Merge commit '2dc788cb9ffa83a2840e62f5ad2d0a7055cfcb19' into main

This commit is contained in:
Sam Lantinga 2022-10-23 16:35:07 -07:00
commit 8696350903
8 changed files with 73 additions and 26 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@ build
gen gen
Build Build
buildbot buildbot
/VERSION
*.so *.so
*.so.* *.so.*

View File

@ -2930,29 +2930,36 @@ listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
set(EXTRA_CFLAGS ${_EXTRA_CFLAGS}) set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
# Compat helpers for the configuration files # 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) find_package(Git)
if(Git_FOUND) if(Git_FOUND)
execute_process(COMMAND execute_process(COMMAND
"${GIT_EXECUTABLE}" remote get-url origin "${GIT_EXECUTABLE}" describe --always --tags --long
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" WORKING_DIRECTORY "${PROJECT_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}"
RESULT_VARIABLE GIT_REVISION_STATUS RESULT_VARIABLE GIT_REVISION_STATUS
OUTPUT_VARIABLE GIT_REVISION OUTPUT_VARIABLE GIT_REVISION
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) 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) if(SDL_SOURCE_VERSION)
set(SDL_REVISION "${GIT_URL}@${GIT_REVISION}") 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() else()
set(SDL_REVISION "") # e.g. release-2.24.0-542-g96361fc47
set(SDL_REVISION "SDL-${GIT_REVISION}")
endif() endif()
else() else()
set(SDL_REVISION "") set(SDL_REVISION "SDL-${SDL_VERSION}-no-vcs")
endif() endif()
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake" configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"

View File

@ -252,7 +252,7 @@ dist $(distfile):
-name '.#*' \) \ -name '.#*' \) \
-exec rm -f {} \; -exec rm -f {} \;
if test -f $(distdir)/test/Makefile; then (cd $(distdir)/test && make distclean); fi 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) tar cvf - $(distdir) | gzip --best >$(distfile)
rm -rf $(distdir) rm -rf $(distdir)

View File

@ -5,10 +5,31 @@
SDL_ROOT=$(dirname $0)/.. SDL_ROOT=$(dirname $0)/..
cd $SDL_ROOT 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 if [ -x "$(command -v git)" ]; then
rev=$(echo "$(git remote get-url origin 2>/dev/null)@$(git rev-list HEAD~.. 2>/dev/null)") rev="$(git describe --tags --long 2>/dev/null)"
if [ "$rev" != "@" ]; then if [ -n "$rev" ]; then
echo $rev # 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 exit 0
fi fi
fi fi
@ -16,10 +37,12 @@ fi
if [ -x "$(command -v p4)" ]; then if [ -x "$(command -v p4)" ]; then
rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')" rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')"
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo $rev # e.g. 2.25.0-p7511446
echo "${version}-p${rev}"
exit 0 exit 0
fi fi
fi fi
echo "" # best we can do
exit 1 echo "${version}-no-vcs"
exit 0

View File

@ -6,10 +6,28 @@ outdir=`pwd`
cd `dirname $0` cd `dirname $0`
srcdir=.. srcdir=..
header=$outdir/include/SDL_revision.h 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` rev=`sh showrev.sh 2>/dev/null`
if [ "$rev" != "" ]; then 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" echo "#define SDL_REVISION_NUMBER 0" >>"$header.new"
if diff $header $header.new >/dev/null 2>&1; then if diff $header $header.new >/dev/null 2>&1; then
rm "$header.new" rm "$header.new"

1
configure vendored
View File

@ -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;} printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi fi

View File

@ -1,6 +1,2 @@
#cmakedefine SDL_REVISION "@SDL_REVISION@" #define SDL_REVISION "@SDL_REVISION@"
#define SDL_REVISION_NUMBER 0 #define SDL_REVISION_NUMBER 0
#ifndef SDL_REVISION
#define SDL_REVISION ""
#endif

1
test/configure vendored
View File

@ -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;} printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi fi