1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-09-19 21:07:26 +02: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:
Misa 2024-06-26 22:21:31 -07:00 committed by Misa Elizabeth Kai
parent b0d2a6a372
commit d4425ed762
2 changed files with 52 additions and 41 deletions

View file

@ -212,10 +212,6 @@ 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)
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)
@ -228,7 +224,6 @@ if(NOT OFFICIAL_BUILD)
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
@ -241,7 +236,6 @@ if(NOT OFFICIAL_BUILD)
add_library(InterimVersion STATIC src/InterimVersion.out.c)
list(APPEND STATIC_LIBRARIES InterimVersion)
endif()
endif()
# Build options
if(ENABLE_WARNINGS)

View file

@ -1,5 +1,9 @@
# Expects INPUT_FILE and OUTPUT_FILE to be defined
# find_package sets GIT_FOUND and GIT_EXECUTABLE
find_package(Git)
if(GIT_FOUND)
# Get interim commit and date of commit
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
@ -18,6 +22,19 @@ EXECUTE_PROCESS(
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}")