build-godot.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. #!/bin/bash
  2. set -e
  3. if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
  4. echo "Usage: $0 <version> <mono version> <platform>"
  5. echo " For example: $0 3.0.3-rc3 5.12.0.226 ubuntu_32"
  6. echo ""
  7. echo "Platforms: mono-glue, ubuntu_32, ubuntu_64, macos, uwp, windows, javascript, android"
  8. exit 1
  9. fi
  10. export OPTIONS="builtin_libpng=yes builtin_openssl=yes builtin_zlib=yes gdnative_wrapper=yes debug_symbols=no"
  11. export SSHOPTS="-i /home/hp/.ssh/id_rsa -oStrictHostKeyChecking=no "
  12. export GODOT_VERSION=$1
  13. export MONO_VERSION=$2
  14. function get-domain-ip {
  15. rx='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
  16. domain=$1
  17. mac=$(sudo virsh domiflist ${domain} | tail -n-2 | awk '{print $5}')
  18. ip=""
  19. while [[ ! "$ip" =~ ^$rx\.$rx\.$rx\.$rx$ ]]; do
  20. ip=$(sudo virsh net-dhcp-leases default-nat | grep $mac | awk '{print $5}' | cut -d/ -f1)
  21. done
  22. echo $ip
  23. }
  24. function boot-domain {
  25. domain=$1
  26. echo "${domain} "
  27. if sudo virsh start ${domain}; then
  28. sleep 30s
  29. fi
  30. ip=$(get-domain-ip ${domain})
  31. while ! tcping -t 1 ${ip} 22 &>/dev/null; do
  32. sleep 1
  33. done
  34. }
  35. function mono-glue {
  36. rm -rf godot-mono-glue
  37. git clone https://github.com/godotengine/godot.git godot-mono-glue
  38. cd godot-mono-glue
  39. git checkout -b 3.0 origin/3.0 || git checkout 3.0
  40. git branch --set-upstream-to=origin/3.0 3.0
  41. git reset --hard
  42. git pull
  43. TERM=xterm /usr/bin/scons platform=x11 bits=64 -j16 ${OPTIONS} target=release_debug tools=yes module_mono_enabled=yes mono_glue=no CXXFLAGS="-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include/ -Wno-parentheses"
  44. bin/godot.x11.opt.tools.64.mono --generate-mono-glue modules/mono/glue
  45. cd ..
  46. rm -rf mono-glue
  47. mkdir mono-glue
  48. cp godot-mono-glue/modules/mono/glue/cs_compressed.gen.h godot-mono-glue/modules/mono/glue/mono_glue.gen.cpp mono-glue
  49. }
  50. function ubuntu_32 {
  51. mkdir -p godot-ubuntu-32
  52. boot-domain godot-ubuntu14.04-32
  53. scp $SSHOPTS build-godot-ubuntu-32.sh user@${ip}:~/build-godot.sh
  54. scp $SSHOPTS -r mono-glue user@${ip}:~/
  55. ssh $SSHOPTS user@${ip} bash build-godot.sh ${MONO_VERSION}
  56. scp $SSHOPTS user@${ip}:~/godot/bin/* godot-ubuntu-32
  57. ssh $SSHOPTS user@${ip} sudo shutdown -h now || /bin/true
  58. mkdir -p templates
  59. rm -f templates/linux_x11_32*
  60. cp godot-ubuntu-32/godot.x11.opt.debug.32 templates/linux_x11_32_debug
  61. cp godot-ubuntu-32/godot.x11.opt.32 templates/linux_x11_32_release
  62. mkdir -p release-${GODOT_VERSION}
  63. rm -f release-${GODOT_VERSION}/*linux*32*
  64. cp godot-ubuntu-32/godot.x11.opt.tools.32 Godot_v${GODOT_VERSION}_x11.32
  65. zip -q -9 Godot_v${GODOT_VERSION}_x11.32.zip Godot_v${GODOT_VERSION}_x11.32
  66. mv Godot_v${GODOT_VERSION}_x11.32.zip release-${GODOT_VERSION}
  67. rm Godot_v${GODOT_VERSION}_x11.32
  68. mkdir -p mono/release-${GODOT_VERSION}
  69. rm -f mono/release-${GODOT_VERSION}/*linux*32*
  70. mkdir -p Godot_v${GODOT_VERSION}_mono_x11_32
  71. cp godot-ubuntu-32/godot.x11.opt.tools.32.mono Godot_v${GODOT_VERSION}_mono_x11_32/Godot_v${GODOT_VERSION}_mono_x11.32
  72. cp godot-ubuntu-32/*.dll Godot_v${GODOT_VERSION}_mono_x11_32
  73. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_x11_32.zip Godot_v${GODOT_VERSION}_mono_x11_32
  74. mv Godot_v${GODOT_VERSION}_mono_x11_32.zip mono/release-${GODOT_VERSION}
  75. rm -rf Godot_v${GODOT_VERSION}_mono_x11_32
  76. mkdir -p mono/templates
  77. rm -f mono/templates/*linux*32*
  78. cp godot-ubuntu-32/godot.x11.opt.debug.32.mono mono/templates/linux_x11_32_debug
  79. cp godot-ubuntu-32/godot.x11.opt.32.mono mono/templates/linux_x11_32_release
  80. }
  81. function ubuntu_64 {
  82. mkdir -p godot-ubuntu-64
  83. boot-domain godot-ubuntu14.04-64
  84. scp $SSHOPTS build-godot-ubuntu-64.sh user@${ip}:~/build-godot.sh
  85. scp $SSHOPTS -r mono-glue user@${ip}:~/
  86. ssh $SSHOPTS user@${ip} bash build-godot.sh ${MONO_VERSION}
  87. scp $SSHOPTS user@${ip}:~/godot/bin/* godot-ubuntu-64
  88. ssh $SSHOPTS user@${ip} sudo shutdown -h now || /bin/true
  89. mkdir -p templates
  90. rm -f templates/linux_x11_64*
  91. cp godot-ubuntu-64/godot.x11.opt.debug.64 templates/linux_x11_64_debug
  92. cp godot-ubuntu-64/godot.x11.opt.64 templates/linux_x11_64_release
  93. mkdir -p release-${GODOT_VERSION}
  94. rm -f release-${GODOT_VERSION}/*linux*64*
  95. cp godot-ubuntu-64/godot_server.server.opt.64 Godot_v${GODOT_VERSION}_linux_server.64
  96. zip -q -9 Godot_v${GODOT_VERSION}_linux_server.64.zip Godot_v${GODOT_VERSION}_linux_server.64
  97. mv Godot_v${GODOT_VERSION}_linux_server.64.zip release-${GODOT_VERSION}
  98. rm Godot_v${GODOT_VERSION}_linux_server.64
  99. cp godot-ubuntu-64/godot_server.server.opt.tools.64 Godot_v${GODOT_VERSION}_linux_headless.64
  100. zip -q -9 Godot_v${GODOT_VERSION}_linux_headless.64.zip Godot_v${GODOT_VERSION}_linux_headless.64
  101. mv Godot_v${GODOT_VERSION}_linux_headless.64.zip release-${GODOT_VERSION}
  102. rm Godot_v${GODOT_VERSION}_linux_headless.64
  103. cp godot-ubuntu-64/godot.x11.opt.tools.64 Godot_v${GODOT_VERSION}_x11.64
  104. zip -q -9 Godot_v${GODOT_VERSION}_x11.64.zip Godot_v${GODOT_VERSION}_x11.64
  105. mv Godot_v${GODOT_VERSION}_x11.64.zip release-${GODOT_VERSION}
  106. rm Godot_v${GODOT_VERSION}_x11.64
  107. mkdir -p mono/release-${GODOT_VERSION}
  108. rm -f mono/release-${GODOT_VERSION}/*linux*64*
  109. mkdir -p Godot_v${GODOT_VERSION}_mono_x11_64
  110. cp godot-ubuntu-64/godot.x11.opt.tools.64.mono Godot_v${GODOT_VERSION}_mono_x11_64/Godot_v${GODOT_VERSION}_mono_x11.64
  111. cp godot-ubuntu-64/*.dll Godot_v${GODOT_VERSION}_mono_x11_64
  112. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_x11_64.zip Godot_v${GODOT_VERSION}_mono_x11_64
  113. mv Godot_v${GODOT_VERSION}_mono_x11_64.zip mono/release-${GODOT_VERSION}
  114. rm -rf Godot_v${GODOT_VERSION}_mono_x11_64
  115. mkdir -p mono/templates
  116. rm -f mono/templates/*linux*64*
  117. cp godot-ubuntu-64/godot.x11.opt.debug.64.mono mono/templates/linux_x11_64_debug
  118. cp godot-ubuntu-64/godot.x11.opt.64.mono mono/templates/linux_x11_64_release
  119. }
  120. function uwp {
  121. boot-domain godot-win10
  122. mkdir -p godot-uwp
  123. scp $SSHOPTS build-godot-uwp.bat user@${ip}:
  124. scp $SSHOPTS -r mono-glue user@${ip}:
  125. ssh $SSHOPTS user@${ip} build-godot-uwp.bat
  126. scp $SSHOPTS -r user@${ip}:binaries/* godot-uwp
  127. ssh $SSHOPTS user@${ip} "shutdown /s /t 0" || /bin/true
  128. mkdir -p templates
  129. rm -f templates/uwp*
  130. rm -rf angle*
  131. wget -c https://github.com/GodotBuilder/godot-builds/releases/download/_tools/angle.7z
  132. 7z x angle.7z
  133. rm -rf uwp_template_*
  134. for arch in ARM Win32 x64; do
  135. cp -r godot-mono-glue/misc/dist/uwp_template uwp_template_${arch}
  136. cp angle/winrt/10/src/Release_${arch}/libEGL.dll \
  137. angle/winrt/10/src/Release_${arch}/libGLESv2.dll \
  138. uwp_template_${arch}/
  139. cp -r uwp_template_${arch} uwp_template_${arch}_debug
  140. done
  141. # ARM
  142. cp godot-uwp/uwp_arm/godot.uwp.opt.32.arm.exe uwp_template_ARM/godot.uwp.exe
  143. cp godot-uwp/uwp_arm/godot.uwp.opt.debug.32.arm.exe uwp_template_ARM_debug/godot.uwp.exe
  144. cd uwp_template_ARM && zip -q -9 -r ../templates/uwp_arm_release.zip * && cd ..
  145. cd uwp_template_ARM_debug && zip -q -9 -r ../templates/uwp_arm_debug.zip * && cd ..
  146. # Win32
  147. cp godot-uwp/uwp_x86/godot.uwp.opt.32.x86.exe uwp_template_Win32/godot.uwp.exe
  148. cp godot-uwp/uwp_x86/godot.uwp.opt.debug.32.x86.exe uwp_template_Win32_debug/godot.uwp.exe
  149. cd uwp_template_Win32 && zip -q -9 -r ../templates/uwp_x86_release.zip * && cd ..
  150. cd uwp_template_Win32_debug && zip -q -9 -r ../templates/uwp_x86_debug.zip * && cd ..
  151. # x64
  152. cp godot-uwp/uwp_amd64/godot.uwp.opt.64.x64.exe uwp_template_x64/godot.uwp.exe
  153. cp godot-uwp/uwp_amd64/godot.uwp.opt.debug.64.x64.exe uwp_template_x64_debug/godot.uwp.exe
  154. cd uwp_template_x64 && zip -q -9 -r ../templates/uwp_x64_release.zip * && cd ..
  155. cd uwp_template_x64_debug && zip -q -9 -r ../templates/uwp_x64_debug.zip * && cd ..
  156. rm -rf uwp_template_*
  157. }
  158. function windows {
  159. mkdir -p godot-windows
  160. boot-domain godot-fedora28
  161. scp $SSHOPTS build-godot-windows.sh user@${ip}:~/build-godot.sh
  162. scp $SSHOPTS -r mono-glue user@${ip}:~/
  163. ssh $SSHOPTS user@${ip} bash build-godot.sh ${MONO_VERSION}
  164. scp $SSHOPTS user@${ip}:~/godot/bin/* godot-windows
  165. ssh $SSHOPTS user@${ip} sudo shutdown -h now || /bin/true
  166. mkdir -p release-${GODOT_VERSION}
  167. rm -f release-${GODOT_VERSION}/*win*zip
  168. cp godot-windows/godot.windows.opt.tools.64.exe Godot_v${GODOT_VERSION}_win64.exe
  169. strip Godot_v${GODOT_VERSION}_win64.exe
  170. zip -q -9 Godot_v${GODOT_VERSION}_win64.exe.zip Godot_v${GODOT_VERSION}_win64.exe
  171. mv Godot_v${GODOT_VERSION}_win64.exe.zip release-${GODOT_VERSION}
  172. rm Godot_v${GODOT_VERSION}_win64.exe
  173. cp godot-windows/godot.windows.opt.tools.32.exe Godot_v${GODOT_VERSION}_win32.exe
  174. strip Godot_v${GODOT_VERSION}_win32.exe
  175. zip -q -9 Godot_v${GODOT_VERSION}_win32.exe.zip Godot_v${GODOT_VERSION}_win32.exe
  176. mv Godot_v${GODOT_VERSION}_win32.exe.zip release-${GODOT_VERSION}
  177. rm Godot_v${GODOT_VERSION}_win32.exe
  178. mkdir -p templates
  179. rm -rf templates/*win*
  180. cp godot-windows/godot.windows.opt.64.exe templates/windows_64_release.exe
  181. cp godot-windows/godot.windows.opt.debug.64.exe templates/windows_64_debug.exe
  182. cp godot-windows/godot.windows.opt.32.exe templates/windows_32_release.exe
  183. cp godot-windows/godot.windows.opt.debug.32.exe templates/windows_32_debug.exe
  184. strip templates/windows*.exe
  185. mkdir -p mono/release-${GODOT_VERSION}
  186. rm -f mono/release-${GODOT_VERSION}/*win*
  187. mkdir -p mono/templates
  188. rm -f mono/templates/*win*
  189. # Win32
  190. mkdir -p Godot_v${GODOT_VERSION}_mono_win32
  191. cp godot-windows/godot.windows.opt.tools.32.mono.exe Godot_v${GODOT_VERSION}_mono_win32/Godot_v${GODOT_VERSION}_mono_win32.exe
  192. strip Godot_v${GODOT_VERSION}_mono_win32/Godot_v${GODOT_VERSION}_mono_win32.exe
  193. cp godot-windows/*.dll Godot_v${GODOT_VERSION}_mono_win32
  194. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_win32.zip Godot_v${GODOT_VERSION}_mono_win32
  195. mv Godot_v${GODOT_VERSION}_mono_win32.zip mono/release-${GODOT_VERSION}
  196. rm -rf Godot_v${GODOT_VERSION}_mono_win32
  197. cp godot-windows/godot.windows.opt.debug.32.mono.exe mono/templates/windows_32_debug.exe
  198. cp godot-windows/godot.windows.opt.32.mono.exe mono/templates/windows_32_release.exe
  199. # x64
  200. mkdir -p Godot_v${GODOT_VERSION}_mono_win64
  201. cp godot-windows/godot.windows.opt.tools.64.mono.exe Godot_v${GODOT_VERSION}_mono_win64/Godot_v${GODOT_VERSION}_mono_win64.exe
  202. strip Godot_v${GODOT_VERSION}_mono_win64/Godot_v${GODOT_VERSION}_mono_win64.exe
  203. cp godot-windows/*.dll Godot_v${GODOT_VERSION}_mono_win64
  204. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_win64.zip Godot_v${GODOT_VERSION}_mono_win64
  205. mv Godot_v${GODOT_VERSION}_mono_win64.zip mono/release-${GODOT_VERSION}
  206. rm -rf Godot_v${GODOT_VERSION}_mono_win64
  207. cp godot-windows/godot.windows.opt.debug.64.mono.exe mono/templates/windows_64_debug.exe
  208. cp godot-windows/godot.windows.opt.64.mono.exe mono/templates/windows_64_release.exe
  209. strip mono/templates/windows*.exe
  210. }
  211. function macos {
  212. echo "booting macosx"
  213. mkdir -p godot-macosx
  214. sudo bash /media/disk2/hp/macosx/OSX-KVM/godot.sh || /bin/true
  215. while ! tcping -t 1 192.168.100.137 22 &>/dev/null; do
  216. sleep 1
  217. done
  218. sleep 30s
  219. scp $SSHOPTS build-godot-macosx.sh hp@192.168.100.137:~/build-godot.sh
  220. scp $SSHOPTS -r mono-glue hp@192.168.100.137:~/
  221. ssh $SSHOPTS hp@192.168.100.137 bash build-godot.sh ${MONO_VERSION}
  222. scp $SSHOPTS hp@192.168.100.137:~/godot/bin/* godot-macosx
  223. ssh $SSHOPTS hp@192.168.100.137 sudo shutdown -h now || /bin/true
  224. mkdir -p templates
  225. rm -f templates/osx*
  226. rm -f templates/iphone*
  227. rm -rf osx_template
  228. mkdir -p osx_template
  229. cd osx_template
  230. cp -r ../godot-mono-glue/misc/dist/osx_template.app .
  231. mkdir osx_template.app/Contents/MacOS
  232. cp ../godot-macosx/godot.osx.opt.fat osx_template.app/Contents/MacOS/godot_osx_release.fat
  233. cp ../godot-macosx/godot.osx.opt.debug.fat osx_template.app/Contents/MacOS/godot_osx_debug.fat
  234. chmod +x osx_template.app/Contents/MacOS/godot_osx*
  235. zip -q -9 -r osx.zip osx_template.app
  236. cd ..
  237. mv osx_template/osx.zip templates
  238. rm -rf osx_template
  239. cp -r godot-mono-glue/misc/dist/ios_xcode ios_xcode
  240. cp godot-macosx/libgodot.iphone.opt.fat ios_xcode/libgodot.iphone.release.fat.a
  241. cp godot-macosx//libgodot.iphone.opt.debug.fat ios_xcode/libgodot.iphone.debug.fat.a
  242. chmod +x ios_xcode/libgodot.iphone.*
  243. cd ios_xcode
  244. zip -q -9 -r ../templates/iphone.zip *
  245. cd ..
  246. rm -rf ios_xcode
  247. mkdir -p release-${GODOT_VERSION}
  248. rm -f release-${GODOT_VERSION}/*osx*
  249. cp -r godot-mono-glue/misc/dist/osx_tools.app Godot.app
  250. mkdir -p Godot.app/Contents/MacOS
  251. cp godot-macosx/godot.osx.opt.tools.fat Godot.app/Contents/MacOS/Godot
  252. chmod +x Godot.app/Contents/MacOS/Godot
  253. zip -q -9 -r "release-${GODOT_VERSION}/Godot_v${GODOT_VERSION}_osx.fat.zip" Godot.app
  254. rm -rf Godot.app
  255. mkdir -p mono/templates
  256. rm -f mono/templates/osx*
  257. rm -rf osx_template
  258. mkdir -p osx_template
  259. cd osx_template
  260. cp -r ../godot-mono-glue/misc/dist/osx_template.app .
  261. mkdir osx_template.app/Contents/MacOS
  262. cp ../godot-macosx/godot.osx.opt.fat.mono osx_template.app/Contents/MacOS/godot_osx_release.fat
  263. cp ../godot-macosx/godot.osx.opt.debug.fat.mono osx_template.app/Contents/MacOS/godot_osx_debug.fat
  264. chmod +x osx_template.app/Contents/MacOS/godot_osx*
  265. zip -q -9 -r osx.zip osx_template.app
  266. cd ..
  267. mv osx_template/osx.zip mono/templates
  268. rm -rf osx_template
  269. mkdir -p mono/release-${GODOT_VERSION}
  270. rm -f mono/release-${GODOT_VERSION}/*osx*
  271. cp -r godot-mono-glue/misc/dist/osx_tools.app Godot_mono.app
  272. mkdir -p Godot_mono.app/Contents/MacOS
  273. cp godot-macosx/godot.osx.opt.tools.fat.mono Godot_mono.app/Contents/MacOS/Godot
  274. cp godot-macosx/*.dll Godot_mono.app/Contents/MacOS/
  275. chmod +x Godot_mono.app/Contents/MacOS/Godot
  276. zip -q -9 -r "mono/release-${GODOT_VERSION}/Godot_v${GODOT_VERSION}_mono_osx.fat.zip" Godot_mono.app
  277. rm -rf Godot_mono.app
  278. }
  279. function android {
  280. export ANDROID_HOME=/home/hp/Apps/android/sdk/
  281. export ANDROID_NDK_ROOT=/home/hp/Apps/android/android-ndk-r16b
  282. export SCONS="/usr/bin/scons -j8 verbose=no warnings=no progress=no"
  283. export OPTIONS="builtin_libpng=yes builtin_openssl=yes builtin_zlib=yes gdnative_wrapper=yes debug_symbols=no"
  284. rm -rf godot-android
  285. git clone https://github.com/godotengine/godot.git godot-android
  286. cd godot-android
  287. git checkout -b 3.0 origin/3.0 || git checkout 3.0
  288. git branch --set-upstream-to=origin/3.0 3.0
  289. git reset --hard
  290. git pull
  291. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=armv7
  292. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=arm64v8
  293. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=x86
  294. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=armv7
  295. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=arm64v8
  296. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=x86
  297. pushd platform/android/java
  298. ./gradlew build
  299. popd
  300. cd ..
  301. mkdir -p templates
  302. rm -f templates/android*
  303. cp godot-android/bin/android_debug.apk templates
  304. cp godot-android/bin/android_release.apk templates
  305. }
  306. function javascript {
  307. source /home/hp//Apps/emsdk-portable/emsdk_env.sh
  308. export EMSCRIPTEN_ROOT="/home/hp/Apps/emsdk-portable/emscripten/1.38.4"
  309. export EM_CONFIG=/home/hp/.emscripten
  310. export SCONS="/usr/bin/scons -j8 verbose=no warnings=no progress=no"
  311. export OPTIONS="builtin_libpng=yes builtin_openssl=yes builtin_zlib=yes gdnative_wrapper=yes debug_symbols=no"
  312. rm -rf godot-javascript
  313. git clone https://github.com/godotengine/godot.git godot-javascript
  314. cd godot-javascript
  315. git checkout -b 3.0 origin/3.0 || git checkout 3.0
  316. git branch --set-upstream-to=origin/3.0 3.0
  317. git reset --hard
  318. git pull
  319. $SCONS platform=javascript target=release_debug tools=no ${OPTIONS}
  320. $SCONS platform=javascript target=release tools=no ${OPTIONS}
  321. cd ..
  322. mkdir -p templates
  323. rm -f templates/webassembly*
  324. cp godot-javascript/bin/godot.javascript.opt.zip templates/webassembly_release.zip
  325. cp godot-javascript/bin/godot.javascript.opt.debug.zip templates/webassembly_debug.zip
  326. }
  327. $3 2>&1 | tee build-godot-$3.log