upgrade.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # Copyright (c) 2012-2026 Daniele Bartolini et al.
  4. set -eu
  5. git_clone () {
  6. local DEST=$1
  7. local REPO=$2
  8. local BRANCH=$3
  9. local COMMIT=${4-}
  10. local DEPTH=1
  11. if [ ! -z "${COMMIT}" ]; then
  12. DEPTH=250 # Ensure enough commits are available for COMMIT option to work.
  13. fi
  14. git clone "${REPO}" "${DEST}" --branch="${BRANCH}" --depth="${DEPTH}" --separate-git-dir="$(mktemp -u)"
  15. if [ ! -z "${COMMIT}" ]; then
  16. pushd "${PWD}" > /dev/null
  17. cd "${DEST}" \
  18. && git reset --hard "${COMMIT}" \
  19. && rm .git
  20. popd > /dev/null
  21. fi
  22. }
  23. update_luajit () {
  24. local DEST=3rdparty/luajit
  25. local REPO=https://github.com/LuaJIT/LuaJIT.git
  26. local BRANCH=v2.1
  27. # Download latest luajit.
  28. rm -rf "${DEST}"
  29. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  30. # Cleanup.
  31. rm -rf "${DEST}"/.gitignore
  32. rm -rf "${DEST}"/doc
  33. rm -rf "${DEST:?}"/etc
  34. rm -rf "${DEST}"/Makefile
  35. rm -rf "${DEST}"/README
  36. # Bump affected resources versions.
  37. RESOURCE_TYPES_H=src/resource/types.h
  38. sed -Ei 's/(.*RESOURCE_VERSION_SCRIPT)(.*RESOURCE_VERSION\()([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' src/resource/types.h
  39. # Add changes and commit.
  40. git add -f "${DEST}"
  41. git add "${RESOURCE_TYPES_H}"
  42. git commit -m "3rdparty: update luajit"
  43. }
  44. update_bx () {
  45. local DEST=3rdparty/bx
  46. local REPO=https://github.com/bkaradzic/bx
  47. local BRANCH=master
  48. # Download latest bx.
  49. rm -rf "${DEST}"
  50. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  51. # Cleanup bx.
  52. rm -rf "${DEST}"/.appveyor.yml
  53. rm -rf "${DEST}"/.editorconfig
  54. rm -rf "${DEST}"/.gitattributes
  55. rm -rf "${DEST}"/.gitignore
  56. rm -rf "${DEST}"/.travis.yml
  57. rm -rf "${DEST}"/3rdparty/catch
  58. rm -rf "${DEST}"/makefile
  59. rm -rf "${DEST}"/README.md
  60. rm -rf "${DEST}"/scripts/bin2c.lua
  61. rm -rf "${DEST}"/scripts/lemon.lua
  62. rm -rf "${DEST}"/tests
  63. rm -rf "${DEST}"/tools
  64. # Ensure BX_CONFIG_DEBUG is set in development builds.
  65. sed -i 's/{ "Release" }$/{ "Release or development" }/' "${DEST}"/scripts/bx.lua
  66. sed -i 's/{ "Release" }$/{ "Release or development" }/' "${DEST}"/scripts/bx.lua
  67. git add -f "${DEST}"
  68. }
  69. update_bimg () {
  70. local DEST=3rdparty/bimg
  71. local REPO=https://github.com/bkaradzic/bimg
  72. local BRANCH=master
  73. # Download latest bimg.
  74. rm -rf "${DEST}"
  75. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  76. # Cleanup bimg.
  77. rm -rf "${DEST}"/.appveyor.yml
  78. rm -rf "${DEST}"/.editorconfig
  79. rm -rf "${DEST}"/.gitattributes
  80. rm -rf "${DEST}"/.gitignore
  81. rm -rf "${DEST}"/.travis.yml
  82. rm -rf "${DEST}"/makefile
  83. rm -rf "${DEST}"/README.md
  84. git add -f "${DEST}"
  85. }
  86. update_bgfx () {
  87. local DEST=3rdparty/bgfx
  88. local REPO=https://github.com/bkaradzic/bgfx
  89. local BRANCH=master
  90. # Update bgfx's dependencies.
  91. update_bx
  92. update_bimg
  93. # Download latest bgfx.
  94. rm -rf "${DEST}"
  95. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  96. # Regenerate samples/core/shaders/common.shader.
  97. COMMON_SHADER=samples/core/shaders/common.shader
  98. rm "${COMMON_SHADER}"
  99. {
  100. echo "render_states = {"
  101. echo " default = {"
  102. echo " states = {"
  103. echo " rgb_write_enable = true"
  104. echo " alpha_write_enable = true"
  105. echo " depth_write_enable = true"
  106. echo " depth_enable = true"
  107. echo " blend_enable = false"
  108. echo " depth_func = \"lequal\""
  109. echo " blend_src = \"src_alpha\""
  110. echo " blend_dst = \"inv_src_alpha\""
  111. echo " blend_equation = \"add\""
  112. echo " cull_mode = \"cw\""
  113. echo " primitive_type = \"pt_triangles\""
  114. echo " }"
  115. echo " }"
  116. echo ""
  117. echo " opacity = {"
  118. echo " inherit = \"default\""
  119. echo " states = {"
  120. echo " cull_mode = \"none\""
  121. echo " depth_write_enable = false"
  122. echo " depth_enable = false"
  123. echo " blend_enable = true"
  124. echo " blend_src = \"src_alpha\""
  125. echo " blend_dst = \"inv_src_alpha\""
  126. echo " \"defined(DEPTH_ENABLED)\" = {"
  127. echo " depth_enable = true"
  128. echo " }"
  129. echo " }"
  130. echo " }"
  131. echo ""
  132. echo "}"
  133. echo ""
  134. echo "sampler_states = {"
  135. echo " clamp_point = {"
  136. echo " wrap_u = \"clamp\""
  137. echo " wrap_v = \"clamp\""
  138. echo " wrap_w = \"clamp\""
  139. echo " filter_min = \"point\""
  140. echo " filter_mag = \"point\""
  141. echo " }"
  142. echo ""
  143. echo " clamp_anisotropic = {"
  144. echo " wrap_u = \"clamp\""
  145. echo " wrap_v = \"clamp\""
  146. echo " wrap_w = \"clamp\""
  147. echo " filter_min = \"anisotropic\""
  148. echo " filter_mag = \"anisotropic\""
  149. echo " }"
  150. echo ""
  151. echo " mirror_point = {"
  152. echo " wrap_u = \"mirror\""
  153. echo " wrap_v = \"mirror\""
  154. echo " wrap_w = \"mirror\""
  155. echo " filter_min = \"point\""
  156. echo " filter_mag = \"point\""
  157. echo " }"
  158. echo ""
  159. echo " mirror_anisotropic = {"
  160. echo " wrap_u = \"mirror\""
  161. echo " wrap_v = \"mirror\""
  162. echo " wrap_w = \"mirror\""
  163. echo " filter_min = \"anisotropic\""
  164. echo " filter_mag = \"anisotropic\""
  165. echo " }"
  166. echo "}"
  167. echo ""
  168. echo "bgfx_shaders = {"
  169. echo " common = {"
  170. echo " code = \"\"\""
  171. sed 's/^/\t\t\t/' "${DEST}"/src/bgfx_shader.sh "${DEST}"/examples/common/shaderlib.sh
  172. echo " \"\"\""
  173. echo " }"
  174. echo "}"
  175. } >> "${COMMON_SHADER}"
  176. # Remove trailing tabs.
  177. sed -i 's/\t*$//' "${COMMON_SHADER}"
  178. # Cleanup bgfx.
  179. rm -rf "${DEST}"/.appveyor.yml
  180. rm -rf "${DEST}"/.editorconfig
  181. rm -rf "${DEST}"/.gitattributes
  182. rm -rf "${DEST}"/.github
  183. rm -rf "${DEST}"/.gitignore
  184. rm -rf "${DEST}"/.travis.yml
  185. rm -rf "${DEST}"/3rdparty/.editorconfig
  186. rm -rf "${DEST}"/3rdparty/cgltf
  187. rm -rf "${DEST}"/3rdparty/dear-imgui
  188. rm -rf "${DEST}"/3rdparty/freetype
  189. rm -rf "${DEST}"/3rdparty/glslang/build
  190. rm -rf "${DEST}"/3rdparty/glslang/build_info.py
  191. rm -rf "${DEST}"/3rdparty/glslang/license-checker.cfg
  192. rm -rf "${DEST}"/3rdparty/iconfontheaders
  193. rm -rf "${DEST}"/3rdparty/meshoptimizer
  194. rm -rf "${DEST}"/3rdparty/sdf
  195. rm -rf "${DEST}"/3rdparty/stb
  196. rm -rf "${DEST}"/bindings
  197. rm -rf "${DEST}"/CODEOWNERS
  198. rm -rf "${DEST}"/CONTRIBUTING.md
  199. rm -rf "${DEST}"/examples
  200. rm -rf "${DEST}"/makefile
  201. rm -rf "${DEST}"/README.md
  202. rm -rf "${DEST}"/scripts/bgfx-codegen.lua
  203. rm -rf "${DEST}"/scripts/bgfx.doxygen
  204. rm -rf "${DEST}"/scripts/bgfx.idl
  205. rm -rf "${DEST}"/scripts/bindings-*.lua
  206. rm -rf "${DEST}"/scripts/build.ninja
  207. rm -rf "${DEST}"/scripts/codegen.lua
  208. rm -rf "${DEST}"/scripts/doxygen.lua
  209. rm -rf "${DEST}"/scripts/geometryc.lua
  210. rm -rf "${DEST}"/scripts/geometryv.lua
  211. rm -rf "${DEST}"/scripts/idl.lua
  212. rm -rf "${DEST}"/scripts/shader-embeded.mk
  213. rm -rf "${DEST}"/scripts/shader.mk
  214. rm -rf "${DEST}"/scripts/temp.bgfx.h
  215. rm -rf "${DEST}"/scripts/temp.bgfx.idl.inl
  216. rm -rf "${DEST}"/scripts/temp.defines.h
  217. rm -rf "${DEST}"/scripts/texturev.lua
  218. rm -rf "${DEST}"/scripts/tools.mk
  219. rm -rf "${DEST}"/src/bgfx_compute.sh
  220. rm -rf "${DEST}"/src/bgfx_shader.sh
  221. rm -rf "${DEST}"/src/fs_clear0.sc
  222. rm -rf "${DEST}"/src/fs_clear1.sc
  223. rm -rf "${DEST}"/src/fs_clear2.sc
  224. rm -rf "${DEST}"/src/fs_clear3.sc
  225. rm -rf "${DEST}"/src/fs_clear4.sc
  226. rm -rf "${DEST}"/src/fs_clear5.sc
  227. rm -rf "${DEST}"/src/fs_clear6.sc
  228. rm -rf "${DEST}"/src/fs_clear7.sc
  229. rm -rf "${DEST}"/src/fs_debugfont.sc
  230. rm -rf "${DEST}"/src/makefile
  231. rm -rf "${DEST}"/src/varying.def.sc
  232. rm -rf "${DEST}"/src/vs_clear.sc
  233. rm -rf "${DEST}"/src/vs_debugfont.sc
  234. rm -rf "${DEST}"/tools/geometryc
  235. rm -rf "${DEST}"/tools/geometryv
  236. rm -rf "${DEST}"/tools/texturev
  237. rm -rf "${DEST}"/tools/bin
  238. rm -rf "${DEST}"/docs
  239. sed -i '/dofile \"texturev.lua\"/d' "${DEST}"/scripts/genie.lua
  240. sed -i '/dofile \"geometryc.lua\"/d' "${DEST}"/scripts/genie.lua
  241. sed -i '/dofile \"geometryv.lua\"/d' "${DEST}"/scripts/genie.lua
  242. # Bump affected resources versions.
  243. RESOURCE_TYPES_H=src/resource/types.h
  244. sed -Ei 's/(.*RESOURCE_VERSION_TEXTURE)(.*RESOURCE_VERSION\()([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' src/resource/types.h
  245. sed -Ei 's/(.*RESOURCE_VERSION_SHADER)(.*RESOURCE_VERSION\()([0-9]+)(.*)/echo "\1\2$((\3 + 1))\4"/ge' src/resource/types.h
  246. # Add changes and commit.
  247. git add -f "${DEST}"
  248. git add "${COMMON_SHADER}"
  249. git add "${RESOURCE_TYPES_H}"
  250. git commit -m "3rdparty: update bx, bimg and bgfx"
  251. }
  252. update_bullet () {
  253. local DEST=3rdparty/bullet3
  254. local REPO=https://github.com/bulletphysics/bullet3
  255. local BRANCH=master
  256. # Download latest bullet3.
  257. rm -rf "${DEST}"
  258. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  259. # Cleanup.
  260. rm -rf "${DEST}"/.ci
  261. rm -rf "${DEST}"/.github
  262. rm -rf "${DEST}"/.gitignore
  263. rm -rf "${DEST}"/.style.yapf
  264. rm -rf "${DEST}"/.travis.yml
  265. rm -rf "${DEST}"/_clang-format
  266. rm -rf "${DEST}"/appveyor.yml
  267. rm -rf "${DEST}"/AUTHORS.txt
  268. rm -rf "${DEST}"/build3
  269. rm -rf "${DEST}"/build_cmake_pybullet_double.sh
  270. rm -rf "${DEST}"/build_visual_studio_vr_pybullet_double.bat
  271. rm -rf "${DEST}"/build_visual_studio_vr_pybullet_double_cmake.bat
  272. rm -rf "${DEST}"/build_visual_studio_vr_pybullet_double_dynamic.bat
  273. rm -rf "${DEST}"/build_visual_studio_without_pybullet_vr.bat
  274. rm -rf "${DEST}"/bullet.pc.cmake
  275. rm -rf "${DEST}"/BulletConfig.cmake.in
  276. rm -rf "${DEST}"/clang-format-all.sh
  277. rm -rf "${DEST}"/CMakeLists.txt
  278. rm -rf "${DEST}"/data
  279. rm -rf "${DEST}"/docs
  280. rm -rf "${DEST}"/Doxyfile
  281. rm -rf "${DEST}"/examples
  282. rm -rf "${DEST}"/Extras
  283. rm -rf "${DEST}"/MANIFEST.in
  284. rm -rf "${DEST}"/README.md
  285. rm -rf "${DEST}"/setup.py
  286. rm -rf "${DEST}"/src/*.cpp
  287. rm -rf "${DEST}"/src/*.h
  288. rm -rf "${DEST}"/src/.DS_Store
  289. rm -rf "${DEST}"/src/Bullet3Collision/
  290. rm -rf "${DEST}"/src/Bullet3Common
  291. rm -rf "${DEST}"/src/Bullet3Dynamics
  292. rm -rf "${DEST}"/src/Bullet3Geometry
  293. rm -rf "${DEST}"/src/Bullet3OpenCL
  294. rm -rf "${DEST}"/src/Bullet3Serialize
  295. rm -rf "${DEST}"/src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp
  296. rm -rf "${DEST}"/src/BulletCollision/Gimpact
  297. rm -rf "${DEST}"/src/BulletInverseDynamics
  298. rm -rf "${DEST}"/src/clew
  299. rm -rf "${DEST}"/test
  300. rm -rf "${DEST}"/UseBullet.cmake
  301. rm -rf "${DEST}"/VERSION
  302. rm -rf "${DEST}"/xcode.command
  303. find "${DEST}" -type f -name 'CMakeLists.txt' -exec rm {} +
  304. find "${DEST}" -type f -name 'premake4.lua' -exec rm {} +
  305. # Add changes and commit.
  306. git add -f "${DEST}"
  307. git commit -m "3rdparty: update bullet3"
  308. }
  309. update_openal () {
  310. local DEST=3rdparty/openal
  311. local REPO=https://github.com/kcat/openal-soft
  312. local BRANCH=master
  313. # Backup generated headers.
  314. cp "${DEST}"/config.h /tmp/config.h
  315. cp "${DEST}"/version.h /tmp/version.h
  316. cp "${DEST}"/bsinc_inc.h /tmp/bsinc_inc.h
  317. # Download latest sources.
  318. rm -rf "${DEST}"
  319. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  320. # Cleanup.
  321. rm -rf "${DEST}"/.gitignore
  322. rm -rf "${DEST}"/.travis.yml
  323. rm -rf "${DEST}"/CMakeLists.txt
  324. rm -rf "${DEST}"/README.md
  325. rm -rf "${DEST}"/XCompile-Android.txt
  326. rm -rf "${DEST}"/XCompile.txt
  327. rm -rf "${DEST}"/alsoftrc.sample
  328. rm -rf "${DEST}"/appveyor.yml
  329. rm -rf "${DEST}"/build/.empty
  330. rm -rf "${DEST}"/cmake/FindALSA.cmake
  331. rm -rf "${DEST}"/cmake/FindAudioIO.cmake
  332. rm -rf "${DEST}"/cmake/FindDSound.cmake
  333. rm -rf "${DEST}"/cmake/FindFFmpeg.cmake
  334. rm -rf "${DEST}"/cmake/FindJACK.cmake
  335. rm -rf "${DEST}"/cmake/FindMySOFA.cmake
  336. rm -rf "${DEST}"/cmake/FindOSS.cmake
  337. rm -rf "${DEST}"/cmake/FindOpenSL.cmake
  338. rm -rf "${DEST}"/cmake/FindPortAudio.cmake
  339. rm -rf "${DEST}"/cmake/FindPulseAudio.cmake
  340. rm -rf "${DEST}"/cmake/FindQSA.cmake
  341. rm -rf "${DEST}"/cmake/FindSDL2.cmake
  342. rm -rf "${DEST}"/cmake/FindSDL_sound.cmake
  343. rm -rf "${DEST}"/cmake/FindSoundIO.cmake
  344. rm -rf "${DEST}"/cmake/FindWindowsSDK.cmake
  345. rm -rf "${DEST}"/config.h.in
  346. rm -rf "${DEST}"/docs/3D7.1.txt
  347. rm -rf "${DEST}"/docs/ambdec.txt
  348. rm -rf "${DEST}"/docs/ambisonics.txt
  349. rm -rf "${DEST}"/docs/env-vars.txt
  350. rm -rf "${DEST}"/docs/hrtf.txt
  351. rm -rf "${DEST}"/examples/alffplay.cpp
  352. rm -rf "${DEST}"/examples/alhrtf.c
  353. rm -rf "${DEST}"/examples/allatency.c
  354. rm -rf "${DEST}"/examples/alloopback.c
  355. rm -rf "${DEST}"/examples/almultireverb.c
  356. rm -rf "${DEST}"/examples/alplay.c
  357. rm -rf "${DEST}"/examples/alrecord.c
  358. rm -rf "${DEST}"/examples/alreverb.c
  359. rm -rf "${DEST}"/examples/alstream.c
  360. rm -rf "${DEST}"/examples/altonegen.c
  361. rm -rf "${DEST}"/examples/common/alhelpers.c
  362. rm -rf "${DEST}"/examples/common/alhelpers.h
  363. rm -rf "${DEST}"/native-tools/CMakeLists.txt
  364. rm -rf "${DEST}"/native-tools/bin2h.c
  365. rm -rf "${DEST}"/native-tools/bsincgen.c
  366. rm -rf "${DEST}"/openal.pc.in
  367. rm -rf "${DEST}"/resources/openal32.rc
  368. rm -rf "${DEST}"/resources/resource.h
  369. rm -rf "${DEST}"/resources/router.rc
  370. rm -rf "${DEST}"/resources/soft_oal.rc
  371. rm -rf "${DEST}"/router/al.cpp
  372. rm -rf "${DEST}"/router/alc.cpp
  373. rm -rf "${DEST}"/router/router.cpp
  374. rm -rf "${DEST}"/router/router.h
  375. rm -rf "${DEST}"/utils/CIAIR.def
  376. rm -rf "${DEST}"/utils/IRC_1005.def
  377. rm -rf "${DEST}"/utils/MIT_KEMAR.def
  378. rm -rf "${DEST}"/utils/MIT_KEMAR_sofa.def
  379. rm -rf "${DEST}"/utils/SCUT_KEMAR.def
  380. rm -rf "${DEST}"/utils/alsoft-config/CMakeLists.txt
  381. rm -rf "${DEST}"/utils/alsoft-config/main.cpp
  382. rm -rf "${DEST}"/utils/alsoft-config/mainwindow.cpp
  383. rm -rf "${DEST}"/utils/alsoft-config/mainwindow.h
  384. rm -rf "${DEST}"/utils/alsoft-config/mainwindow.ui
  385. rm -rf "${DEST}"/utils/alsoft-config/verstr.cpp
  386. rm -rf "${DEST}"/utils/alsoft-config/verstr.h
  387. rm -rf "${DEST}"/utils/getopt.c
  388. rm -rf "${DEST}"/utils/getopt.h
  389. rm -rf "${DEST}"/utils/makemhr/loaddef.cpp
  390. rm -rf "${DEST}"/utils/makemhr/loaddef.h
  391. rm -rf "${DEST}"/utils/makemhr/loadsofa.cpp
  392. rm -rf "${DEST}"/utils/makemhr/loadsofa.h
  393. rm -rf "${DEST}"/utils/makemhr/makemhr.cpp
  394. rm -rf "${DEST}"/utils/makemhr/makemhr.h
  395. rm -rf "${DEST}"/utils/openal-info.c
  396. rm -rf "${DEST}"/utils/sofa-info.cpp
  397. rm -rf "${DEST}"/version.cmake
  398. rm -rf "${DEST}"/version.h.in
  399. rm -rf "${DEST}"/.github
  400. # Restore generated sources.
  401. cp /tmp/config.h "${DEST}"/config.h
  402. cp /tmp/version.h "${DEST}"/version.h
  403. cp /tmp/bsinc_inc.h "${DEST}"/bsinc_inc.h
  404. # Add changes and commit.
  405. git add -f "${DEST}"
  406. git commit -m "3rdparty: update openal"
  407. echo ""
  408. echo "!!! Remember to update ALSOFT_VERSION !!!"
  409. }
  410. update_sphinx_rtd_theme () {
  411. local REPO=https://github.com/readthedocs/sphinx_rtd_theme
  412. local DEST=docs/_themes/sphinx_rtd_theme
  413. local BRANCH=master
  414. local RTD_THEME=$(mktemp -d)
  415. # Download latest sphinx_rtd_theme.
  416. git_clone "${RTD_THEME}" "${REPO}" "${BRANCH}"
  417. rm -rf "${DEST}"
  418. mv "${RTD_THEME}"/sphinx_rtd_theme "${DEST}"
  419. # Add changes and commit.
  420. git add -f "${DEST}"
  421. git commit -m "docs: update sphinx_rtd_theme"
  422. }
  423. update_sphinx_sitemap () {
  424. local REPO=https://github.com/jdillard/sphinx-sitemap
  425. local DEST=docs/_extensions/sphinx_sitemap
  426. local BRANCH=master
  427. local SITEMAP=$(mktemp -d)
  428. # Download latest sphinx_rtd_theme.
  429. git_clone "${SITEMAP}" "${REPO}" "${BRANCH}"
  430. rm -rf "${DEST}"
  431. mv "${SITEMAP}"/sphinx_sitemap "${DEST}"
  432. # Add changes and commit.
  433. git add -f "${DEST}"
  434. git commit -m "docs: update sphinx-sitemap"
  435. }
  436. update_sphinx_lubg () {
  437. local REPO=https://github.com/mgeier/sphinx-last-updated-by-git/
  438. local DEST=docs/_extensions/sphinx_last_updated_by_git.py
  439. local BRANCH=master
  440. local LUBG=$(mktemp -d)
  441. # Download latest sphinx_rtd_theme.
  442. git_clone "${LUBG}" "${REPO}" "${BRANCH}"
  443. rm -rf "${DEST}"
  444. mv "${LUBG}"/src/sphinx_last_updated_by_git.py "${DEST}"
  445. # Add changes and commit.
  446. git add -f "${DEST}"
  447. git commit -m "docs: update sphinx-last-updated-by-git"
  448. }
  449. update_sphinx_opengraph () {
  450. local REPO=https://github.com/sphinx-doc/sphinxext-opengraph
  451. local DEST=docs/_extensions/sphinxext/opengraph
  452. local BRANCH=master
  453. local OPENGRAPH=$(mktemp -d)
  454. # Download latest sphinx_rtd_theme.
  455. git_clone "${OPENGRAPH}" "${REPO}" "${BRANCH}"
  456. rm -rf "${DEST}"
  457. mv "${OPENGRAPH}"/sphinxext/opengraph "${DEST}"
  458. # Add changes and commit.
  459. git add -f "${DEST}"
  460. git commit -m "docs: update sphinxext-opengraph"
  461. }
  462. update_gtk_theme () {
  463. local REPO=https://gitlab.gnome.org/GNOME/gtk.git
  464. local DEST=tools/level_editor/resources/theme/Adwaita
  465. local BRANCH=gtk-3-24
  466. local GTK_THEME=$(mktemp -d)
  467. # Download latest sphinx_rtd_theme.
  468. git_clone "${GTK_THEME}" "${REPO}" "${BRANCH}"
  469. rm -rf "${DEST}"
  470. mv "${GTK_THEME}"/gtk/theme/Adwaita "${DEST}"
  471. sed -i 's/resource:\/\/\/org\/gtk\/libgtk\/theme\/Adwaita\/gtk-contained.css/resource:\/\/\/org\/crown\/level_editor\/theme\/Adwaita\/gtk-contained.css/' "${DEST}"/gtk.css
  472. sed -i 's/resource:\/\/\/org\/gtk\/libgtk\/theme\/Adwaita\/gtk-contained-dark.css/resource:\/\/\/org\/crown\/level_editor\/theme\/Adwaita\/gtk-contained-dark.css/' "${DEST}"/gtk-dark.css
  473. # Add changes and commit.
  474. git add -f "${DEST}"
  475. git commit -m "tools: update GTK theme"
  476. }
  477. update_tinyexpr () {
  478. # Download latest tinyexpr.
  479. local REPO=https://github.com/codeplea/tinyexpr
  480. local DEST=3rdparty/tinyexpr
  481. local BRANCH=master
  482. rm -rf "${DEST}"
  483. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  484. # Cleanup.
  485. rm -r "${DEST}"/doc
  486. rm "${DEST}"/benchmark.c
  487. rm "${DEST}"/CONTRIBUTING
  488. rm "${DEST}"/example2.c
  489. rm "${DEST}"/example3.c
  490. rm "${DEST}"/example.c
  491. rm "${DEST}"/Makefile
  492. rm "${DEST}"/minctest.h
  493. rm "${DEST}"/README.md
  494. rm "${DEST}"/repl.c
  495. rm "${DEST}"/smoke.c
  496. rm "${DEST}"/.travis.yml
  497. # Add changes and commit.
  498. git add -f "${DEST}"
  499. git commit -m "3rdparty: update tinyexpr"
  500. }
  501. update_ufbx () {
  502. # Download latest tinyexpr.
  503. local REPO=https://github.com/ufbx/ufbx
  504. local DEST=3rdparty/ufbx
  505. local BRANCH=v0.20.0
  506. rm -rf "${DEST}"
  507. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  508. # Cleanup.
  509. rm -r "${DEST}"/.git
  510. rm -r "${DEST}"/.github
  511. rm -r "${DEST}"/bindgen
  512. rm -r "${DEST}"/data
  513. rm -r "${DEST}"/examples
  514. rm -r "${DEST}"/extra
  515. rm -r "${DEST}"/misc
  516. rm -r "${DEST}"/test
  517. rm "${DEST}"/.gitattributes
  518. rm "${DEST}"/.gitignore
  519. rm "${DEST}"/README.md
  520. # Add changes and commit.
  521. git add -f "${DEST}"
  522. git commit -m "3rdparty: update ufbx"
  523. }
  524. update_stb () {
  525. # Download latest stb libs.
  526. local REPO=https://github.com/nothings/stb
  527. local DEST=3rdparty/stb
  528. local BRANCH=master
  529. rm -rf "${DEST}"
  530. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  531. # Cleanup.
  532. rm -r "${DEST}"/.git
  533. rm -r "${DEST}"/.github
  534. rm -r "${DEST}"/data
  535. rm -r "${DEST}"/deprecated
  536. rm -r "${DEST}"/docs
  537. rm -r "${DEST}"/stb_image_resize_test
  538. rm -r "${DEST}"/tests
  539. rm -r "${DEST}"/tools
  540. rm "${DEST}"/.gitignore
  541. rm "${DEST}"/.travis.yml
  542. rm "${DEST}"/.gitignore
  543. rm "${DEST}"/README.md
  544. rm "${DEST}"/stb_c_lexer.h
  545. rm "${DEST}"/stb_connected_components.h
  546. rm "${DEST}"/stb_divide.h
  547. rm "${DEST}"/stb_ds.h
  548. rm "${DEST}"/stb_dxt.h
  549. rm "${DEST}"/stb_easy_font.h
  550. rm "${DEST}"/stb_herringbone_wang_tile.h
  551. rm "${DEST}"/stb_hexwave.h
  552. rm "${DEST}"/stb_image.h
  553. rm "${DEST}"/stb_image_resize2.h
  554. rm "${DEST}"/stb_image_write.h
  555. rm "${DEST}"/stb_include.h
  556. rm "${DEST}"/stb_leakcheck.h
  557. rm "${DEST}"/stb_perlin.h
  558. rm "${DEST}"/stb_textedit.h
  559. rm "${DEST}"/stb_tilemap_editor.h
  560. rm "${DEST}"/stb_voxel_render.h
  561. # Add changes and commit.
  562. git add -f "${DEST}"
  563. git commit -m "3rdparty: update stb"
  564. }
  565. update_lz4 () {
  566. local REPO=https://github.com/lz4/lz4
  567. local DEST=3rdparty/lz4
  568. local BRANCH=v1.10.0
  569. rm -rf "${DEST}"
  570. git_clone "${DEST}" "${REPO}" "${BRANCH}"
  571. # Cleanup.
  572. rm -rf "${DEST}"/.git
  573. rm -rf "${DEST}"/.github
  574. rm -rf "${DEST}"/.gitignore
  575. rm -rf "${DEST}"/.circleci/config.yml
  576. rm -rf "${DEST}"/.circleci/images/primary/Dockerfile
  577. rm -rf "${DEST}"/.cirrus.yml
  578. rm -rf "${DEST}"/.clang-format
  579. rm -rf "${DEST}"/.gitattributes
  580. rm -rf "${DEST}"/CODING_STYLE
  581. rm -rf "${DEST}"/INSTALL
  582. rm -rf "${DEST}"/LICENSE
  583. rm -rf "${DEST}"/Makefile
  584. rm -rf "${DEST}"/Makefile.inc
  585. rm -rf "${DEST}"/NEWS
  586. rm -rf "${DEST}"/SECURITY.md
  587. rm -rf "${DEST}"/appveyor.yml
  588. rm -rf "${DEST}"/build/
  589. rm -rf "${DEST}"/contrib/
  590. rm -rf "${DEST}"/doc/
  591. rm -rf "${DEST}"/examples/
  592. rm -rf "${DEST}"/lib/.gitignore
  593. rm -rf "${DEST}"/lib/Makefile
  594. rm -rf "${DEST}"/lib/dll
  595. rm -rf "${DEST}"/lib/liblz4-dll.rc.in
  596. rm -rf "${DEST}"/lib/liblz4.pc.in
  597. rm -rf "${DEST}"/lib/lz4file.c
  598. rm -rf "${DEST}"/lib/lz4file.h
  599. rm -rf "${DEST}"/lib/lz4frame.c
  600. rm -rf "${DEST}"/lib/lz4frame.h
  601. rm -rf "${DEST}"/lib/lz4frame_static.h
  602. rm -rf "${DEST}"/lib/xxhash.c
  603. rm -rf "${DEST}"/lib/xxhash.h
  604. rm -rf "${DEST}"/ossfuzz
  605. rm -rf "${DEST}"/programs
  606. rm -rf "${DEST}"/tests
  607. # Add changes and commit.
  608. git add -f "${DEST}"
  609. git commit -m "3rdparty: update lz4"
  610. }
  611. wayland_scanner () {
  612. local filename
  613. local protocol="$1"
  614. filename=$(basename "$protocol")
  615. local header="${filename%.*}"
  616. wayland-scanner client-header "$1" 3rdparty/wayland/include/wayland/"$header"-client-protocol.h
  617. wayland-scanner private-code "$1" 3rdparty/wayland/include/wayland/"$header"-client-protocol.c
  618. }
  619. update_wayland () {
  620. wayland_scanner /usr/share/wayland/wayland.xml
  621. wayland_scanner /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
  622. wayland_scanner /usr/share/wayland-protocols/unstable/relative-pointer/relative-pointer-unstable-v1.xml
  623. wayland_scanner /usr/share/wayland-protocols/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
  624. }
  625. print_help () {
  626. echo "Usage: scripts/upgrade.sh <dependency-name>"
  627. }
  628. while true; do
  629. case "$1" in
  630. luajit)
  631. update_luajit
  632. exit $?
  633. ;;
  634. bgfx)
  635. update_bgfx
  636. exit $?
  637. ;;
  638. bullet)
  639. update_bullet
  640. exit $?
  641. ;;
  642. openal)
  643. update_openal
  644. exit $?
  645. ;;
  646. sphinx_rtd_theme)
  647. update_sphinx_rtd_theme
  648. exit $?
  649. ;;
  650. sphinx_sitemap)
  651. update_sphinx_sitemap
  652. exit $?
  653. ;;
  654. sphinx_lubg)
  655. update_sphinx_lubg
  656. exit $?
  657. ;;
  658. sphinx_opengraph)
  659. update_sphinx_opengraph
  660. exit $?
  661. ;;
  662. tinyexpr)
  663. update_tinyexpr
  664. exit $?
  665. ;;
  666. gtk_theme)
  667. update_gtk_theme
  668. exit $?
  669. ;;
  670. ufbx)
  671. update_ufbx
  672. exit $?
  673. ;;
  674. stb)
  675. update_stb
  676. exit $?
  677. ;;
  678. lz4)
  679. update_lz4
  680. exit $?
  681. ;;
  682. wayland)
  683. update_wayland
  684. exit $?
  685. ;;
  686. *)
  687. echo "Unknown option or target \`$1\`"
  688. print_help
  689. exit 1
  690. ;;
  691. esac
  692. done