build-templates.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. set -e
  3. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  4. pushd "$dir" > /dev/null
  5. if [ ! "$#" -eq 1 ]; then
  6. echo "Usage: ./build-templates.sh <platform>"
  7. echo
  8. echo "e.g.:"
  9. echo " ./build-templates.sh windows"
  10. echo " ./build-templates.sh linux"
  11. echo " ./build-templates.sh macos"
  12. echo " ./build-templates.sh ios"
  13. echo " ./build-templates.sh android"
  14. echo " ./build-templates.sh web"
  15. echo
  16. exit 1
  17. fi
  18. if [ ! -d ../godot ]; then
  19. echo "No Godot clone found. Run ./setup.sh <Godot branch or tag> <dev> first."
  20. exit 1
  21. fi
  22. platform=${1%/}
  23. cpus=2
  24. if [ "$OSTYPE" = "msys" ]; then
  25. cpus=$NUMBER_OF_PROCESSORS
  26. elif [[ "$OSTYPE" = "darwin"* ]]; then
  27. cpus=$(sysctl -n hw.logicalcpu)
  28. else
  29. cpus=$(grep -c ^processor /proc/cpuinfo)
  30. fi
  31. pushd ../godot
  32. if [ "$platform" = "windows" ]; then
  33. # --- Windows ---
  34. #generates windows_64_debug.exe and windows_64_release.exe
  35. scons platform=windows tools=no target=release custom_modules="../spine_godot" --jobs=$cpus
  36. scons platform=windows tools=no target=release_debug custom_modules="../spine_godot" --jobs=$cpus
  37. cp bin/godot.windows.opt.64.exe bin/windows_64_release.exe
  38. cp bin/godot.windows.opt.debug.64.exe bin/windows_64_debug.exe
  39. elif [ "$platform" = "macos" ]; then
  40. # --- macOS ---
  41. # generates osx.zip
  42. scons platform=osx tools=no target=release arch=x86_64 custom_modules="../spine_godot" --jobs=$cpus
  43. scons platform=osx tools=no target=release_debug arch=x86_64 custom_modules="../spine_godot" --jobs=$cpus
  44. scons platform=osx tools=no target=release arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
  45. scons platform=osx tools=no target=release_debug arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
  46. lipo -create bin/godot.osx.opt.x86_64 bin/godot.osx.opt.arm64 -output bin/godot.osx.opt.universal
  47. lipo -create bin/godot.osx.opt.debug.x86_64 bin/godot.osx.opt.debug.arm64 -output bin/godot.osx.opt.debug.universal
  48. strip -S -x bin/godot.osx.opt.universal
  49. pushd bin
  50. cp -r ../misc/dist/osx_template.app .
  51. mkdir -p osx_template.app/Contents/MacOS
  52. cp godot.osx.opt.universal osx_template.app/Contents/MacOS/godot_osx_release.64
  53. cp godot.osx.opt.debug.universal osx_template.app/Contents/MacOS/godot_osx_debug.64
  54. chmod +x osx_template.app/Contents/MacOS/godot_osx*
  55. rm -rf osx.zip
  56. zip -q -9 -r osx.zip osx_template.app
  57. popd
  58. elif [ "$platform" = "ios" ]; then
  59. # --- iOS --
  60. # generates iphone.zip
  61. scons p=iphone tools=no target=release arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
  62. scons p=iphone tools=no target=release_debug arch=arm64 custom_modules="../spine_godot" --jobs=$cpus
  63. scons p=iphone tools=no target=release arch=arm64 ios_simulator=yes custom_modules="../spine_godot" --jobs=$cpus
  64. scons p=iphone tools=no target=release arch=x86_64 ios_simulator=yes custom_modules="../spine_godot" --jobs=$cpus
  65. scons p=iphone tools=no target=release_debug arch=arm64 ios_simulator=yes custom_modules="../spine_godot" --jobs=$cpus
  66. scons p=iphone tools=no target=release_debug arch=x86_64 ios_simulator=yes custom_modules="../spine_godot" --jobs=$cpus
  67. lipo -create bin/libgodot.iphone.opt.arm64.simulator.a bin/libgodot.iphone.opt.x86_64.simulator.a -output bin/libgodot.iphone.opt.simulator.a
  68. lipo -create bin/libgodot.iphone.opt.debug.arm64.simulator.a bin/libgodot.iphone.opt.debug.x86_64.simulator.a -output bin/libgodot.iphone.opt.debug.simulator.a
  69. strip -S -x bin/libgodot.iphone.opt.arm64.a
  70. strip -S -x bin/libgodot.iphone.opt.simulator.a
  71. pushd bin
  72. cp -r ../misc/dist/ios_xcode .
  73. cp libgodot.iphone.opt.arm64.a ios_xcode/libgodot.iphone.release.xcframework/ios-arm64/libgodot.a
  74. cp libgodot.iphone.opt.simulator.a ios_xcode/libgodot.iphone.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a
  75. cp libgodot.iphone.opt.debug.arm64.a ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64/libgodot.a
  76. cp libgodot.iphone.opt.debug.simulator.a ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a
  77. rm -rf iphone.zip
  78. pushd ios_xcode
  79. zip -q -9 -r ../iphone.zip *
  80. popd
  81. popd
  82. elif [ "$platform" = "web" ]; then
  83. # --- WEB ---
  84. # generates webassembly_debug.zip, webassembly_release.zip
  85. scons platform=javascript tools=no target=release custom_modules="../spine_godot" --jobs=$cpus
  86. scons platform=javascript tools=no target=release_debug custom_modules="../spine_godot" --jobs=$cpus
  87. mv bin/godot.javascript.opt.zip bin/webassembly_release.zip
  88. mv bin/godot.javascript.opt.debug.zip bin/webassembly_debug.zip
  89. elif [ "$platform" = "android" ]; then
  90. # --- ANROID ---
  91. # generates android_release.apk, android_debug.apk, android_source.zip
  92. scons platform=android target=release android_arch=armv7 custom_modules="../spine_godot" --jobs=$cpus
  93. scons platform=android target=release_debug android_arch=armv7 custom_modules="../spine_godot" --jobs=$cpus
  94. scons platform=android target=release android_arch=arm64v8 custom_modules="../spine_godot" --jobs=$cpus
  95. scons platform=android target=release_debug android_arch=arm64v8 custom_modules="../spine_godot" --jobs=$cpus
  96. pushd platform/android/java
  97. chmod a+x gradlew
  98. ./gradlew generateGodotTemplates
  99. popd
  100. elif [ "$platform" = "linux" ]; then
  101. # --- Linix ---
  102. # generates linux_x11_64_release, linux_x11_64_debug
  103. scons platform=x11 tools=no target=release bits=64 custom_modules="../spine_godot" --jobs=$cpus
  104. scons platform=x11 tools=no target=release_debug bits=64 custom_modules="../spine_godot" --jobs=$cpus
  105. strip bin/godot.x11.opt.64
  106. strip bin/godot.x11.opt.debug.64
  107. chmod a+x bin/godot.x11.opt.64
  108. chmod a+x bin/godot.x11.opt.debug.64
  109. cp bin/godot.x11.opt.64 bin/linux_x11_64_release
  110. cp bin/godot.x11.opt.debug.64 bin/linux_x11_64_debug
  111. else
  112. echo "Unknown platform: $platform"
  113. exit 1
  114. fi
  115. popd