diff options
Diffstat (limited to 'contrib/SDL-3.2.8/build-scripts/test-versioning.sh')
| -rwxr-xr-x | contrib/SDL-3.2.8/build-scripts/test-versioning.sh | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/build-scripts/test-versioning.sh b/contrib/SDL-3.2.8/build-scripts/test-versioning.sh new file mode 100755 index 0000000..55e29a3 --- /dev/null +++ b/contrib/SDL-3.2.8/build-scripts/test-versioning.sh | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright 2022 Collabora Ltd. | ||
| 3 | # SPDX-License-Identifier: Zlib | ||
| 4 | |||
| 5 | set -eu | ||
| 6 | |||
| 7 | cd `dirname $0`/.. | ||
| 8 | |||
| 9 | ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL3/SDL_version.h) | ||
| 10 | ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL3/SDL_version.h) | ||
| 11 | ref_micro=$(sed -ne 's/^#define SDL_MICRO_VERSION *//p' include/SDL3/SDL_version.h) | ||
| 12 | ref_version="${ref_major}.${ref_minor}.${ref_micro}" | ||
| 13 | |||
| 14 | tests=0 | ||
| 15 | failed=0 | ||
| 16 | |||
| 17 | ok () { | ||
| 18 | tests=$(( tests + 1 )) | ||
| 19 | echo "ok - $*" | ||
| 20 | } | ||
| 21 | |||
| 22 | not_ok () { | ||
| 23 | tests=$(( tests + 1 )) | ||
| 24 | echo "not ok - $*" | ||
| 25 | failed=1 | ||
| 26 | } | ||
| 27 | |||
| 28 | version=$(sed -Ene 's/^.* version ([0-9.]*)$/\1/p' include/SDL3/SDL.h) | ||
| 29 | |||
| 30 | if [ "$ref_version" = "$version" ]; then | ||
| 31 | ok "SDL.h $version" | ||
| 32 | else | ||
| 33 | not_ok "SDL.h $version disagrees with SDL_version.h $ref_version" | ||
| 34 | fi | ||
| 35 | |||
| 36 | version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C VERSION "([0-9.]*)"\)$/\1/p' CMakeLists.txt) | ||
| 37 | |||
| 38 | if [ "$ref_version" = "$version" ]; then | ||
| 39 | ok "CMakeLists.txt $version" | ||
| 40 | else | ||
| 41 | not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version" | ||
| 42 | fi | ||
| 43 | |||
| 44 | major=$(sed -ne 's/.*SDL_MAJOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java) | ||
| 45 | minor=$(sed -ne 's/.*SDL_MINOR_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java) | ||
| 46 | micro=$(sed -ne 's/.*SDL_MICRO_VERSION = \([0-9]*\);/\1/p' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java) | ||
| 47 | version="${major}.${minor}.${micro}" | ||
| 48 | |||
| 49 | if [ "$ref_version" = "$version" ]; then | ||
| 50 | ok "SDLActivity.java $version" | ||
| 51 | else | ||
| 52 | not_ok "android-project/app/src/main/java/org/libsdl/app/SDLActivity.java $version disagrees with SDL_version.h $ref_version" | ||
| 53 | fi | ||
| 54 | |||
| 55 | tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/core/windows/version.rc | tr -d '\r') | ||
| 56 | ref_tuple="${ref_major},${ref_minor},${ref_micro},0" | ||
| 57 | |||
| 58 | if [ "$ref_tuple" = "$tuple" ]; then | ||
| 59 | ok "version.rc FILEVERSION $tuple" | ||
| 60 | else | ||
| 61 | not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple" | ||
| 62 | fi | ||
| 63 | |||
| 64 | tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/core/windows/version.rc | tr -d '\r') | ||
| 65 | |||
| 66 | if [ "$ref_tuple" = "$tuple" ]; then | ||
| 67 | ok "version.rc PRODUCTVERSION $tuple" | ||
| 68 | else | ||
| 69 | not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple" | ||
| 70 | fi | ||
| 71 | |||
| 72 | tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r') | ||
| 73 | ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0" | ||
| 74 | |||
| 75 | if [ "$ref_tuple" = "$tuple" ]; then | ||
| 76 | ok "version.rc FileVersion $tuple" | ||
| 77 | else | ||
| 78 | not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple" | ||
| 79 | fi | ||
| 80 | |||
| 81 | tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/core/windows/version.rc | tr -d '\r') | ||
| 82 | |||
| 83 | if [ "$ref_tuple" = "$tuple" ]; then | ||
| 84 | ok "version.rc ProductVersion $tuple" | ||
| 85 | else | ||
| 86 | not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple" | ||
| 87 | fi | ||
| 88 | |||
| 89 | version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist) | ||
| 90 | |||
| 91 | if [ "$ref_version" = "$version" ]; then | ||
| 92 | ok "Info-Framework.plist CFBundleShortVersionString $version" | ||
| 93 | else | ||
| 94 | not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_version.h $ref_version" | ||
| 95 | fi | ||
| 96 | |||
| 97 | version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist) | ||
| 98 | |||
| 99 | if [ "$ref_version" = "$version" ]; then | ||
| 100 | ok "Info-Framework.plist CFBundleVersion $version" | ||
| 101 | else | ||
| 102 | not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version" | ||
| 103 | fi | ||
| 104 | |||
| 105 | version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info) | ||
| 106 | |||
| 107 | if [ "$ref_version" = "$version" ]; then | ||
| 108 | ok "SDL.info Title $version" | ||
| 109 | else | ||
| 110 | not_ok "SDL.info Title $version disagrees with SDL_version.h $ref_version" | ||
| 111 | fi | ||
| 112 | |||
| 113 | marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) | ||
| 114 | |||
| 115 | ref="$ref_version | ||
| 116 | $ref_version" | ||
| 117 | |||
| 118 | if [ "$ref" = "$marketing" ]; then | ||
| 119 | ok "project.pbxproj MARKETING_VERSION is consistent" | ||
| 120 | else | ||
| 121 | not_ok "project.pbxproj MARKETING_VERSION is inconsistent, expected $ref, got $marketing" | ||
| 122 | fi | ||
| 123 | |||
| 124 | # For simplicity this assumes we'll never break ABI before SDL 3. | ||
| 125 | dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) | ||
| 126 | |||
| 127 | case "$ref_minor" in | ||
| 128 | (*[02468]) | ||
| 129 | major="$(( ref_minor * 100 + 1 ))" | ||
| 130 | minor="0" | ||
| 131 | ;; | ||
| 132 | (*) | ||
| 133 | major="$(( ref_minor * 100 + ref_micro + 1 ))" | ||
| 134 | minor="0" | ||
| 135 | ;; | ||
| 136 | esac | ||
| 137 | |||
| 138 | ref="${major}.${minor}.0 | ||
| 139 | ${major}.${minor}.0" | ||
| 140 | |||
| 141 | if [ "$ref" = "$dylib_compat" ]; then | ||
| 142 | ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent" | ||
| 143 | else | ||
| 144 | not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat" | ||
| 145 | fi | ||
| 146 | |||
| 147 | dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) | ||
| 148 | |||
| 149 | case "$ref_minor" in | ||
| 150 | (*[02468]) | ||
| 151 | major="$(( ref_minor * 100 + 1 ))" | ||
| 152 | minor="$ref_micro" | ||
| 153 | ;; | ||
| 154 | (*) | ||
| 155 | major="$(( ref_minor * 100 + ref_micro + 1 ))" | ||
| 156 | minor="0" | ||
| 157 | ;; | ||
| 158 | esac | ||
| 159 | |||
| 160 | ref="${major}.${minor}.0 | ||
| 161 | ${major}.${minor}.0" | ||
| 162 | |||
| 163 | if [ "$ref" = "$dylib_cur" ]; then | ||
| 164 | ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent" | ||
| 165 | else | ||
| 166 | not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur" | ||
| 167 | fi | ||
| 168 | |||
| 169 | echo "1..$tests" | ||
| 170 | exit "$failed" | ||
