forked from sd2psx/firmware
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/version' into develop
- Loading branch information
Showing
5 changed files
with
46 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,10 @@ | ||
add_custom_target(sd2psx_version_generator ALL | ||
COMMAND ${CMAKE_COMMAND} | ||
-D SCRIPT_TEMPLATE=${CMAKE_CURRENT_SOURCE_DIR}/template/version.c | ||
-D SCRIPT_WORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR} | ||
-D SCRIPT_OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.c | ||
-P ${CMAKE_CURRENT_SOURCE_DIR}/script.cmake | ||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/version.c) | ||
|
||
find_package(Git QUIET) | ||
|
||
if(Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git") | ||
execute_process(COMMAND ${GIT_EXECUTABLE} fetch --all --tags --force) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match HEAD --exclude=latest --exclude=nightly | ||
OUTPUT_VARIABLE SD2PSX_VERSION) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD | ||
OUTPUT_VARIABLE SD2PSX_COMMIT) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD | ||
OUTPUT_VARIABLE SD2PSX_BRANCH) | ||
string(REGEX REPLACE "\n$" "" SD2PSX_VERSION "${SD2PSX_VERSION}") | ||
string(REGEX REPLACE "\n$" "" SD2PSX_COMMIT "${SD2PSX_COMMIT}") | ||
string(REGEX REPLACE "\n$" "" SD2PSX_BRANCH "${SD2PSX_BRANCH}") | ||
if("${SD2PSX_VERSION}" STREQUAL "") | ||
set(SD2PSX_VERSION "nightly-${SD2PSX_COMMIT}") | ||
endif() | ||
else() | ||
set(SD2PSX_VERSION "None") | ||
set(SD2PSX_COMMIT "None") | ||
set(SD2PSX_BRANCH "None") | ||
endif() | ||
|
||
|
||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/template/version.c ${CMAKE_CURRENT_BINARY_DIR}/version.c @ONLY) | ||
add_library(sd2psx_version STATIC ${CMAKE_CURRENT_BINARY_DIR}/version.c) | ||
target_include_directories(sd2psx_version PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
|
||
find_package(Git QUIET) | ||
|
||
if(Git_FOUND AND EXISTS "${SCRIPT_WORKING_DIR}/../../.git") | ||
execute_process(COMMAND ${GIT_EXECUTABLE} fetch origin --tags --force WORKING_DIRECTORY ${SCRIPT_WORKING_DIR}) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match HEAD --exclude=latest --exclude=nightly | ||
OUTPUT_VARIABLE SD2PSX_VERSION WORKING_DIRECTORY ${SCRIPT_WORKING_DIR} | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD | ||
OUTPUT_VARIABLE SD2PSX_COMMIT WORKING_DIRECTORY ${SCRIPT_WORKING_DIR} | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD | ||
OUTPUT_VARIABLE SD2PSX_BRANCH WORKING_DIRECTORY ${SCRIPT_WORKING_DIR} | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
string(REGEX REPLACE "\n$" "" SD2PSX_VERSION "${SD2PSX_VERSION}") | ||
string(REGEX REPLACE "\n$" "" SD2PSX_COMMIT "${SD2PSX_COMMIT}") | ||
string(REGEX REPLACE "\n$" "" SD2PSX_BRANCH "${SD2PSX_BRANCH}") | ||
if("${SD2PSX_VERSION}" STREQUAL "") | ||
set(SD2PSX_VERSION "nightly") | ||
endif() | ||
else() | ||
set(SD2PSX_VERSION "None") | ||
set(SD2PSX_COMMIT "None") | ||
set(SD2PSX_BRANCH "None") | ||
endif() | ||
|
||
file(READ ${SCRIPT_TEMPLATE} template_file) | ||
|
||
string(REPLACE "@SD2PSX_VERSION@" ${SD2PSX_VERSION} template_file "${template_file}") | ||
string(REPLACE "@SD2PSX_COMMIT@" ${SD2PSX_COMMIT} template_file "${template_file}") | ||
string(REPLACE "@SD2PSX_BRANCH@" ${SD2PSX_BRANCH} template_file "${template_file}") | ||
|
||
file(WRITE ${SCRIPT_OUTPUT_FILE} "${template_file}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters