mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Regenerate 'build.txt' after DLL project builds
This post build event function regenerates the 'build.txt' file after compiling the engine projects. It takes the branch name, commit hash (short), current time and time designator.
This commit is contained in:
parent
b3fc2c5adb
commit
d8ac2852ba
49
r5dev/cmake/PostBuild.cmake
Normal file
49
r5dev/cmake/PostBuild.cmake
Normal file
@ -0,0 +1,49 @@
|
||||
# -----------------------------------------------------------------------------
|
||||
# Creates and writes the build string after building a project
|
||||
# -----------------------------------------------------------------------------
|
||||
function( WriteBuildString OUTPUT_DIR )
|
||||
# Get the current date and time
|
||||
string( TIMESTAMP CURRENT_DATE "%Y_%m_%d_%I_%M" ) # Use %I for 12-hour clock
|
||||
|
||||
# Compute AM/PM
|
||||
string( TIMESTAMP CURRENT_HOUR "%H" )
|
||||
if( CURRENT_HOUR LESS 12 )
|
||||
set( TIME_DESIGNATOR "AM" )
|
||||
else()
|
||||
set( TIME_DESIGNATOR "PM" )
|
||||
endif()
|
||||
|
||||
# Get the current git commit hash
|
||||
execute_process( COMMAND
|
||||
git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Convert the hash to uppercase
|
||||
string( TOUPPER
|
||||
"${GIT_COMMIT_HASH} GIT_COMMIT_HASH"
|
||||
)
|
||||
|
||||
# Get the current git branch name
|
||||
execute_process( COMMAND
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Construct the build string
|
||||
set( BUILD_STRING
|
||||
"R5pc_${GIT_BRANCH_NAME}_N1094_${GIT_COMMIT_HASH}_${CURRENT_DATE}_${TIME_DESIGNATOR}\n"
|
||||
)
|
||||
|
||||
# Write the build string to a file
|
||||
file( WRITE
|
||||
"${CMAKE_SOURCE_DIR}/${OUTPUT_DIR}/build.txt ${BUILD_STRING}"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Initiate the creation command
|
||||
WriteBuildString( "../../../game" )
|
@ -120,6 +120,10 @@ target_link_options( ${PROJECT_NAME} PRIVATE
|
||||
"/STACK:8000000" # Match game executable stack reserve size
|
||||
)
|
||||
|
||||
add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -P ${ENGINE_SOURCE_DIR}/cmake/PostBuild.cmake
|
||||
)
|
||||
|
||||
endmacro()
|
||||
|
||||
add_sdk_project( "gamesdk" )
|
||||
|
Loading…
x
Reference in New Issue
Block a user