mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 01:29:43 +01:00
Always have interim version indicators
Previously, the interim version indicators (commit, date, and branch) would go away on development builds if git didn't exist. And if it did exist but provided blank output for whatever reason, that was almost exactly the same as not having them at all (save for the window title saying "VVVVVV []" which can be easy to overlook). This was bad because it complicates troubleshooting when you potentially have an unofficial or in-development build since those get distributed around or compiled by some people frequently. Now, there will always be an interim version indicators unless the game is compiled with -DOFFICIAL_BUILD=ON. And if the indicators are blank for any reason, they will just be replaced with placeholder defaults so they will still show up.
This commit is contained in:
parent
b0d2a6a372
commit
d4425ed762
2 changed files with 52 additions and 41 deletions
|
@ -212,35 +212,29 @@ set(SBIDI_SRC ../third_party/SheenBidi/Source/SheenBidi.c)
|
|||
if(NOT OFFICIAL_BUILD)
|
||||
# Add interim commit hash and its date to the build
|
||||
|
||||
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
||||
find_package(Git)
|
||||
# These filenames have to be qualified, because when we run
|
||||
# the CMake script, its work dir gets set to the build folder
|
||||
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.in.c)
|
||||
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.out.c)
|
||||
|
||||
if(GIT_FOUND)
|
||||
# These filenames have to be qualified, because when we run
|
||||
# the CMake script, its work dir gets set to the build folder
|
||||
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.in.c)
|
||||
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.out.c)
|
||||
add_custom_target(
|
||||
GenerateVersion ALL
|
||||
# This BYPRODUCTS line is required for this to be ran every time
|
||||
BYPRODUCTS ${VERSION_OUTPUT_FILE}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
# These args have to be passed through, otherwise the script can't see them
|
||||
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
|
||||
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
||||
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
GenerateVersion ALL
|
||||
# This BYPRODUCTS line is required for this to be ran every time
|
||||
BYPRODUCTS ${VERSION_OUTPUT_FILE}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
# These args have to be passed through, otherwise the script can't see them
|
||||
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
|
||||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
||||
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
||||
)
|
||||
add_dependencies(VVVVVV GenerateVersion)
|
||||
|
||||
add_dependencies(VVVVVV GenerateVersion)
|
||||
target_compile_definitions(VVVVVV PRIVATE -DINTERIM_VERSION_EXISTS)
|
||||
|
||||
target_compile_definitions(VVVVVV PRIVATE -DINTERIM_VERSION_EXISTS)
|
||||
|
||||
add_library(InterimVersion STATIC src/InterimVersion.out.c)
|
||||
list(APPEND STATIC_LIBRARIES InterimVersion)
|
||||
endif()
|
||||
add_library(InterimVersion STATIC src/InterimVersion.out.c)
|
||||
list(APPEND STATIC_LIBRARIES InterimVersion)
|
||||
endif()
|
||||
|
||||
# Build options
|
||||
|
|
|
@ -1,23 +1,40 @@
|
|||
# Expects INPUT_FILE and OUTPUT_FILE to be defined
|
||||
|
||||
# Get interim commit and date of commit
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||
OUTPUT_VARIABLE INTERIM_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
||||
find_package(Git)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
||||
OUTPUT_VARIABLE COMMIT_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(GIT_FOUND)
|
||||
# Get interim commit and date of commit
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||
OUTPUT_VARIABLE INTERIM_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" branch --show-current
|
||||
OUTPUT_VARIABLE BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
||||
OUTPUT_VARIABLE COMMIT_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND "${GIT_EXECUTABLE}" branch --show-current
|
||||
OUTPUT_VARIABLE BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
|
||||
# Defaults if we don't have git or its commands fail for any reason or give blanks
|
||||
# For annoying CMake reasons, must use "${VAR}" syntax rather than VAR
|
||||
if("${INTERIM_COMMIT}" STREQUAL "")
|
||||
set(INTERIM_COMMIT "(commit?)")
|
||||
endif()
|
||||
if("${COMMIT_DATE}" STREQUAL "")
|
||||
set(COMMIT_DATE "(date?)")
|
||||
endif()
|
||||
if("${BRANCH_NAME}" STREQUAL "")
|
||||
set(BRANCH_NAME "(branch?)")
|
||||
endif()
|
||||
|
||||
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE}) on branch ${BRANCH_NAME}")
|
||||
|
||||
|
|
Loading…
Reference in a new issue