setup_sdk_dev.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
  4. DERIVED_BASE="$ROOT_DIR/.deriveddata"
  5. log() {
  6. printf '[setup] %s\n' "$1"
  7. }
  8. require_cmd() {
  9. if ! command -v "$1" >/dev/null 2>&1; then
  10. echo "Missing required command: $1" >&2
  11. exit 1
  12. fi
  13. }
  14. require_cmd xcodebuild
  15. require_cmd xcrun
  16. log "Using developer dir: $(xcode-select -p)"
  17. log "Xcode version: $(xcodebuild -version | tr '\n' ' ' | sed 's/ */ /g')"
  18. if xcrun --find metal >/dev/null 2>&1; then
  19. METAL_BIN="$(xcrun --find metal)"
  20. if "$METAL_BIN" -v >/dev/null 2>&1; then
  21. log "Metal toolchain is ready: $METAL_BIN"
  22. else
  23. log "Metal toolchain is not ready, downloading component..."
  24. xcodebuild -downloadComponent MetalToolchain
  25. if ! "$METAL_BIN" -v >/dev/null 2>&1; then
  26. echo "Metal toolchain is still unavailable. Run Xcode once and retry." >&2
  27. exit 1
  28. fi
  29. log "Metal toolchain installed successfully."
  30. fi
  31. else
  32. log "metal command is missing, downloading component..."
  33. xcodebuild -downloadComponent MetalToolchain
  34. fi
  35. mkdir -p "$DERIVED_BASE/objc" "$DERIVED_BASE/swift"
  36. log "DerivedData folders prepared under $DERIVED_BASE"
  37. xcodebuild -project "$ROOT_DIR/QGVAPlayer/QGVAPlayer.xcodeproj" -list >/dev/null
  38. xcodebuild -project "$ROOT_DIR/QGVAPlayerDemo/QGVAPlayerDemo.xcodeproj" -list >/dev/null
  39. xcodebuild -project "$ROOT_DIR/QGVAPlayerDemoSwift/QGVAPlayerDemoSwift.xcodeproj" -list >/dev/null
  40. log "SDK dev environment check complete."
  41. log "Next: run scripts/dev/build_demo.sh all"