build.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.sh <target>"
  7. echo
  8. echo "e.g.:"
  9. echo " ./build.sh release_debug"
  10. echo " ./build.sh debug"
  11. echo
  12. exit 1
  13. fi
  14. if [ ! -d ../godot ]; then
  15. echo "No Godot clone found. Run ./setup.sh <Godot branch or tag> <dev> first."
  16. exit 1
  17. fi
  18. target="target=${1%/}"
  19. dev="false"
  20. if [ -f "../godot/custom.py" ]; then
  21. dev="true"
  22. fi
  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. echo "CPUS: $cpus"
  32. pushd ../godot
  33. if [ `uname` == 'Darwin' ] && [ $dev = "false" ]; then
  34. scons $target arch=x86_64 compiledb=yes custom_modules="../spine_godot" --jobs=$cpus
  35. scons $target arch=arm64 compiledb=yes custom_modules="../spine_godot" --jobs=$cpus
  36. pushd bin
  37. cp -r ../misc/dist/osx_tools.app .
  38. mv osx_tools.app Godot.app
  39. mkdir -p Godot.app/Contents/MacOS
  40. if [ "$target" = "debug" ]; then
  41. lipo -create godot.osx.tools.x86_64 godot.osx.tools.arm64 -output godot.osx.tools.universal
  42. strip -S -x godot.osx.tools.universal
  43. cp godot.osx.tools.universal Godot.app/Contents/MacOS/Godot
  44. else
  45. lipo -create godot.osx.opt.tools.x86_64 godot.osx.opt.tools.arm64 -output godot.osx.opt.tools.universal
  46. strip -S -x godot.osx.opt.tools.universal
  47. cp godot.osx.opt.tools.universal Godot.app/Contents/MacOS/Godot
  48. fi
  49. chmod +x Godot.app/Contents/MacOS/Godot
  50. popd
  51. else
  52. if [ "$OSTYPE" = "msys" ]; then
  53. target="$target vsproj=yes livepp=$LIVEPP"
  54. fi
  55. scons $target compiledb=yes custom_modules="../spine_godot" --jobs=$cpus
  56. cp compile_commands.json ../build
  57. if [ -f "bin/godot.x11.opt.tools.64" ]; then
  58. strip bin/godot.x11.opt.tools.64
  59. chmod a+x bin/godot.x11.opt.tools.64
  60. fi
  61. fi
  62. popd
  63. popd > /dev/null