Commit 4774c184 authored by Jan Dinkelbach's avatar Jan Dinkelbach

fix submodule build: throwing only warning when git version unavailable

parent 16d72c59
......@@ -47,69 +47,71 @@ function(GetVersion DIR PREFIX)
)
if(NOT RC EQUAL 0)
message(FATAL_ERROR
set(FOUND_GIT_VERSION OFF PARENT_SCOPE)
message(WARNING
"Failed to retrieve version information from Git. "
"Make sure that the source directory is a Git repo and "
"contains at least one valid tag like 'v0.1.0'"
)
endif()
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\1" MAJOR_VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\2" MINOR_VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" PATCH_VERSION ${VERSION_STR})
else()
set(FOUND_GIT_VERSION ON PARENT_SCOPE)
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\1" MAJOR_VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\2" MINOR_VERSION ${VERSION_STR})
string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" PATCH_VERSION ${VERSION_STR})
string(TIMESTAMP BUILD_DATE "%Y%m%d")
string(TIMESTAMP BUILD_DATE "%Y%m%d")
if(CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" VARIANT)
else()
set(VARIANT "release")
endif()
if(CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" VARIANT)
else()
set(VARIANT "release")
endif()
if(DEFINED ENV{CI})
string(APPEND VARIANT "-ci")
string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 GIT_REV)
set(GIT_BRANCH $ENV{CI_COMMIT_REF_NAME})
else()
execute_process(
COMMAND git rev-parse --short=7 HEAD
WORKING_DIRECTORY ${DIR}
OUTPUT_VARIABLE GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED ENV{CI})
string(APPEND VARIANT "-ci")
string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 GIT_REV)
set(GIT_BRANCH $ENV{CI_COMMIT_REF_NAME})
else()
execute_process(
COMMAND git rev-parse --short=7 HEAD
WORKING_DIRECTORY ${DIR}
OUTPUT_VARIABLE GIT_REV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if(DEFINED ENV{CI_COMMIT_TAG})
set(RELEASE 1)
else()
string(REPLACE "-" "_" GIT_BRANCH_NORM ${GIT_BRANCH})
string(REPLACE "-" "_" VARIANT_NORM ${VARIANT})
if(DEFINED ENV{CI_COMMIT_TAG})
set(RELEASE 1)
else()
string(REPLACE "-" "_" GIT_BRANCH_NORM ${GIT_BRANCH})
string(REPLACE "-" "_" VARIANT_NORM ${VARIANT})
set(RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}")
endif()
set(RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}")
endif()
set(BUILD_ID "v${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${GIT_REV}-${VARIANT}" )
set(BUILD_ID "v${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${GIT_REV}-${VARIANT}" )
# Return results to parent scope
set(${PREFIX}_VERSION_STR ${VERSION_STR} PARENT_SCOPE)
set(${PREFIX}_VERSION ${VERSION} PARENT_SCOPE)
set(${PREFIX}_MAJOR_VERSION ${MAJOR_VERSION} PARENT_SCOPE)
set(${PREFIX}_MINOR_VERSION ${MINOR_VERSION} PARENT_SCOPE)
set(${PREFIX}_PATCH_VERSION ${PATCH_VERSION} PARENT_SCOPE)
set(${PREFIX}_RELEASE ${RELEASE} PARENT_SCOPE)
set(${PREFIX}_GIT_REV ${GIT_REV} PARENT_SCOPE)
set(${PREFIX}_GIT_BRANCH ${GIT_BRANCH} PARENT_SCOPE)
set(${PREFIX}_GIT_BRANCH_NORM ${GIT_BRANCH_NORM} PARENT_SCOPE)
set(${PREFIX}_VARIANT ${VARIANT} PARENT_SCOPE)
set(${PREFIX}_VARIANT_NORM ${VARIANT_NORM} PARENT_SCOPE)
set(${PREFIX}_BUILD_ID ${BUILD_ID} PARENT_SCOPE)
set(${PREFIX}_BUILD_DATE ${BUILD_DATE} PARENT_SCOPE)
# Return results to parent scope
set(${PREFIX}_VERSION_STR ${VERSION_STR} PARENT_SCOPE)
set(${PREFIX}_VERSION ${VERSION} PARENT_SCOPE)
set(${PREFIX}_MAJOR_VERSION ${MAJOR_VERSION} PARENT_SCOPE)
set(${PREFIX}_MINOR_VERSION ${MINOR_VERSION} PARENT_SCOPE)
set(${PREFIX}_PATCH_VERSION ${PATCH_VERSION} PARENT_SCOPE)
set(${PREFIX}_RELEASE ${RELEASE} PARENT_SCOPE)
set(${PREFIX}_GIT_REV ${GIT_REV} PARENT_SCOPE)
set(${PREFIX}_GIT_BRANCH ${GIT_BRANCH} PARENT_SCOPE)
set(${PREFIX}_GIT_BRANCH_NORM ${GIT_BRANCH_NORM} PARENT_SCOPE)
set(${PREFIX}_VARIANT ${VARIANT} PARENT_SCOPE)
set(${PREFIX}_VARIANT_NORM ${VARIANT_NORM} PARENT_SCOPE)
set(${PREFIX}_BUILD_ID ${BUILD_ID} PARENT_SCOPE)
set(${PREFIX}_BUILD_DATE ${BUILD_DATE} PARENT_SCOPE)
endif()
endfunction(GetVersion)
......@@ -138,16 +138,18 @@ if(TOPLEVEL_PROJECT)
add_feature_info(GSL WITH_GSL "Use GNU Scientific library")
feature_summary(WHAT ALL VAR enabledFeaturesText)
message(STATUS "Building ${CMAKE_PROJECT_NAME}:")
message(STATUS "Feature summary for DPsim")
message(STATUS "${enabledFeaturesText}")
message(STATUS " VERSION: ${DPSIM_VERSION}")
message(STATUS " RELEASE: ${DPSIM_RELEASE}")
message(STATUS " GIT_REV: ${DPSIM_GIT_REV}")
message(STATUS " GIT_BRANCH: ${DPSIM_GIT_BRANCH}")
message(STATUS " VARIANT: ${DPSIM_VARIANT}")
message(STATUS " BUILD_ID: ${DPSIM_BUILD_ID}")
message(STATUS " BUILD_DATE: ${DPSIM_BUILD_DATE}")
if (FOUND_GIT_VERSION)
message(STATUS "Building ${CMAKE_PROJECT_NAME}:")
message(STATUS "Feature summary for DPsim")
message(STATUS "${enabledFeaturesText}")
message(STATUS " VERSION: ${DPSIM_VERSION}")
message(STATUS " RELEASE: ${DPSIM_RELEASE}")
message(STATUS " GIT_REV: ${DPSIM_GIT_REV}")
message(STATUS " GIT_BRANCH: ${DPSIM_GIT_BRANCH}")
message(STATUS " VARIANT: ${DPSIM_VARIANT}")
message(STATUS " BUILD_ID: ${DPSIM_BUILD_ID}")
message(STATUS " BUILD_DATE: ${DPSIM_BUILD_DATE}")
endif()
endif()
include(DPsimPackaging)
......@@ -34,7 +34,7 @@ TIME=$(date -d "+10 seconds" +%Y%m%dT%H%M%S) #-Iseconds
echo "Start simulation at: $TIME"
# Simulation params
OPTS="--timestep 1 --duration $((60)) --system-freq 50 --start-at $TIME --solver-domain SP --solver-type NRP"
OPTS="--timestep 1 --duration $((300)) --system-freq 50 --start-at $TIME --solver-domain SP --solver-type NRP"
echo "Simulation params: $OPTS"
CPS_LOG_PREFIX="[Sys ] " \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment