Path: blob/master/thirdparty/metal-cpp/update-metal-cpp.sh
21038 views
#!/bin/bash -e12# metal-cpp update script for Godot3#4# metal-cpp source: https://developer.apple.com/metal/cpp/5# This version includes Metal 4 APIs (macOS 26 / iOS 26).67VERSION="macOS26-iOS26"89SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"10REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"1112# If a zip is provided as argument, extract it13if [ -n "$1" ]; then14echo "Updating metal-cpp from: $1"1516rm -rf \17"$SCRIPT_DIR/Foundation" \18"$SCRIPT_DIR/Metal" \19"$SCRIPT_DIR/MetalFX" \20"$SCRIPT_DIR/QuartzCore" \21"$SCRIPT_DIR/SingleHeader"2223unzip -q "$1" -d "$SCRIPT_DIR"2425echo "Extracted metal-cpp $VERSION"26else27echo "Applying patches only..."28fi2930# =============================================================================31# Apply Godot-specific patches32# =============================================================================3334echo "Applying Godot compatibility patches..."3536# Apply patch files (idempotent)37PATCH_DIR="$SCRIPT_DIR/patches"38if [ -d "$PATCH_DIR" ]; then39for PATCH in "$PATCH_DIR"/*.patch; do40if [ ! -e "$PATCH" ]; then41echo " No patches found in $PATCH_DIR"42break43fi4445PATCH_NAME="$(basename "$PATCH")"46if git -C "$REPO_ROOT" apply --check "$PATCH" > /dev/null 2>&1; then47git -C "$REPO_ROOT" apply "$PATCH"48echo " $PATCH_NAME: applied"49elif git -C "$REPO_ROOT" apply --reverse --check "$PATCH" > /dev/null 2>&1; then50echo " $PATCH_NAME: already applied"51else52echo " $PATCH_NAME: failed to apply"53exit 154fi55done56else57echo " Warning: $PATCH_DIR not found"58fi5960# Patch 1: Add forward declarations to NSDefines.hpp to avoid conflicts with61# Godot's global types (String, Object, Error).62#63# Without this patch, metal-cpp's "class String*" forward declarations conflict64# with Godot's ::String, ::Object, and ::Error types.6566NSDEFINES="$SCRIPT_DIR/Foundation/NSDefines.hpp"6768if [ -f "$NSDEFINES" ]; then69# Check if patch already applied70if grep -q "Forward declarations to avoid conflicts with Godot" "$NSDEFINES"; then71echo " NSDefines.hpp: already patched"72else73# Find the line with #pragma once and insert after the next separator74sed -i '' '/^#pragma once$/,/^\/\/---/{75/^\/\/---/ {76a\77\78// Forward declarations to avoid conflicts with Godot types (String, Object, Error)\79namespace NS {\80class Array;\81class Dictionary;\82class Error;\83class Object;\84class String;\85class URL;\86} // namespace NS87}88}' "$NSDEFINES"89echo " NSDefines.hpp: patched"90fi91else92echo " Warning: $NSDEFINES not found"93fi9495echo "Done."969798