Skip to content

app: Add example of VERSION file tracking git index file#92

Merged
henrikbrixandersen merged 1 commit into
zephyrproject-rtos:mainfrom
nordicjm:versiontrackgit
Jan 26, 2026
Merged

app: Add example of VERSION file tracking git index file#92
henrikbrixandersen merged 1 commit into
zephyrproject-rtos:mainfrom
nordicjm:versiontrackgit

Conversation

@nordicjm
Copy link
Copy Markdown
Contributor

Adds an example of how to add the git index file (if this is inside of a git repo) to the dependencies of the application version file, which allows the git commit of the application version to be updated as new commits are added

@nordicjm nordicjm requested a review from tejlmand October 31, 2025 09:26
Copy link
Copy Markdown
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat. I wonder if this could somehow be added as a hook in the main Zephyr repo?

@nordicjm
Copy link
Copy Markdown
Contributor Author

nordicjm commented Nov 3, 2025

Neat. I wonder if this could somehow be added as a hook in the main Zephyr repo?

It was added with one originally but Torsten did not like introducing a git dependency on application repos: zephyrproject-rtos/zephyr#98210 (comment)

Copy link
Copy Markdown
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, some small observations

Comment thread app/CMakeLists.txt Outdated
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE stderr
RESULT_VARIABLE return_code)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit.

Suggested change
RESULT_VARIABLE return_code)
RESULT_VARIABLE return_code
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread app/CMakeLists.txt Outdated
# without a dependency, this will be the case with freestanding applications.
if(NOT return_code)
if(NOT "${stderr}" STREQUAL "")
message(WARNING "APPLICATION_BUILD_VERSION: git rev-parse warned: ${stderr}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using upper case and _ makes APPLICATION_BUILD_VERSION looks like it's referring to a CMake var, which doesn't seem the case, so can be a bit misleading / confusing.

What's the reason for APPLICATION_BUILD_VERSION: first, or could there be another option ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was based on the zephyr one, have changed it to be lower case and no longer make it look like a variable

@nordicjm nordicjm requested a review from tejlmand January 5, 2026 12:22
Adds an example of how to add the git index file (if this is inside
of a git repo) to the dependencies of the application version file,
which allows the git commit of the application version to be
updated as new commits are added

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Copy link
Copy Markdown
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that's cool... just wondering, is this something that you could move in the main repository in a cmake function and then have the app instantiate that by calling it in the app cmakelist? Then one would not have to copypaste this snippet around

@fabiobaltieri
Copy link
Copy Markdown
Member

Ok I've just seen the comments above, nevermind.

@henrikbrixandersen henrikbrixandersen merged commit a58c752 into zephyrproject-rtos:main Jan 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants