mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-09 20:49:42 +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)
|
if(NOT OFFICIAL_BUILD)
|
||||||
# Add interim commit hash and its date to the build
|
# Add interim commit hash and its date to the build
|
||||||
|
|
||||||
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
# These filenames have to be qualified, because when we run
|
||||||
find_package(Git)
|
# 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)
|
add_custom_target(
|
||||||
# These filenames have to be qualified, because when we run
|
GenerateVersion ALL
|
||||||
# the CMake script, its work dir gets set to the build folder
|
# This BYPRODUCTS line is required for this to be ran every time
|
||||||
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.in.c)
|
BYPRODUCTS ${VERSION_OUTPUT_FILE}
|
||||||
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.out.c)
|
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(
|
add_dependencies(VVVVVV GenerateVersion)
|
||||||
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)
|
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)
|
||||||
add_library(InterimVersion STATIC src/InterimVersion.out.c)
|
|
||||||
list(APPEND STATIC_LIBRARIES InterimVersion)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build options
|
# Build options
|
||||||
|
|
|
@ -1,23 +1,40 @@
|
||||||
# Expects INPUT_FILE and OUTPUT_FILE to be defined
|
# Expects INPUT_FILE and OUTPUT_FILE to be defined
|
||||||
|
|
||||||
# Get interim commit and date of commit
|
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
||||||
EXECUTE_PROCESS(
|
find_package(Git)
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
|
||||||
OUTPUT_VARIABLE INTERIM_COMMIT
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
EXECUTE_PROCESS(
|
if(GIT_FOUND)
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
# Get interim commit and date of commit
|
||||||
OUTPUT_VARIABLE COMMIT_DATE
|
EXECUTE_PROCESS(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||||
)
|
OUTPUT_VARIABLE INTERIM_COMMIT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" branch --show-current
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
||||||
OUTPUT_VARIABLE BRANCH_NAME
|
OUTPUT_VARIABLE COMMIT_DATE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
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}")
|
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE}) on branch ${BRANCH_NAME}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue