zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.78k stars 6.58k forks source link

cmake: KERNEL_VERSION_CUSTOMIZATION and APP_VERSION_CUSTOMIZATION do not work anymore #80193

Open mlasch opened 1 week ago

mlasch commented 1 week ago

https://github.com/zephyrproject-rtos/zephyr/pull/61635 introduced a feature to set additional defines in version.h and app_version.h. This seems to be broken, at least in the current version (beginning with Zephyr 3.6.0 AFAIK).

Steps to reproduce Build with KERNEL_VERSION_CUSTOMIZATION

west build -palways -b nrf52840dk/nrf52840 zephyr/samples/hello_world -- -DKERNEL_VERSION_CUSTOMIZATION="#define;BANNER_VERSION;STRINGIFY(blah)"

as mentioned in the PR. Then find a custom define in build/zephyr/include/generated/version.h. Note: in Zephyr 3.7.0 version.h moved to a new location: build/zephyr/include/generated/zephyr/version.h.

The regression appears to be present already in Zephyr 3.6.0.

...
#define KERNEL_VERSION_STRING  "3.5.0"

#define BUILD_VERSION zephyr-v3.5.0
#define BANNER_VERSION STRINGIFY(blah)
...
...
#define KERNEL_VERSION_STRING           "3.6.0"
#define KERNEL_VERSION_EXTENDED_STRING  "3.6.0+0"
#define KERNEL_VERSION_TWEAK_STRING     "3.6.0+0"

#define BUILD_VERSION v3.6.0
<missing>
...

Also there seems to be no documentation about this feature.

Expected behavior KERNEL_VERSION_CUSTOMIZATION should produce an entry in the version.h header file. Same for APP_VERSION_CUSTOMIZATION in app_version.h.

Impact KERNEL_VERSION_CUSTOMIZATION and APP_VERSION_CUSTOMIZATION cannot be used.

rettichschnidi commented 1 week ago

Seems like this feature only be used via CMake properties, not via CLI anymore due to #62395.

Example:

$ git diff samples/hello_world/CMakeLists.txt
diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt
index ecb7d24bb8f..9b22926d66e 100644
--- a/samples/hello_world/CMakeLists.txt
+++ b/samples/hello_world/CMakeLists.txt
@@ -6,3 +6,4 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
 project(hello_world)

 target_sources(app PRIVATE src/main.c)
+set_target_properties(version_h PROPERTIES KERNEL_VERSION_CUSTOMIZATION "#define;BANNER_VERSION;STRINGIFY(blah)")

Resulting Build:

$ west build --pristine -b nrf52840dk/nrf52840 zephyr/samples/hello_world
<snip>
$ rg BANNER_VERSION build/zephyr/include/generated/zephyr/version.h
23:#define BANNER_VERSION STRINGIFY(blah)