Skip to content

Commit 5d66f1d

Browse files
marc-hblgirdwood
authored andcommitted
cmake: fix .ldc chksum fallback when no SOURCE_DIRECTORY/.git
Fixes old (Aug 2020) and untested commit b2a325a ("cmake: Handle empty SOF_SRC_HASH_LONG") which tried to use GIT_LOG_HASH as a fallback for the SOF_SRC_HASH .ldc checksum but always fell back on "0" instead because of a misunderstanding of cmake's surprisingly complex "if" operator. Before Zephyr this was not an issue in practice because GIT_LOG_HASH was empty anyway when SOURCE_DIRECTORY/.git was missing, so there was nothing to lose. For the Zephyr builds this will now use the SOF SHA1 as the .ldc checksum for now. Probably not ideal yet but far better than the current constant "0" which means no check at all. Also log the SOF_SRC_HASH fallback value now and change the second fallback (when GIT_LOG_HASH is also missing) from "0" to the searchable hexspeak "baadf00d". Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 7981197 commit 5d66f1d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

scripts/cmake/version.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ if(EXISTS ${SOF_ROOT_SOURCE_DIRECTORY}/.git/)
110110
message(STATUS "Source content hash: ${SOF_SRC_HASH}. \
111111
Note: by design, source hash is broken by config changes. See #3890.")
112112
else() # Zephyr, tarball,...
113-
if("${GIT_LOG_HASH}")
113+
if(NOT "${GIT_LOG_HASH}" STREQUAL "")
114114
string(SUBSTRING "${GIT_LOG_HASH}" 0 8 SOF_SRC_HASH)
115115
else()
116-
set(SOF_SRC_HASH "0")
116+
set(SOF_SRC_HASH "baadf00d")
117117
endif()
118118
message(WARNING "${SOF_ROOT_SOURCE_DIRECTORY}/.git not found, \
119-
source content hash cannot computed. Using GIT_LOG_HASH for .ldc instead.")
119+
source content hash cannot computed for the .ldc. Using SOF_SRC_HASH=${SOF_SRC_HASH} \
120+
from GIT_LOG_HASH instead")
120121
endif()
121122

122123
# for SOF_BUILD

0 commit comments

Comments
 (0)