Files
video-orchestra/build_macos.sh

113 lines
3.2 KiB
Bash
Raw Permalink Normal View History

2025-09-15 00:17:01 +09:00
#!/bin/bash
# Video Orchestra - macOS Build Script
# Builds and copies libvpx.dylib to lib/macos directory for Godot integration
set -e
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LIB_MACOS_DIR="${PROJECT_ROOT}/lib/macos"
GODOT_LIB_DIR="${PROJECT_ROOT}/godot-project/.godot/mono/temp/bin/Debug"
echo "Video Orchestra - macOS Build Script"
echo "Project Root: ${PROJECT_ROOT}"
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if Homebrew is installed
if ! command_exists brew; then
echo "Error: Homebrew is not installed. Please install Homebrew first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
# Check if libvpx is installed via Homebrew
if ! brew list libvpx >/dev/null 2>&1; then
echo "Installing libvpx via Homebrew..."
brew install libvpx
else
echo "libvpx is already installed via Homebrew"
fi
# Get libvpx installation path
LIBVPX_PATH="$(brew --prefix libvpx)"
echo "libvpx installation path: ${LIBVPX_PATH}"
# Check if libvpx.dylib exists
LIBVPX_DYLIB="${LIBVPX_PATH}/lib/libvpx.dylib"
if [[ ! -f "${LIBVPX_DYLIB}" ]]; then
echo "Error: libvpx.dylib not found at ${LIBVPX_DYLIB}"
exit 1
fi
echo "Found libvpx.dylib: ${LIBVPX_DYLIB}"
# Create lib/macos directory
echo "Creating lib/macos directory..."
mkdir -p "${LIB_MACOS_DIR}"
# Copy libvpx.dylib to lib/macos
echo "Copying libvpx.dylib to ${LIB_MACOS_DIR}..."
cp "${LIBVPX_DYLIB}" "${LIB_MACOS_DIR}/"
# Also copy to Godot build output directory if it exists
if [[ -d "${GODOT_LIB_DIR}" ]]; then
echo "Copying libvpx.dylib to Godot build directory..."
cp "${LIBVPX_DYLIB}" "${GODOT_LIB_DIR}/"
fi
# Verify the copy
if [[ -f "${LIB_MACOS_DIR}/libvpx.dylib" ]]; then
echo "✅ Successfully copied libvpx.dylib to lib/macos/"
# Show library info
echo ""
echo "Library Information:"
file "${LIB_MACOS_DIR}/libvpx.dylib"
echo ""
otool -L "${LIB_MACOS_DIR}/libvpx.dylib" | head -5
else
echo "❌ Failed to copy libvpx.dylib"
exit 1
fi
# Update deps.json if it exists
DEPS_JSON="${GODOT_LIB_DIR}/VideoOrchestra.deps.json"
if [[ -f "${DEPS_JSON}" ]]; then
echo ""
echo "Updating deps.json to reference libvpx.dylib..."
# Create a backup
cp "${DEPS_JSON}" "${DEPS_JSON}.backup"
# Update deps.json to reference the copied library
if grep -q '"native"' "${DEPS_JSON}"; then
echo "deps.json already contains native library references"
else
# Add native library reference
sed -i '' 's/"runtime": {/"runtime": {\
"VideoOrchestra.dll": {}\
},\
"native": {\
"libvpx.dylib": {}/g' "${DEPS_JSON}"
echo "Added native library reference to deps.json"
fi
fi
echo ""
echo "🎉 macOS build completed successfully!"
echo ""
echo "Files created:"
echo " - ${LIB_MACOS_DIR}/libvpx.dylib"
if [[ -f "${GODOT_LIB_DIR}/libvpx.dylib" ]]; then
echo " - ${GODOT_LIB_DIR}/libvpx.dylib"
fi
echo ""
echo "Next steps:"
echo " 1. Open Godot project and rebuild C# assembly"
echo " 2. Run the VP9 test to verify libvpx integration"
echo " 3. If needed, run this script again after Godot rebuilds"