build-extension.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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-cpp ]; then
  6. echo "No godot-cpp clone found. Run ./setup-extension.sh <Godot branch or tag> <dev> first."
  7. exit 1
  8. fi
  9. options=""
  10. dev="false"
  11. raw_platform=${1%/} # Store the raw platform name before adding platform=
  12. platform="platform=$raw_platform" # Add platform= prefix
  13. arch=$2
  14. if [ -f "../godot-cpp/dev" ]; then
  15. dev="true"
  16. echo "DEV build"
  17. fi
  18. if [ $dev == "true" ]; then
  19. options="$options dev_build=true"
  20. fi
  21. if [ -z $raw_platform ]; then
  22. echo "Platform: current"
  23. platform=""
  24. else
  25. echo "Platform: $raw_platform"
  26. fi
  27. if [ ! -z "$arch" ]; then
  28. echo "Architecture: $arch"
  29. if [ "$raw_platform" == "linux" ] || [ "$raw_platform" == "android" ]; then
  30. options="$options arch=$arch"
  31. fi
  32. fi
  33. cpus=2
  34. if [ "$OSTYPE" == "msys" ]; then
  35. os="windows"
  36. cpus=$NUMBER_OF_PROCESSORS
  37. elif [[ "$OSTYPE" == "darwin"* ]]; then
  38. os="macos"
  39. cpus=$(sysctl -n hw.logicalcpu)
  40. if [ `uname -m` == "arm64" ]; then
  41. echo "Would do Apple Silicon specific setup"
  42. fi
  43. else
  44. os="linux"
  45. cpus=$(grep -c ^processor /proc/cpuinfo)
  46. fi
  47. echo "CPUS: $cpus"
  48. pushd ..
  49. if [ "$raw_platform" == "web" ]; then
  50. BINDIR="example-v4-extension/bin/web"
  51. mkdir -p $BINDIR
  52. # Build threaded versions
  53. echo "Building web with threads..."
  54. scons -j $cpus $options $platform target=template_debug
  55. scons -j $cpus $options $platform target=template_release
  56. # Build non-threaded versions
  57. echo "Building web without threads..."
  58. scons -j $cpus $options $platform target=template_debug threads=no
  59. scons -j $cpus $options $platform target=template_release threads=no
  60. else
  61. # Normal build process for other platforms
  62. if [ "$raw_platform" != "android" ] && [ "$raw_platform" != "ios" ] && [ "$raw_platform" != "web" ]; then
  63. scons -j $cpus $options $platform target=editor
  64. fi
  65. scons -j $cpus $options $platform target=template_debug
  66. scons -j $cpus $options $platform target=template_release
  67. fi
  68. popd
  69. popd