setup-extension.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. set -e
  3. dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  4. pushd "$dir" > /dev/null
  5. if [ $# -lt 2 ] || [ $# -gt 3 ]; then
  6. echo "Usage: ./setup-extension.sh <Godot version> <dev:true|false>"
  7. echo
  8. echo "e.g.:"
  9. echo " ./setup-extension.sh 4.2.2-stable true"
  10. exit 1
  11. fi
  12. godot_branch=${1%/}
  13. dev=${2%/}
  14. mono=false
  15. godot_cpp_repo=https://github.com/godotengine/godot-cpp.git
  16. godot_repo=https://github.com/godotengine/godot.git
  17. if [[ $# -eq 3 ]]; then
  18. mono=${3%/}
  19. fi
  20. if [ "$dev" != "true" ] && [ "$dev" != "false" ]; then
  21. echo "Invalid value for the 'dev' argument. It should be either 'true' or 'false'."
  22. exit 1
  23. fi
  24. if [ "$mono" != "true" ] && [ "$mono" != "false" ]; then
  25. echo "Invalid value for the 'mono' argument. It should be either 'true' or 'false'."
  26. exit 1
  27. fi
  28. godot_cpp_branch=$(echo $godot_branch | cut -d. -f1-2 | cut -d- -f1)
  29. cpus=2
  30. if [ "$OSTYPE" == "msys" ]; then
  31. cpus=$NUMBER_OF_PROCESSORS
  32. elif [[ "$OSTYPE" == "darwin"* ]]; then
  33. cpus=$(sysctl -n hw.logicalcpu)
  34. else
  35. cpus=$(grep -c ^processor /proc/cpuinfo)
  36. fi
  37. echo "godot-cpp branch: $godot_cpp_branch"
  38. echo "godot branch: $godot_branch"
  39. echo "dev: $dev"
  40. echo "mono: $mono"
  41. echo "cpus: $cpus"
  42. pushd ..
  43. rm -rf godot-cpp
  44. git clone --depth 1 $godot_cpp_repo -b $godot_cpp_branch
  45. rm -rf example-v4-extension/bin
  46. mkdir -p example-v4-extension/bin
  47. if [ $dev == "true" ]; then
  48. echo "Dev build, creating godot-cpp/dev"
  49. touch godot-cpp/dev
  50. rm -rf godot
  51. git clone --depth 1 $godot_repo -b $godot_branch
  52. pushd godot
  53. scons target=editor dev_build=true optimize=debug --jobs=$cpus
  54. popd
  55. fi
  56. cp spine_godot_extension.gdextension example-v4-extension/bin
  57. cp -r ../spine-cpp/spine-cpp spine_godot
  58. popd
  59. popd > /dev/null