cmake: fix .ldc chksum fallback when no SOURCE_DIRECTORY/.git

Fixes old (Aug 2020) and untested commit b2a325a3b7 ("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>
This commit is contained in:
Marc Herbert 2021-12-24 00:45:26 +00:00 committed by Liam Girdwood
parent 7981197f6d
commit 5d66f1dac4
1 changed files with 4 additions and 3 deletions

View File

@ -110,13 +110,14 @@ if(EXISTS ${SOF_ROOT_SOURCE_DIRECTORY}/.git/)
message(STATUS "Source content hash: ${SOF_SRC_HASH}. \ message(STATUS "Source content hash: ${SOF_SRC_HASH}. \
Note: by design, source hash is broken by config changes. See #3890.") Note: by design, source hash is broken by config changes. See #3890.")
else() # Zephyr, tarball,... else() # Zephyr, tarball,...
if("${GIT_LOG_HASH}") if(NOT "${GIT_LOG_HASH}" STREQUAL "")
string(SUBSTRING "${GIT_LOG_HASH}" 0 8 SOF_SRC_HASH) string(SUBSTRING "${GIT_LOG_HASH}" 0 8 SOF_SRC_HASH)
else() else()
set(SOF_SRC_HASH "0") set(SOF_SRC_HASH "baadf00d")
endif() endif()
message(WARNING "${SOF_ROOT_SOURCE_DIRECTORY}/.git not found, \ message(WARNING "${SOF_ROOT_SOURCE_DIRECTORY}/.git not found, \
source content hash cannot computed. Using GIT_LOG_HASH for .ldc instead.") source content hash cannot computed for the .ldc. Using SOF_SRC_HASH=${SOF_SRC_HASH} \
from GIT_LOG_HASH instead")
endif() endif()
# for SOF_BUILD # for SOF_BUILD