Skip to content

Instantly share code, notes, and snippets.

@dcvz
Last active March 10, 2025 21:22
Show Gist options
  • Save dcvz/a2129372537f17b95b1f1e3e694ca6d9 to your computer and use it in GitHub Desktop.
Save dcvz/a2129372537f17b95b1f1e3e694ca6d9 to your computer and use it in GitHub Desktop.
ZeldaRecomp macOS build & run script
#!/bin/bash
# ==============================================
# Zelda64Recompiled macOS Build & Run Script
# ==============================================
#
# Prerequisites:
# 1. Install pkgx: curl -fsS https://pkgx.sh | sh
# 2. Install Xcode from the Mac App Store
#
# Usage:
# ./run-macos.sh
#
# Notes:
# - This script will build in Debug mode
# - Required dependencies (ninja, SDL2, FreeType, LLVM) will be handled by pkgx
# ==============================================
# Run CMake configure command with pkgx managing dependencies
pkgx +ninja +libsdl.org@2 +freetype.org +llvm.org cmake \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DFREETYPE_LIBRARY=$(pkgx +freetype.org pkg-config --variable=libdir freetype2)/libfreetype.dylib \
-DFREETYPE_INCLUDE_DIRS=$(pkgx +freetype.org pkg-config --variable=includedir freetype2)/freetype2 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang \
-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ \
-DPATCHES_LD=$(pkgx +llvm.org which ld.lld) \
-DPATCHES_OBJCOPY=$(pkgx +llvm.org which llvm-objcopy) \
-DCMAKE_AR=$(pkgx +llvm.org which llvm-ar) \
-DPATCHES_C_COMPILER=$(pkgx +llvm.org which clang) \
-DRT64_BUILD_EXAMPLES=ON \
--no-warn-unused-cli \
-H. \
-Bbuild \
-G Ninja
# Run CMake build command
pkgx +ninja cmake --build build --config Debug
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi
echo "Build successful! Starting debugger..."
echo "Type 'run' at the (lldb) prompt to start the game"
echo "Type 'bt' if the game crashes to see the backtrace"
echo "Type 'quit' to exit LLDB"
# Run the compiled application
lldb -- ./build/Zelda64Recompiled.app/Contents/MacOS/Zelda64Recompiled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment