better handling of non-git builds

This commit is contained in:
walker0643 2018-05-14 12:55:03 -04:00
parent 0b2dfd80e2
commit 8b69f9fe03
1 changed files with 6 additions and 12 deletions

View File

@ -45,10 +45,7 @@ if (NOT DEFINED BARRIER_REVISION)
string (SUBSTRING $ENV{GIT_COMMIT} 0 8 BARRIER_REVISION) string (SUBSTRING $ENV{GIT_COMMIT} 0 8 BARRIER_REVISION)
else() else()
find_program (GIT_BINARY git) find_program (GIT_BINARY git)
if (GIT_BINARY STREQUAL "GIT_BINARY-NOTFOUND") if (NOT GIT_BINARY STREQUAL "GIT_BINARY-NOTFOUND")
set (BARRIER_REVISION "00000000")
message (WARNING "git not found. revision hash set to ${BARRIER_REVISION}")
else()
execute_process ( execute_process (
COMMAND git rev-parse --short=8 HEAD COMMAND git rev-parse --short=8 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@ -59,15 +56,12 @@ if (NOT DEFINED BARRIER_REVISION)
endif() endif()
endif() endif()
if (DEFINED BARRIER_REVISION) string(LENGTH "${BARRIER_REVISION}" BARRIER_REVISION_LENGTH)
string(LENGTH ${BARRIER_REVISION} BARRIER_REVISION_LENGTH) if (NOT BARRIER_REVISION_LENGTH EQUAL 8 OR NOT BARRIER_REVISION MATCHES "^[a-f0-9]+")
if (NOT ((BARRIER_REVISION MATCHES "^[a-f0-9]+") AND (BARRIER_REVISION_LENGTH EQUAL "8"))) set (BARRIER_REVISION "00000000")
message (FATAL_ERROR "BARRIER_REVISION ('${BARRIER_REVISION}') should be a short commit hash") message (WARNING "revision not found. setting to ${BARRIER_REVISION}")
endif()
unset (BARRIER_REVISION_LENGTH)
else()
set (BARRIER_REVISION "0badc0de")
endif() endif()
unset (BARRIER_REVISION_LENGTH)
if (DEFINED ENV{BUILD_NUMBER}) if (DEFINED ENV{BUILD_NUMBER})
set (BARRIER_BUILD_NUMBER $ENV{BUILD_NUMBER}) set (BARRIER_BUILD_NUMBER $ENV{BUILD_NUMBER})