Merge commit '2dc788cb9ffa83a2840e62f5ad2d0a7055cfcb19' into main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
diff --git a/.gitignore b/.gitignore
index 5d5849b..1ab87fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@ build
gen
Build
buildbot
+/VERSION
*.so
*.so.*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27160ee..a6d865b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2930,29 +2930,36 @@ listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
# Compat helpers for the configuration files
+
+if(EXISTS "${PROJECT_SOURCE_DIR}/VERSION")
+ file(READ "${PROJECT_SOURCE_DIR}/VERSION" SDL_SOURCE_VERSION)
+endif()
+
find_package(Git)
if(Git_FOUND)
execute_process(COMMAND
- "${GIT_EXECUTABLE}" remote get-url origin
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
- RESULT_VARIABLE GIT_URL_STATUS
- OUTPUT_VARIABLE GIT_URL
- ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- execute_process(COMMAND
- "${GIT_EXECUTABLE}" rev-list --max-count=1 HEAD~..
- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ "${GIT_EXECUTABLE}" describe --always --tags --long
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
RESULT_VARIABLE GIT_REVISION_STATUS
OUTPUT_VARIABLE GIT_REVISION
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
+ set(GIT_REVISION_STATUS 1)
+ set(GIT_REVISION "")
+endif()
- if(GIT_URL_STATUS EQUAL 0 OR GIT_REVISION_STATUS EQUAL 0)
- set(SDL_REVISION "${GIT_URL}@${GIT_REVISION}")
+if(SDL_SOURCE_VERSION)
+ set(SDL_REVISION "SDL-${SDL_SOURCE_VERSION}")
+elseif(GIT_REVISION_STATUS EQUAL 0)
+ if(GIT_REVISION MATCHES "^[0-9a-f]+$")
+ # Just a truncated sha1, so prefix it with the version number
+ set(SDL_REVISION "SDL-${SDL_VERSION}-g${GIT_REVISION}")
else()
- set(SDL_REVISION "")
+ # e.g. release-2.24.0-542-g96361fc47
+ set(SDL_REVISION "SDL-${GIT_REVISION}")
endif()
else()
- set(SDL_REVISION "")
+ set(SDL_REVISION "SDL-${SDL_VERSION}-no-vcs")
endif()
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
diff --git a/Makefile.in b/Makefile.in
index 1dc78f6..1418a62 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -252,7 +252,7 @@ dist $(distfile):
-name '.#*' \) \
-exec rm -f {} \;
if test -f $(distdir)/test/Makefile; then (cd $(distdir)/test && make distclean); fi
- (cd $(distdir); build-scripts/updaterev.sh)
+ (cd $(distdir); $(srcdir)/build-scripts/updaterev.sh --dist)
tar cvf - $(distdir) | gzip --best >$(distfile)
rm -rf $(distdir)
diff --git a/build-scripts/showrev.sh b/build-scripts/showrev.sh
index 71be3fe..02cbbb0 100755
--- a/build-scripts/showrev.sh
+++ b/build-scripts/showrev.sh
@@ -5,10 +5,31 @@
SDL_ROOT=$(dirname $0)/..
cd $SDL_ROOT
+if [ -e ./VERSION ]; then
+ cat ./VERSION
+ exit 0
+fi
+
+major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
+minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
+micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
+version="${major}.${minor}.${micro}"
+
if [ -x "$(command -v git)" ]; then
- rev=$(echo "$(git remote get-url origin 2>/dev/null)@$(git rev-list HEAD~.. 2>/dev/null)")
- if [ "$rev" != "@" ]; then
- echo $rev
+ rev="$(git describe --tags --long 2>/dev/null)"
+ if [ -n "$rev" ]; then
+ # e.g. release-2.24.0-542-g96361fc47
+ # or release-2.24.1-5-g36b987dab
+ # or prerelease-2.23.2-0-gcb46e1b3f
+ echo "$rev"
+ exit 0
+ fi
+
+ rev="$(git describe --always --tags --long 2>/dev/null)"
+ if [ -n "$rev" ]; then
+ # Just a truncated sha1, e.g. 96361fc47.
+ # Turn it into e.g. 2.25.0-g96361fc47
+ echo "${version}-g${rev}"
exit 0
fi
fi
@@ -16,10 +37,12 @@ fi
if [ -x "$(command -v p4)" ]; then
rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')"
if [ $? = 0 ]; then
- echo $rev
+ # e.g. 2.25.0-p7511446
+ echo "${version}-p${rev}"
exit 0
fi
fi
-echo ""
-exit 1
+# best we can do
+echo "${version}-no-vcs"
+exit 0
diff --git a/build-scripts/updaterev.sh b/build-scripts/updaterev.sh
index eb20e80..a15784d 100755
--- a/build-scripts/updaterev.sh
+++ b/build-scripts/updaterev.sh
@@ -6,10 +6,28 @@ outdir=`pwd`
cd `dirname $0`
srcdir=..
header=$outdir/include/SDL_revision.h
+dist=
+
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ (--dist)
+ dist=yes
+ shift
+ ;;
+ (*)
+ echo "$0: Unknown option: $1" >&2
+ exit 2
+ ;;
+ esac
+done
rev=`sh showrev.sh 2>/dev/null`
if [ "$rev" != "" ]; then
- echo "#define SDL_REVISION \"$rev\"" >"$header.new"
+ if [ -n "$dist" ]; then
+ echo "$rev" > "$outdir/VERSION"
+ fi
+ echo "/* Generated by updaterev.sh, do not edit */" >"$header.new"
+ echo "#define SDL_REVISION \"SDL-$rev\"" >>"$header.new"
echo "#define SDL_REVISION_NUMBER 0" >>"$header.new"
if diff $header $header.new >/dev/null 2>&1; then
rm "$header.new"
diff --git a/configure b/configure
index 072eedb..88c80f7 100755
--- a/configure
+++ b/configure
@@ -32529,3 +32529,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
+
diff --git a/include/SDL_revision.h.cmake b/include/SDL_revision.h.cmake
index b27ec11..dc12088 100644
--- a/include/SDL_revision.h.cmake
+++ b/include/SDL_revision.h.cmake
@@ -1,6 +1,2 @@
-#cmakedefine SDL_REVISION "@SDL_REVISION@"
+#define SDL_REVISION "@SDL_REVISION@"
#define SDL_REVISION_NUMBER 0
-
-#ifndef SDL_REVISION
-#define SDL_REVISION ""
-#endif
diff --git a/test/configure b/test/configure
index f627d92..c71abe4 100755
--- a/test/configure
+++ b/test/configure
@@ -6103,3 +6103,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
+