aports/testing/ktx/ktx_override_version.patch
2024-07-22 05:28:59 +00:00

72 lines
2.3 KiB
Diff

--- a/cmake/version.cmake
+++ b/cmake/version.cmake
@@ -108,8 +108,10 @@ function(generate_version _var )
set(${_var} "${KTX_VERSION}" PARENT_SCOPE)
endfunction()
-# Get latest tag
-git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*)
+# Get latest tag from git if not passed to cmake
+if(NOT KTX_VERSION_FULL)
+ git_describe_raw(KTX_VERSION_FULL --abbrev=0 --match v[0-9]*)
+endif()
#message("KTX full version: ${KTX_VERSION_FULL}")
# generate_version(TOKTX_VERSION tools/toktx)
@@ -174,7 +176,7 @@ function( create_version_header dest_path target )
add_custom_command(
OUTPUT ${version_h_output}
# On Windows this command has to be invoked by a shell in order to work
- COMMAND ${BASH_EXECUTABLE} -c "\"./mkversion\" \"-o\" \"version.h\" \"${dest_path}\""
+ COMMAND ${BASH_EXECUTABLE} -c "\"./mkversion\" \"-v\" \"${KTX_VERSION_FULL}\" \"-o\" \"version.h\" \"${dest_path}\""
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate ${version_h_output}"
VERBATIM
@@ -182,7 +184,7 @@ function( create_version_header dest_path target )
else()
add_custom_command(
OUTPUT ${version_h_output}
- COMMAND ./mkversion -o version.h ${dest_path}
+ COMMAND ./mkversion -v ${KTX_VERSION_FULL} -o version.h ${dest_path}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate ${version_h_output}"
VERBATIM
--- a/mkversion
+++ b/mkversion
@@ -89,7 +89,10 @@ function setfile() {
# Figure out the object name and write its version file.
function writeversion() {
- genversion $1
+ # Extract version from git if it is not passed via command line
+ if [-z "$VN"]; then
+ genversion $1
+ fi
local vfp;
if [ -z "$1" ]; then
vfp=$VF
@@ -107,14 +110,14 @@ function writeversion() {
}
function usage() {
- echo "Usage: $0 [-a] [-f] [-n] [-o <outfile>] [<object>]"
+ echo "Usage: $0 [-a] [-f] [-n] [-v version] [-o <outfile>] [<object>]"
exit 1
}
force=0
dry_run=0
write_all=0;
-args=$(getopt afno: $*)
+args=$(getopt afnv:o: $*)
set -- $args
for i; do
@@ -125,6 +128,7 @@ for i; do
shift;;
-n) dry_run=1;
shift;;
+ -v) VN=$2; shift; shift;;
-o) VF=$2; shift; shift;;
--) shift; break;;
esac