build-v4.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. set -e
  3. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  4. pushd "$dir" > /dev/null
  5. if [ ! -d ../godot ]; then
  6. echo "No Godot clone found. Run ./setup.sh <Godot branch or tag> <dev> first."
  7. exit 1
  8. fi
  9. target=""
  10. dev="false"
  11. mono="false"
  12. if [ $# -gt 0 ]; then
  13. if [ $# -gt 1 ]; then
  14. echo "Usage: $0 <mono:true|false>"
  15. exit 1
  16. else
  17. if [ "$1" == "true" ] || [ "$1" == "false" ]; then
  18. mono="$1"
  19. else
  20. echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'."
  21. exit 1
  22. fi
  23. fi
  24. fi
  25. if [ -f "../godot/custom.py" ]; then
  26. dev="true"
  27. echo "DEV build"
  28. fi
  29. mono_module=""
  30. mono_extension=""
  31. if [ $mono == "true" ]; then
  32. mono_module="module_mono_enabled=yes"
  33. mono_extension=".mono"
  34. echo "Building Godot with C# support"
  35. else
  36. echo "Building Godot without C# support"
  37. fi
  38. dev_extension=""
  39. if [ $dev == "true" ]; then
  40. dev_extension=".dev"
  41. target="$target dev_build=true"
  42. fi
  43. cpus=2
  44. if [ "$OSTYPE" == "msys" ]; then
  45. os="windows"
  46. cpus=$NUMBER_OF_PROCESSORS
  47. target="$target"
  48. godot_exe="godot.windows.editor$dev_extension.x86_64$mono_extension.exe"
  49. godot_exe_host=$godot_exe
  50. elif [[ "$OSTYPE" == "darwin"* ]]; then
  51. os="macos"
  52. cpus=$(sysctl -n hw.logicalcpu)
  53. godot_exe="godot.macos.editor$dev_extension.x86_64$mono_extension"
  54. godot_exe_arm="godot.macos.editor$dev_extension.arm64$mono_extension"
  55. godot_exe_host=$godot_exe
  56. if [ `uname -m` == "arm64" ]; then
  57. godot_exe_host=$godot_exe_arm
  58. fi
  59. else
  60. os="linux"
  61. cpus=$(grep -c ^processor /proc/cpuinfo)
  62. godot_exe="godot.linuxbsd.editor$dev_extension.x86_64$mono_extension"
  63. godot_exe_host=$godot_exe
  64. fi
  65. echo "CPUS: $cpus"
  66. pushd ../godot
  67. if [ "$os" == "macos" ] && [ $dev == "false" ]; then
  68. scons $target $mono_module arch=x86_64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus
  69. scons $target $mono_module arch=arm64 compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus
  70. if [ $mono == "true" ]; then
  71. echo "Building C# glue and assemblies."
  72. "./bin/$godot_exe_host" --generate-mono-glue modules/mono/glue
  73. python3 ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-spine-csharp
  74. fi
  75. pushd bin
  76. cp -r ../misc/dist/macos_tools.app .
  77. mv macos_tools.app Godot.app
  78. mkdir -p Godot.app/Contents/MacOS
  79. lipo -create $godot_exe_arm $godot_exe -output Godot
  80. strip -S -x Godot
  81. cp Godot Godot.app/Contents/MacOS/Godot
  82. chmod +x Godot.app/Contents/MacOS/Godot
  83. if [ $mono == "true" ]; then
  84. cp -r GodotSharp Godot.app/Contents/Resources
  85. fi
  86. popd
  87. else
  88. scons $target $mono_module compiledb=yes custom_modules="../spine_godot" opengl3=yes --jobs=$cpus
  89. if [ $mono == "true" ]; then
  90. echo "Building C# glue and assemblies."
  91. "./bin/$godot_exe_host" --headless --generate-mono-glue modules/mono/glue
  92. python3 ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local ../godot-nuget
  93. fi
  94. cp compile_commands.json ../build
  95. if [ -f "bin/godot.linuxbsd.editor.x86_64$mono_extension" ]; then
  96. strip bin/godot.linuxbsd.editor.x86_64$mono_extension
  97. chmod a+x bin/godot.linuxbsd.editor.x86_64$mono_extension
  98. fi
  99. fi
  100. popd
  101. popd > /dev/null