Browse Source

[c] Improved build.sh

- release builds
- --help flag
Mario Zechner 2 tháng trước cách đây
mục cha
commit
d5947d45a1
1 tập tin đã thay đổi với 35 bổ sung2 xóa
  1. 35 2
      spine-c/build.sh

+ 35 - 2
spine-c/build.sh

@@ -3,6 +3,33 @@ set -e
 
 cd "$(dirname "$0")"
 
+# Display help information
+show_help() {
+    echo "spine-c build script"
+    echo ""
+    echo "Usage: ./build.sh [option]"
+    echo ""
+    echo "Options:"
+    echo "  --help, -h    Show this help message"
+    echo "  codegen       Run code generation to regenerate C bindings from C++ sources"
+    echo "  clean         Clean build directory before building"
+    echo "  release       Build in release mode (default is debug)"
+    echo "  (no option)   Build the project in debug mode (default)"
+    echo ""
+    echo "Examples:"
+    echo "  ./build.sh              # Build debug version"
+    echo "  ./build.sh release      # Build release version"
+    echo "  ./build.sh clean        # Clean and rebuild debug"
+    echo "  ./build.sh codegen      # Regenerate C bindings"
+    echo "  ./build.sh --help       # Show this help"
+    exit 0
+}
+
+# Check for help flag
+if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
+    show_help
+fi
+
 # Run codegen if requested
 if [ "$1" = "codegen" ]; then
     npx tsx codegen/src/index.ts
@@ -14,6 +41,12 @@ if [ "$1" = "clean" ]; then
     rm -rf build
 fi
 
+# Determine build type
+BUILD_TYPE="debug"
+if [ "$1" = "release" ]; then
+    BUILD_TYPE="release"
+fi
+
 # Always build
-cmake --preset=debug .
-cmake --build --preset=debug
+cmake --preset=$BUILD_TYPE .
+cmake --build --preset=$BUILD_TYPE