From 456fe4be10f4c4c5e007a014a75412e3780e00c5 Mon Sep 17 00:00:00 2001 From: Suraj Sonawane Date: Wed, 5 Mar 2025 12:34:24 +0530 Subject: [PATCH] scripts/cmake: Set SOF_MICRO to 99 on main branch This ensures SOF_MICRO is set to 99 when on the main branch, aligning with Zephyr's approach for never-released branches. For other branches, it remains 0 to maintain consistency with xtensa-build-zephyr.py. Signed-off-by: Suraj Sonawane --- scripts/cmake/version.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/cmake/version.cmake b/scripts/cmake/version.cmake index 54e4d0339493..3c00a6609d1f 100644 --- a/scripts/cmake/version.cmake +++ b/scripts/cmake/version.cmake @@ -86,9 +86,21 @@ string(JSON SOF_MICRO ERROR_VARIABLE micro_error # Don't confuse "error not found" with "version not found" if(NOT "${micro_error}" STREQUAL "NOTFOUND") message(STATUS "versions.json: ${micro_error}, defaulting to 0") - # TODO: default this to .99 on the main, never released branch like zephyr does - # Keep this default SOF_MICRO the same as the one in xtensa-build-zephyr.py - set(SOF_MICRO 0) + # Detect if the current branch is "main" + execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${SOF_ROOT_SOURCE_DIRECTORY} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Set SOF_MICRO to 99 only on the "main" branch + if("${GIT_BRANCH}" STREQUAL "main") + set(SOF_MICRO 99) + else() + # Keep this default SOF_MICRO the same as the one in xtensa-build-zephyr.py + set(SOF_MICRO 0) + endif() endif() string(SUBSTRING "${GIT_LOG_HASH}" 0 5 SOF_TAG)