test-versioning.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/bin/sh
  2. # Copyright 2022 Collabora Ltd.
  3. # SPDX-License-Identifier: Zlib
  4. set -eu
  5. ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
  6. ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
  7. ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
  8. ref_version="${ref_major}.${ref_minor}.${ref_micro}"
  9. tests=0
  10. failed=0
  11. ok () {
  12. tests=$(( tests + 1 ))
  13. echo "ok - $*"
  14. }
  15. not_ok () {
  16. tests=$(( tests + 1 ))
  17. echo "not ok - $*"
  18. failed=1
  19. }
  20. major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure.ac)
  21. minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure.ac)
  22. micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure.ac)
  23. version="${major}.${minor}.${micro}"
  24. if [ "$ref_version" = "$version" ]; then
  25. ok "configure.ac $version"
  26. else
  27. not_ok "configure.ac $version disagrees with SDL_version.h $ref_version"
  28. fi
  29. major=$(sed -ne 's/^SDL_MAJOR_VERSION=//p' configure)
  30. minor=$(sed -ne 's/^SDL_MINOR_VERSION=//p' configure)
  31. micro=$(sed -ne 's/^SDL_MICRO_VERSION=//p' configure)
  32. version="${major}.${minor}.${micro}"
  33. if [ "$ref_version" = "$version" ]; then
  34. ok "configure $version"
  35. else
  36. not_ok "configure $version disagrees with SDL_version.h $ref_version"
  37. fi
  38. major=$(sed -ne 's/^set(SDL_MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
  39. minor=$(sed -ne 's/^set(SDL_MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
  40. micro=$(sed -ne 's/^set(SDL_MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
  41. version="${major}.${minor}.${micro}"
  42. if [ "$ref_version" = "$version" ]; then
  43. ok "CMakeLists.txt $version"
  44. else
  45. not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version"
  46. fi
  47. major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.os2)
  48. minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.os2)
  49. micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.os2)
  50. version="${major}.${minor}.${micro}"
  51. if [ "$ref_version" = "$version" ]; then
  52. ok "Makefile.os2 $version"
  53. else
  54. not_ok "Makefile.os2 $version disagrees with SDL_version.h $ref_version"
  55. fi
  56. major=$(sed -ne 's/^MAJOR_VERSION *= *//p' Makefile.w32)
  57. minor=$(sed -ne 's/^MINOR_VERSION *= *//p' Makefile.w32)
  58. micro=$(sed -ne 's/^MICRO_VERSION *= *//p' Makefile.w32)
  59. version="${major}.${minor}.${micro}"
  60. if [ "$ref_version" = "$version" ]; then
  61. ok "Makefile.w32 $version"
  62. else
  63. not_ok "Makefile.w32 $version disagrees with SDL_version.h $ref_version"
  64. fi
  65. tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/main/windows/version.rc | tr -d '\r')
  66. ref_tuple="${ref_major},${ref_minor},${ref_micro},0"
  67. if [ "$ref_tuple" = "$tuple" ]; then
  68. ok "version.rc FILEVERSION $tuple"
  69. else
  70. not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple"
  71. fi
  72. tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/main/windows/version.rc | tr -d '\r')
  73. if [ "$ref_tuple" = "$tuple" ]; then
  74. ok "version.rc PRODUCTVERSION $tuple"
  75. else
  76. not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
  77. fi
  78. tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
  79. ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"
  80. if [ "$ref_tuple" = "$tuple" ]; then
  81. ok "version.rc FileVersion $tuple"
  82. else
  83. not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple"
  84. fi
  85. tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/main/windows/version.rc | tr -d '\r')
  86. if [ "$ref_tuple" = "$tuple" ]; then
  87. ok "version.rc ProductVersion $tuple"
  88. else
  89. not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
  90. fi
  91. version=$(sed -Ene '/CFBundleShortVersionString/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
  92. if [ "$ref_version" = "$version" ]; then
  93. ok "Info-Framework.plist CFBundleShortVersionString $version"
  94. else
  95. not_ok "Info-Framework.plist CFBundleShortVersionString $version disagrees with SDL_version.h $ref_version"
  96. fi
  97. version=$(sed -Ene '/CFBundleVersion/,+1 s/.*<string>(.*)<\/string>.*/\1/p' Xcode/SDL/Info-Framework.plist)
  98. if [ "$ref_version" = "$version" ]; then
  99. ok "Info-Framework.plist CFBundleVersion $version"
  100. else
  101. not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
  102. fi
  103. # For simplicity this assumes we'll never break ABI before SDL 3.
  104. dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
  105. case "$ref_minor" in
  106. (*[02468])
  107. major="$(( ref_minor * 100 + 1 ))"
  108. minor="0"
  109. ;;
  110. (*)
  111. major="$(( ref_minor * 100 + ref_micro + 1 ))"
  112. minor="0"
  113. ;;
  114. esac
  115. ref="${major}.${minor}.0
  116. ${major}.${minor}.0"
  117. if [ "$ref" = "$dylib_compat" ]; then
  118. ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is consistent"
  119. else
  120. not_ok "project.pbxproj DYLIB_COMPATIBILITY_VERSION is inconsistent, expected $ref, got $dylib_compat"
  121. fi
  122. dylib_cur=$(sed -Ene 's/.*DYLIB_CURRENT_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
  123. case "$ref_minor" in
  124. (*[02468])
  125. major="$(( ref_minor * 100 + 1 ))"
  126. minor="$ref_micro"
  127. ;;
  128. (*)
  129. major="$(( ref_minor * 100 + ref_micro + 1 ))"
  130. minor="0"
  131. ;;
  132. esac
  133. ref="${major}.${minor}.0
  134. ${major}.${minor}.0"
  135. if [ "$ref" = "$dylib_cur" ]; then
  136. ok "project.pbxproj DYLIB_CURRENT_VERSION is consistent"
  137. else
  138. not_ok "project.pbxproj DYLIB_CURRENT_VERSION is inconsistent, expected $ref, got $dylib_cur"
  139. fi
  140. echo "1..$tests"
  141. exit "$failed"