From 58d355196041d6c79300b76067f535f14ac3b4b1 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 14 Jan 2022 05:16:56 +0000 Subject: [PATCH] version.cmake: more robust logging of the current git commit and parents execute_process() runs in the current directory of the process invoking cmake. This can be completely outside the git repo. Fixes commit a5899812b7f5 ("version.cmake: don't trust CI to record time and versions and log ourselves") Signed-off-by: Marc Herbert --- scripts/cmake/version.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/cmake/version.cmake b/scripts/cmake/version.cmake index a82678596..08d624d12 100644 --- a/scripts/cmake/version.cmake +++ b/scripts/cmake/version.cmake @@ -27,10 +27,11 @@ message(STATUS "version.cmake starting SOF build at ${build_start_time} UTC") # moving target: the latest target branch. In that case the SHA version # gathered by git describe is disposable hence useless. Only the # --parents SHA are useful. -message(STATUS "Building git commit with parent(s):") +message(STATUS "Building SOF git commit with parent(s):") # Note execute_process() failures are ignored by default (missing git...) execute_process( - COMMAND git log --parents --oneline --decorate -n 1 HEAD + COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" + log --parents --oneline --decorate -n 1 HEAD ) @@ -134,6 +135,7 @@ function(sof_check_version_h) "#define SOF_SRC_HASH 0x${SOF_SRC_HASH}\n" ) + # Regenerating the same file would cause a full rebuild. if(EXISTS "${VERSION_H_PATH}") file(READ "${VERSION_H_PATH}" old_version_content) if("${header_content}" STREQUAL "${old_version_content}")