mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39: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,10 +212,6 @@ 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
|
|
||||||
find_package(Git)
|
|
||||||
|
|
||||||
if(GIT_FOUND)
|
|
||||||
# These filenames have to be qualified, because when we run
|
# These filenames have to be qualified, because when we run
|
||||||
# the CMake script, its work dir gets set to the build folder
|
# 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_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.in.c)
|
||||||
|
@ -228,7 +224,6 @@ if(NOT OFFICIAL_BUILD)
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
# These args have to be passed through, otherwise the script can't see them
|
# 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)
|
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
|
||||||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
|
||||||
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
||||||
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
||||||
|
@ -240,7 +235,6 @@ if(NOT OFFICIAL_BUILD)
|
||||||
|
|
||||||
add_library(InterimVersion STATIC src/InterimVersion.out.c)
|
add_library(InterimVersion STATIC src/InterimVersion.out.c)
|
||||||
list(APPEND STATIC_LIBRARIES InterimVersion)
|
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)
|
||||||
|
|
||||||
|
if(GIT_FOUND)
|
||||||
|
# Get interim commit and date of commit
|
||||||
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||||
OUTPUT_VARIABLE INTERIM_COMMIT
|
OUTPUT_VARIABLE INTERIM_COMMIT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=short
|
||||||
OUTPUT_VARIABLE COMMIT_DATE
|
OUTPUT_VARIABLE COMMIT_DATE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" branch --show-current
|
COMMAND "${GIT_EXECUTABLE}" branch --show-current
|
||||||
OUTPUT_VARIABLE BRANCH_NAME
|
OUTPUT_VARIABLE BRANCH_NAME
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
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