Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export EMSCRIPTEN_ROOT=[path containing em++, emsdk-portable/emscripten/*]
  4. export ANDROID_HOME=[path to android sdk, usually home/Android/Sdk]
  5. export ANDROID_NDK_ROOT=[path to android ndk, likely $ANDROID_HOME/ndk-bundle]
  6.  
  7. X11_DEBUG=false
  8. X11_RELEASE=false
  9. WIN_DEBUG=false
  10. WIN_RELEASE=false
  11. WEB_DEBUG=false
  12. WEB_RELEASE=false
  13. ANDROID_DEBUG=false
  14. ANDROID_RELEASE=false
  15.  
  16. usage () {
  17. echo "Usage:"
  18. echo " --all builds all platforms"
  19. echo " --x11 builds all linux targets"
  20. echo " --win builds all windows targets"
  21. echo " --web builds all html5 targets"
  22. echo " --android builds all android targets"
  23. echo ""
  24. echo " append -debug or -release for debug or release builds only"
  25. echo " e.g. --all-debug"
  26. echo ""
  27. echo "This script assumes a proper environment is set up. In other words:"
  28. echo ""
  29. echo "1) All dev libs must be installed for i686 and x86-64."
  30. echo "2) Same for the mingw32 and mingw64 toolchains."
  31. echo "3) Android build tools (version 23.0.3) + NDK must be installed."
  32. echo "4) emscripten sdk must be installed."
  33. echo "5) Optional: Install upx to compress executables."
  34. echo ""
  35. echo "I'd recommend building one platform at a time on the first run to make certain you have everything you need."
  36. }
  37.  
  38. if [[ ! $# -gt 0 ]]; then
  39. usage
  40. exit
  41. fi
  42.  
  43. # Make sure we're in the right directory by looking for the Godot icon.
  44. if [[ ! -f "icon.svg" ]]; then
  45. echo "Script must be run from root of godot repo."
  46. exit
  47. fi
  48.  
  49. # Parse script arguments.
  50. while [[ $# -gt 0 ]]; do
  51. key="$1"
  52.  
  53. case $key in
  54. --x11-debug) X11_DEBUG=true; ;;
  55. --x11-release) X11_RELEASE=true; ;;
  56. --win-debug) WIN_DEBUG=true; ;;
  57. --win-release) WIN_RELEASE=true; ;;
  58. --web-debug) WEB_DEBUG=true; ;;
  59. --web-release) WEB_RELEASE=true; ;;
  60. --android-debug) ANDROID_DEBUG=true; ;;
  61. --android-release) ANDROID_RELEASE=true; ;;
  62. --x11) X11_DEBUG=true; X11_RELEASE=true; ;;
  63. --win) WIN_DEBUG=true; WIN_RELEASE=true; ;;
  64. --web) WEB_DEBUG=true; WEB_RELEASE=true; ;;
  65. --android) ANDROID_DEBUG=true; ANDROID_RELEASE=true; ;;
  66. --all)
  67. X11_DEBUG=true
  68. X11_RELEASE=true
  69. WIN_DEBUG=true
  70. WIN_RELEASE=true
  71. WEB_DEBUG=true
  72. WEB_RELEASE=true
  73. ANDROID_DEBUG=true
  74. ANDROID_RELEASE=true
  75. ;;
  76. *)
  77. usage
  78. exit
  79. ;;
  80. esac
  81.  
  82. shift
  83. done
  84.  
  85. # Throw them in an array and count them up.
  86. declare -a PLATFORMS=(\
  87. "$X11_DEBUG" "$X11_RELEASE"\
  88. "$WIN_DEBUG" "$WIN_RELEASE"\
  89. "$WEB_DEBUG" "$WEB_RELEASE"\
  90. "$ANDROID_DEBUG" "$ANDROID_RELEASE")
  91.  
  92. COUNT=0
  93.  
  94. for i in "${PLATFORMS[@]}"; do
  95. if [[ "$i" = true ]]; then
  96. COUNT=$(($COUNT + 1))
  97. fi
  98. done
  99.  
  100. if [[ $COUNT -gt 0 ]]; then
  101. if [[ ! -d "templates" ]]; then
  102. mkdir templates
  103. fi
  104. fi
  105.  
  106. # Linux
  107. if [[ "$X11_DEBUG" = true || "$X11_RELEASE" = true ]]; then
  108. if [[ "$X11_DEBUG" = true ]]; then
  109. scons -j 4 p=x11 tools=no target=release_debug bits=64
  110. scons -j 4 p=x11 tools=no target=release_debug bits=32
  111.  
  112. cp bin/godot.x11.opt.debug.64 templates/linux_x11_64_debug
  113. cp bin/godot.x11.opt.debug.32 templates/linux_x11_32_debug
  114.  
  115. upx templates/linux_x11_64_debug
  116. upx templates/linux_x11_32_debug
  117. fi
  118.  
  119. if [[ "$X11_RELEASE" = true ]]; then
  120. scons -j 4 p=x11 tools=no target=release bits=64
  121. scons -j 4 p=x11 tools=no target=release bits=32
  122.  
  123. cp bin/godot.x11.opt.64 templates/linux_x11_64_release
  124. cp bin/godot.x11.opt.32 templates/linux_x11_32_release
  125.  
  126. upx templates/linux_x11_64_release
  127. upx templates/linux_x11_32_release
  128. fi
  129. fi
  130.  
  131. # Windows
  132. if [[ "$WIN_DEBUG" = true || "$WIN_RELEASE" = true ]]; then
  133. if [[ "$WIN_DEBUG" = true ]]; then
  134. scons -j 4 p=windows tools=no target=release_debug bits=64
  135. scons -j 4 p=windows tools=no target=release_debug bits=32
  136.  
  137. cp bin/godot.windows.opt.debug.64.exe templates/windows_64_debug.exe
  138. cp bin/godot.windows.opt.debug.32.exe templates/windows_32_debug.exe
  139.  
  140. upx templates/windows_32_debug.exe
  141. x86_64-w64-mingw32-strip templates/windows_64_debug.exe
  142. fi
  143.  
  144. if [[ "$WIN_RELEASE" = true ]]; then
  145. scons -j 4 p=windows tools=no target=release bits=64
  146. scons -j 4 p=windows tools=no target=release bits=32
  147.  
  148. cp bin/godot.windows.opt.64.exe templates/windows_64_release.exe
  149. cp bin/godot.windows.opt.32.exe templates/windows_32_release.exe
  150.  
  151. upx templates/windows_32_release.exe
  152. x86_64-w64-mingw32-strip templates/windows_64_release.exe
  153. fi
  154. fi
  155.  
  156. # HTML5
  157. if [[ "$WEB_DEBUG" = true || "$WEB_RELEASE" = true ]]; then
  158. if [[ ! -f "$EMSCRIPTEN_ROOT/em++" ]]; then
  159. echo "Emscripten not properly set up. Please install the Emscripten SDK.";
  160. exit
  161. fi
  162.  
  163. if [[ "$WEB_DEBUG" = true ]]; then
  164. scons -j 4 p=javascript target=release_debug
  165.  
  166. cp bin/godot.javascript.opt.debug.html godot.html
  167. cp bin/godot.javascript.opt.debug.js godot.js
  168. cp misc/dist/html_fs/godotfs.js .
  169. zip javascript_debug.zip godot.html godot.js godotfs.js
  170. mv javascript_debug.zip templates/
  171. fi
  172.  
  173. if [[ "$WEB_RELEASE" = true ]]; then
  174. scons -j 4 p=javascript target=release
  175.  
  176. cp bin/godot.javascript.opt.html godot.html
  177. cp bin/godot.javascript.opt.js godot.js
  178. cp misc/dist/html_fs/godotfs.js .
  179. zip javascript_release.zip godot.html godot.js godotfs.js
  180. mv javascript_release.zip templates/
  181. fi
  182.  
  183. # Clean up mess.
  184. rm a.out.js godot.html godot.js godotfs.js
  185. fi
  186.  
  187. # Android
  188. if [[ "$ANDROID_DEBUG" = true || "$ANDROID_RELEASE" = true ]]; then
  189. if [[ ! -d "$ANDROID_HOME/build-tools/23.0.3" ]]; then
  190. echo "Android SDK build tools version 23.0.3 not found.";
  191. echo "Please install it with the Android Studio SDK manager.";
  192. exit
  193. fi
  194.  
  195. # Not sure if this is necessary, t'is but a relic of the old. But it doesn't hurt.
  196. mkdir -p platform/android/java/libs/armeabi
  197. mkdir -p platform/android/java/libs/x86
  198.  
  199. if [[ "$ANDROID_DEBUG" = true ]]; then
  200. scons -j 4 p=android target=release_debug
  201. scons -j 4 p=android target=release_debug android_arch=x86
  202.  
  203. cd platform/android/java
  204. ./gradlew build
  205. cd ../../..
  206.  
  207. cp bin/android_debug.apk templates/android_debug.apk
  208. fi
  209.  
  210. if [[ "$ANDROID_RELEASE" = true ]]; then
  211. scons -j 4 p=android target=release
  212. scons -j 4 p=android target=release android_arch=x86
  213.  
  214. cd platform/android/java
  215. ./gradlew build
  216. cd ../../..
  217.  
  218. cp bin/android_release.apk templates/android_release.apk
  219. fi
  220. fi
  221.  
  222. # Zip the template directory's contents into templates.tpz.
  223. if [[ $COUNT -gt 0 ]]; then
  224. cd templates
  225. zip templates.tpz ./*
  226. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement