ccollins476ad opened a new issue #162: Build failures for conditional 
dependency lists
URL: https://github.com/apache/mynewt-newt/issues/162
 
 
   Newt fails to build some targets when one or more packages has a conditional 
dependency list.  I will describe the problem in more detail, but first, here 
is one way to replicate the issue:
   
   ## Replicate Steps
   
   (this requires the apache-mynewt-core and mcuboot repos)
   
   1. Create the following target:
   ```
   targets/nrf52dk_boot
       app=@mcuboot/boot/mynewt
       bsp=@apache-mynewt-core/hw/bsp/nrf52dk
       build_profile=optimized
       
syscfg=BOOTUTIL_SIGN_ECC=0:BOOTUTIL_SIGN_RSA=1:BOOT_SERIAL=1:OS_CPUTIME_TIMER_NUM=-1:TIMER_0=0:UART_0=0
   ```
   
   2. Modify `repos/mcuboot/boot/mynewt.pkg.yml` as follows:
   ```
   diff --git a/boot/mynewt/pkg.yml b/boot/mynewt/pkg.yml
   index a005522..936f7dc 100644
   --- a/boot/mynewt/pkg.yml
   +++ b/boot/mynewt/pkg.yml
   @@ -32,7 +32,10 @@ pkg.deps:
        - "@mcuboot/boot/mynewt/mcuboot_config"
        - "@mcuboot/boot/bootutil"
        - "@apache-mynewt-core/kernel/os"
   -    - "@apache-mynewt-core/sys/console/minimal"
   +
   +pkg.deps.'!BOOT_SERIAL':
   +    - "@apache-mynewt-core/sys/console/stub"
   
    pkg.deps.BOOT_SERIAL:
        - "@mcuboot/boot/boot_serial"
   +    - "@apache-mynewt-core/sys/console/minimal"
   ```
   
   (i.e., only depend on the minimal console if `BOOT_SERIAL` is enabled; 
otherwise, depend on the stub console.  This is how the package would be 
defined if it weren't for this newt bug, as `console/minimal` adds extra code 
size that isn't needed)
   
   3. Build the target.
   
   This yields the following output:
   ```
   Building target targets/nrf52dk_boot
   * Warning: setting CONSOLE_UART_DEV redefined (pkg1=sys/console/minimal 
pkg2=sys/console/stub)
   * Warning: setting CONSOLE_UART_BAUD redefined (pkg1=sys/console/minimal 
pkg2=sys/console/stub)
   * Warning: setting CONSOLE_UART_FLOW_CONTROL redefined 
(pkg1=sys/console/minimal pkg2=sys/console/stub)
   * Warning: setting CONSOLE_UART_BAUD redefined (pkg1=sys/console/minimal 
pkg2=sys/console/stub)
   * Warning: setting CONSOLE_UART_FLOW_CONTROL redefined 
(pkg1=sys/console/minimal pkg2=sys/console/stub)
   * Warning: setting CONSOLE_UART_DEV redefined (pkg1=sys/console/minimal 
pkg2=sys/console/stub)
   Error: Package not found sys/console/stub; required by kernel/os
   ```
   
   These warnings and the error are incorrect.  Only one console package should 
be included in the build (`console/minimal` since our target defines 
`BOOT_SERIAL`), so the settings should not be getting redefined.  Furthermore, 
`kernel/os` should not be looking for `console/stub`; its `CONSOLE` API 
requirement should be satisfied by `console/minimal`.
   
   ## Explanation
   
   This problem arises because newt resolves API requirements at the same time 
as it resolves package dependencies and calculates syscfg state.  When package 
resolution first begins, the `BOOT_SERIAL` setting is undefined, since the 
target's `syscfg.yml` file hasn't been processed yet.  Consequently, the boot 
loader app depends on `console/stub`, *not* `console/minimal`.  When newt 
processes the `kernel/os` package, it resolves the `CONSOLE` API requirement by 
adding a hard dependency to the only suitable package in the system: 
`console/stub`.
   
   Later, when the target's `syscfg.yml` file is processed, newt determines 
that `console/minimal` should be pulled in, and `console/stub` should be 
removed from the resolution state.  However, two problems have already 
occurred: 1) `kernel/os` already has a dependency on `console/stub`, and 2) 
`console/stub`'s settings are still in syscfg, so when `console/minimal`'s 
syscfg is read, newt reports redefinition errors for the identically named 
settings.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to