build-godot.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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.x11.opt.tools.64 Godot_v${GODOT_VERSION}_x11.64
  100. zip -q -9 Godot_v${GODOT_VERSION}_x11.64.zip Godot_v${GODOT_VERSION}_x11.64
  101. mv Godot_v${GODOT_VERSION}_x11.64.zip release-${GODOT_VERSION}
  102. rm Godot_v${GODOT_VERSION}_x11.64
  103. mkdir -p mono/release-${GODOT_VERSION}
  104. rm -f mono/release-${GODOT_VERSION}/*linux*64*
  105. mkdir -p Godot_v${GODOT_VERSION}_mono_x11_64
  106. cp godot-ubuntu-64/godot.x11.opt.tools.64.mono Godot_v${GODOT_VERSION}_mono_x11_64/Godot_v${GODOT_VERSION}_mono_x11.64
  107. cp godot-ubuntu-64/*.dll Godot_v${GODOT_VERSION}_mono_x11_64
  108. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_x11_64.zip Godot_v${GODOT_VERSION}_mono_x11_64
  109. mv Godot_v${GODOT_VERSION}_mono_x11_64.zip mono/release-${GODOT_VERSION}
  110. rm -rf Godot_v${GODOT_VERSION}_mono_x11_64
  111. mkdir -p mono/templates
  112. rm -f mono/templates/*linux*64*
  113. cp godot-ubuntu-64/godot.x11.opt.debug.64.mono mono/templates/linux_x11_64_debug
  114. cp godot-ubuntu-64/godot.x11.opt.64.mono mono/templates/linux_x11_64_release
  115. }
  116. function uwp {
  117. boot-domain godot-win10
  118. mkdir -p godot-uwp
  119. scp $SSHOPTS build-godot-uwp.bat user@${ip}:
  120. scp $SSHOPTS -r mono-glue user@${ip}:
  121. ssh $SSHOPTS user@${ip} build-godot-uwp.bat
  122. scp $SSHOPTS -r user@${ip}:binaries/* godot-uwp
  123. ssh $SSHOPTS user@${ip} "shutdown /s /t 0" || /bin/true
  124. mkdir -p templates
  125. rm -f templates/uwp*
  126. rm -rf angle*
  127. wget -c https://github.com/GodotBuilder/godot-builds/releases/download/_tools/angle.7z
  128. 7z x angle.7z
  129. rm -rf uwp_template_*
  130. for arch in ARM Win32 x64; do
  131. cp -r godot-mono-glue/misc/dist/uwp_template uwp_template_${arch}
  132. cp angle/winrt/10/src/Release_${arch}/libEGL.dll \
  133. angle/winrt/10/src/Release_${arch}/libGLESv2.dll \
  134. uwp_template_${arch}/
  135. cp -r uwp_template_${arch} uwp_template_${arch}_debug
  136. done
  137. # ARM
  138. cp godot-uwp/uwp_arm/godot.uwp.opt.32.arm.exe uwp_template_ARM/godot.uwp.exe
  139. cp godot-uwp/uwp_arm/godot.uwp.opt.debug.32.arm.exe uwp_template_ARM_debug/godot.uwp.exe
  140. cd uwp_template_ARM && zip -q -9 -r ../templates/uwp_arm_release.zip * && cd ..
  141. cd uwp_template_ARM_debug && zip -q -9 -r ../templates/uwp_arm_debug.zip * && cd ..
  142. # Win32
  143. cp godot-uwp/uwp_x86/godot.uwp.opt.32.x86.exe uwp_template_Win32/godot.uwp.exe
  144. cp godot-uwp/uwp_x86/godot.uwp.opt.debug.32.x86.exe uwp_template_Win32_debug/godot.uwp.exe
  145. cd uwp_template_Win32 && zip -q -9 -r ../templates/uwp_x86_release.zip * && cd ..
  146. cd uwp_template_Win32_debug && zip -q -9 -r ../templates/uwp_x86_debug.zip * && cd ..
  147. # x64
  148. cp godot-uwp/uwp_amd64/godot.uwp.opt.64.x64.exe uwp_template_x64/godot.uwp.exe
  149. cp godot-uwp/uwp_amd64/godot.uwp.opt.debug.64.x64.exe uwp_template_x64_debug/godot.uwp.exe
  150. cd uwp_template_x64 && zip -q -9 -r ../templates/uwp_x64_release.zip * && cd ..
  151. cd uwp_template_x64_debug && zip -q -9 -r ../templates/uwp_x64_debug.zip * && cd ..
  152. rm -rf uwp_template_*
  153. }
  154. function windows {
  155. mkdir -p godot-windows
  156. boot-domain godot-fedora28
  157. scp $SSHOPTS build-godot-windows.sh user@${ip}:~/build-godot.sh
  158. scp $SSHOPTS -r mono-glue user@${ip}:~/
  159. ssh $SSHOPTS user@${ip} bash build-godot.sh ${MONO_VERSION}
  160. scp $SSHOPTS user@${ip}:~/godot/bin/* godot-windows
  161. ssh $SSHOPTS user@${ip} sudo shutdown -h now || /bin/true
  162. mkdir -p release-${GODOT_VERSION}
  163. rm -f release-${GODOT_VERSION}/*win*zip
  164. cp godot-windows/godot.windows.opt.tools.64.exe Godot_v${GODOT_VERSION}_win64.exe
  165. strip Godot_v${GODOT_VERSION}_win64.exe
  166. zip -q -9 Godot_v${GODOT_VERSION}_win64.exe.zip Godot_v${GODOT_VERSION}_win64.exe
  167. mv Godot_v${GODOT_VERSION}_win64.exe.zip release-${GODOT_VERSION}
  168. rm Godot_v${GODOT_VERSION}_win64.exe
  169. cp godot-windows/godot.windows.opt.tools.32.exe Godot_v${GODOT_VERSION}_win32.exe
  170. strip Godot_v${GODOT_VERSION}_win32.exe
  171. zip -q -9 Godot_v${GODOT_VERSION}_win32.exe.zip Godot_v${GODOT_VERSION}_win32.exe
  172. mv Godot_v${GODOT_VERSION}_win32.exe.zip release-${GODOT_VERSION}
  173. rm Godot_v${GODOT_VERSION}_win32.exe
  174. mkdir -p templates
  175. rm -rf templates/*win*
  176. cp godot-windows/godot.windows.opt.64.exe templates/windows_64_release.exe
  177. cp godot-windows/godot.windows.opt.debug.64.exe templates/windows_64_debug.exe
  178. cp godot-windows/godot.windows.opt.32.exe templates/windows_32_release.exe
  179. cp godot-windows/godot.windows.opt.debug.32.exe templates/windows_32_debug.exe
  180. strip templates/windows*.exe
  181. mkdir -p mono/release-${GODOT_VERSION}
  182. rm -f mono/release-${GODOT_VERSION}/*win*
  183. mkdir -p mono/templates
  184. rm -f mono/templates/*win*
  185. # Win32
  186. mkdir -p Godot_v${GODOT_VERSION}_mono_win32
  187. cp godot-windows/godot.windows.opt.tools.32.mono.exe Godot_v${GODOT_VERSION}_mono_win32/Godot_v${GODOT_VERSION}_mono_win32.exe
  188. strip Godot_v${GODOT_VERSION}_mono_win32/Godot_v${GODOT_VERSION}_mono_win32.exe
  189. cp godot-windows/*.dll Godot_v${GODOT_VERSION}_mono_win32
  190. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_win32.zip Godot_v${GODOT_VERSION}_mono_win32
  191. mv Godot_v${GODOT_VERSION}_mono_win32.zip mono/release-${GODOT_VERSION}
  192. rm -rf Godot_v${GODOT_VERSION}_mono_win32
  193. cp godot-windows/godot.windows.opt.debug.32.mono.exe mono/templates/windows_32_debug.exe
  194. cp godot-windows/godot.windows.opt.32.mono.exe mono/templates/windows_32_release.exe
  195. # x64
  196. mkdir -p Godot_v${GODOT_VERSION}_mono_win64
  197. cp godot-windows/godot.windows.opt.tools.64.mono.exe Godot_v${GODOT_VERSION}_mono_win64/Godot_v${GODOT_VERSION}_mono_win64.exe
  198. strip Godot_v${GODOT_VERSION}_mono_win64/Godot_v${GODOT_VERSION}_mono_win64.exe
  199. cp godot-windows/*.dll Godot_v${GODOT_VERSION}_mono_win64
  200. zip -r -q -9 Godot_v${GODOT_VERSION}_mono_win64.zip Godot_v${GODOT_VERSION}_mono_win64
  201. mv Godot_v${GODOT_VERSION}_mono_win64.zip mono/release-${GODOT_VERSION}
  202. rm -rf Godot_v${GODOT_VERSION}_mono_win64
  203. cp godot-windows/godot.windows.opt.debug.64.mono.exe mono/templates/windows_64_debug.exe
  204. cp godot-windows/godot.windows.opt.64.mono.exe mono/templates/windows_64_release.exe
  205. strip mono/templates/windows*.exe
  206. }
  207. function macos {
  208. echo "booting macosx"
  209. mkdir -p godot-macosx
  210. sudo bash /media/disk2/hp/macosx/OSX-KVM/godot.sh || /bin/true
  211. while ! tcping -t 1 192.168.112.137 22 &>/dev/null; do
  212. sleep 1
  213. done
  214. sleep 30s
  215. scp $SSHOPTS build-godot-macosx.sh hp@192.168.112.137:~/build-godot.sh
  216. scp $SSHOPTS -r mono-glue hp@192.168.112.137:~/
  217. ssh $SSHOPTS hp@192.168.112.137 bash build-godot.sh ${MONO_VERSION}
  218. scp $SSHOPTS hp@192.168.112.137:~/godot/bin/* godot-macosx
  219. ssh $SSHOPTS hp@192.168.112.137 sudo shutdown -h now || /bin/true
  220. mkdir -p templates
  221. rm -f templates/osx*
  222. rm -f templates/iphone*
  223. rm -rf osx_template
  224. mkdir -p osx_template
  225. cd osx_template
  226. cp -r ../godot-mono-glue/misc/dist/osx_template.app .
  227. mkdir osx_template.app/Contents/MacOS
  228. cp ../godot-macosx/godot.osx.opt.fat osx_template.app/Contents/MacOS/godot_osx_release.fat
  229. cp ../godot-macosx/godot.osx.opt.debug.fat osx_template.app/Contents/MacOS/godot_osx_debug.fat
  230. chmod +x osx_template.app/Contents/MacOS/godot_osx*
  231. zip -q -9 -r osx.zip osx_template.app
  232. cd ..
  233. mv osx_template/osx.zip templates
  234. rm -rf osx_template
  235. cp -r godot-mono-glue/misc/dist/ios_xcode ios_xcode
  236. cp godot-macosx/libgodot.iphone.opt.fat ios_xcode/libgodot.iphone.release.fat.a
  237. cp godot-macosx//libgodot.iphone.opt.debug.fat ios_xcode/libgodot.iphone.debug.fat.a
  238. chmod +x ios_xcode/libgodot.iphone.*
  239. cd ios_xcode
  240. zip -q -9 -r ../templates/iphone.zip *
  241. cd ..
  242. rm -rf ios_xcode
  243. mkdir -p release-${GODOT_VERSION}
  244. rm -f release-${GODOT_VERSION}/*osx*
  245. cp -r godot-mono-glue/misc/dist/osx_tools.app Godot.app
  246. mkdir -p Godot.app/Contents/MacOS
  247. cp godot-macosx/godot.osx.opt.tools.fat Godot.app/Contents/MacOS/Godot
  248. chmod +x Godot.app/Contents/MacOS/Godot
  249. zip -q -9 -r "release-${GODOT_VERSION}/Godot_v${GODOT_VERSION}_osx.fat.zip" Godot.app
  250. rm -rf Godot.app
  251. mkdir -p mono/templates
  252. rm -f mono/templates/osx*
  253. rm -rf osx_template
  254. mkdir -p osx_template
  255. cd osx_template
  256. cp -r ../godot-mono-glue/misc/dist/osx_template.app .
  257. mkdir osx_template.app/Contents/MacOS
  258. cp ../godot-macosx/godot.osx.opt.fat.mono osx_template.app/Contents/MacOS/godot_osx_release.fat
  259. cp ../godot-macosx/godot.osx.opt.debug.fat.mono osx_template.app/Contents/MacOS/godot_osx_debug.fat
  260. chmod +x osx_template.app/Contents/MacOS/godot_osx*
  261. zip -q -9 -r osx.zip osx_template.app
  262. cd ..
  263. mv osx_template/osx.zip mono/templates
  264. rm -rf osx_template
  265. mkdir -p mono/release-${GODOT_VERSION}
  266. rm -f mono/release-${GODOT_VERSION}/*osx*
  267. cp -r godot-mono-glue/misc/dist/osx_tools.app Godot_mono.app
  268. mkdir -p Godot_mono.app/Contents/MacOS
  269. cp godot-macosx/godot.osx.opt.tools.fat.mono Godot_mono.app/Contents/MacOS/Godot
  270. cp godot-macosx/*.dll Godot_mono.app/Contents/MacOS/
  271. chmod +x Godot_mono.app/Contents/MacOS/Godot
  272. zip -q -9 -r "mono/release-${GODOT_VERSION}/Godot_v${GODOT_VERSION}_mono_osx.fat.zip" Godot_mono.app
  273. rm -rf Godot_mono.app
  274. }
  275. function android {
  276. export ANDROID_HOME=/home/hp/Apps/android/sdk/
  277. export ANDROID_NDK_ROOT=/home/hp/Apps/android/android-ndk-r16b
  278. export SCONS="/usr/bin/scons -j8 verbose=no warnings=no progress=no"
  279. export OPTIONS="builtin_libpng=yes builtin_openssl=yes builtin_zlib=yes gdnative_wrapper=yes debug_symbols=no"
  280. rm -rf godot-android
  281. git clone https://github.com/godotengine/godot.git godot-android
  282. cd godot-android
  283. git checkout -b 3.0 origin/3.0 || git checkout 3.0
  284. git branch --set-upstream-to=origin/3.0 3.0
  285. git reset --hard
  286. git pull
  287. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=armv7
  288. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=arm64v8
  289. $SCONS platform=android target=release_debug tools=no ${OPTIONS} android_arch=x86
  290. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=armv7
  291. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=arm64v8
  292. $SCONS platform=android target=release tools=no ${OPTIONS} android_arch=x86
  293. pushd platform/android/java
  294. ./gradlew build
  295. popd
  296. cd ..
  297. mkdir -p templates
  298. rm -f templates/android*
  299. cp godot-android/bin/android_debug.apk templates
  300. cp godot-android/bin/android_release.apk templates
  301. }
  302. function javascript {
  303. source /home/hp//Apps/emsdk-portable/emsdk_env.sh
  304. export EMSCRIPTEN_ROOT="/home/hp/Apps/emsdk-portable/emscripten/1.38.4"
  305. export EM_CONFIG=/home/hp/.emscripten
  306. export SCONS="/usr/bin/scons -j8 verbose=no warnings=no progress=no"
  307. export OPTIONS="builtin_libpng=yes builtin_openssl=yes builtin_zlib=yes gdnative_wrapper=yes debug_symbols=no"
  308. rm -rf godot-javascript
  309. git clone https://github.com/godotengine/godot.git godot-javascript
  310. cd godot-javascript
  311. git checkout -b 3.0 origin/3.0 || git checkout 3.0
  312. git branch --set-upstream-to=origin/3.0 3.0
  313. git reset --hard
  314. git pull
  315. $SCONS platform=javascript target=release_debug tools=no ${OPTIONS}
  316. $SCONS platform=javascript target=release tools=no ${OPTIONS}
  317. cd ..
  318. mkdir -p templates
  319. rm -f templates/webassembly*
  320. cp godot-javascript/bin/godot.javascript.opt.zip templates/webassembly_release.zip
  321. cp godot-javascript/bin/godot.javascript.opt.debug.zip templates/webassembly_debug.zip
  322. }
  323. $3 2>&1 | tee build-godot-$3.log