build time with west for zephyr projects : how to re-build without the 'build setup' phase eg when just recompiling C files

I'm building my zephyr project for nRF5340, using west.

However, each time I change my code and re-build to try it, my PC (which is pretty recent) takes around 40-50s just re-doing all the build config stuff, rebuilding the core zephyr bit etc before actually compiling the 1 or 2 C files I changed! This ends up being quite frustrating...

I already tell west the --pristine auto option, which does mean it only re-compiles the C I changed, but how can I get it to not redo all the build config stuff ( as generally I have no changes to CMakefiles, no changes to dts files etc)

thanks!

Parents
  • Hi,

    I'm building my zephyr project for nRF5340, using west.

    However, each time I change my code and re-build to try it, my PC (which is pretty recent) takes around 40-50s just re-doing all the build config stuff, rebuilding the core zephyr bit etc before actually compiling the 1 or 2 C files I changed! This ends up being quite frustrating...

    This is expected if you do pristine build every time you build your application.

    I already tell west the --pristine auto option, which does mean it only re-compiles the C I changed, but how can I get it to not redo all the build config stuff ( as generally I have no changes to CMakefiles, no changes to dts files etc)

    I guess that you use --pristine-auto option with west build command. Auto option allows west to choose if the build should be pristine. You can disable pristine if you do not want to be included in west build using "west config build.pristine never". This is shown in the configuration options.
    If you use VS Code, you could just press Build instead of Pristine Build and if you use command line do not include -p option when building. You can read more about building and pristine builds in the documentation.

    Best regards,
    Dejan

  • I see 2 actions that take time:

    1/ remerge of the DTS, setup of the cmake: this takes about 10s (despite no changes to any dts, prj.conf or overlay files):

    C:\work\dev\if-device-nrf53>west build --build-dir cc1-med/build cc1-med --board nrf5340dk_nrf5340_cpuapp --pristine auto -DNCS_TOOLCHAIN_VERSION=NONE -DCACHED_CONF_FILE=prj.conf -DBOARD_ROOT=%CD%
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/work/dev/if-device-nrf53/cc1-med
    -- CMake version: 3.21.0
    -- Cache files will be written to: C:/work/dev/nordic_connect/zephyr/.cache
    -- Zephyr version: 3.5.99 (C:/work/dev/nordic_connect/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf5340dk_nrf5340_cpuapp
    -- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/work/dev/if-device-nrf53/boards/arm/cc1_med_nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp.dts
    -- Found devicetree overlay: C:/work/dev/if-device-nrf53/cc1-med/nrf5340dk_nrf5340_cpuapp.overlay
    -- Generated zephyr.dts: C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/dts.cmake
    Parsing C:/work/dev/nordic_connect/zephyr/Kconfig
    Loaded configuration 'C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/.config'
    No change to configuration in 'C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/.config'
    No change to Kconfig header in 'C:/work/dev/if-device-nrf53/cc1-med/build/zephyr/include/generated/autoconf.h'

    2/ the 'rebuild every time' of the hcièipc image for the CPUNET:

    === child image hci_ipc - CPUNET begin ===

    ....

    [15/15] Generating zephyr/merged_CPUNET.hex

    This takes about 30s and happens every time (pristine, auto, never, whatever)..

    Any way to get it to not do steps 1 and 2 if nothing has changed?

    thanks

  • Solution found : the correct option is

    --pristine=auto

    not

    --pristine auto

    mea culpa....

  • Hi,

    Thank you for the update.

    Best regards,
    Dejan

  • Sorry to reopen this question, but I now find the same behaviour (always rebuilds the config, recomiles to subimage) when I use a board specific DTS and BOARD subdir...

    My full 'pristine' build command line is:

    west build --build-dir cc1-med/build -S dev cc1-med --pristine --board cc1medv1_nrf5340_cpuapp -DBOARD_ROOT=%CD%\cc1-med
    My 'incremental' build line is:
    west build --build-dir cc1-med/build -S dev cc1-med --pristine=auto
    Previously, when using the nrf5340DK DTS + overlay, this would only recompile my source files that had changed. But now with my specific DTS and BOARD_ROOT it insists on always building the config and the subimage...
    Any ideas? 
  • Hi,

    Have you changed NCS version in the meantime or done any other change?

    Is there a reason why you use --pristine instead of --pristine=auto as you did previously?

    Best regards,
    Dejan

  • No changes to NCS versions. 

    The main change is to using a specific board file that is in a 'local project' directory (hence I have to set BOARD_ROOT for the 'pristine' build)

    As I said: 

    My 'incremental' build line is:
    west build --build-dir cc1-med/build -S dev cc1-med --pristine=auto

    but this now systematically rebuilds the makefiles/subimage.

    Is there any known issue with using either snippets (-S) or a specific BOARD_ROOT for the pristine=auto option?

Reply
  • No changes to NCS versions. 

    The main change is to using a specific board file that is in a 'local project' directory (hence I have to set BOARD_ROOT for the 'pristine' build)

    As I said: 

    My 'incremental' build line is:
    west build --build-dir cc1-med/build -S dev cc1-med --pristine=auto

    but this now systematically rebuilds the makefiles/subimage.

    Is there any known issue with using either snippets (-S) or a specific BOARD_ROOT for the pristine=auto option?

Children
Related