Repository navigation
android build fix #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: macOS version | |
| on: | |
| push: | |
| branches: [master, SDL3] | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| SDL3_VER: release-3.4.10 | |
| SDL3_TTF_VER: release-3.2.2 | |
| SDL3_IMAGE_VER: release-3.4.6 | |
| SDL3_MIXER_VER: release-3.2.4 | |
| LUAJIT_REV: v2.1 | |
| jobs: | |
| build: | |
| name: macOS ${{ matrix.arch }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: macos-15-intel, arch: x86_64, deployment: "10.13" } | |
| - { os: macos-15, arch: arm64, deployment: "11.0" } | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Packages | |
| run: brew install ninja cmake pkg-config | |
| - name: Cache SDL3 | |
| id: cache-sdl | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ runner.temp }}/prefix | |
| key: ${{ runner.os }}-${{ matrix.arch }}-sdl3-${{ env.SDL3_VER }}-${{ env.SDL3_TTF_VER }}-${{ env.SDL3_IMAGE_VER }}-${{ env.SDL3_MIXER_VER }}-${{ matrix.deployment }} | |
| - name: Build SDL3 | |
| if: steps.cache-sdl.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| PREFIX="$RUNNER_TEMP/prefix" | |
| build() { | |
| name="$1"; tag="$2"; shift 2 | |
| git clone --depth 1 --recurse-submodules --shallow-submodules \ | |
| -b "$tag" "https://github.com/libsdl-org/$name.git" "/tmp/$name" | |
| cmake -S "/tmp/$name" -B "/tmp/$name/build" -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_INSTALL_PREFIX="$PREFIX" \ | |
| -DCMAKE_INSTALL_RPATH=@executable_path \ | |
| -DCMAKE_OSX_DEPLOYMENT_TARGET="${{ matrix.deployment }}" \ | |
| -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" "$@" | |
| cmake --build "/tmp/$name/build" | |
| cmake --install "/tmp/$name/build" | |
| } | |
| build SDL "$SDL3_VER" -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF | |
| build SDL_ttf "$SDL3_TTF_VER" -DSDLTTF_VENDORED=ON -DSDLTTF_SAMPLES=OFF -DSDLTTF_PLUTOSVG=OFF | |
| build SDL_image "$SDL3_IMAGE_VER" -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_SAMPLES=OFF -DSDLIMAGE_TESTS=OFF -DSDLIMAGE_AVIF=OFF -DSDLIMAGE_JXL=OFF -DSDLIMAGE_SVG=OFF | |
| build SDL_mixer "$SDL3_MIXER_VER" -DSDLMIXER_VENDORED=ON -DSDLMIXER_TESTS=OFF -DSDLMIXER_EXAMPLES=OFF -DSDLMIXER_GME=OFF -DSDLMIXER_MOD=ON -DSDLMIXER_MOD_XMP_SHARED=OFF -DSDLMIXER_MIDI=OFF -DSDLMIXER_WAVPACK=OFF -DSDLMIXER_MP3_MPG123=OFF | |
| - name: Cache LuaJIT | |
| id: cache-luajit | |
| uses: actions/cache@v6 | |
| with: | |
| path: luajit | |
| key: ${{ runner.os }}-${{ matrix.arch }}-luajit-${{ env.LUAJIT_REV }}-${{ matrix.deployment }} | |
| - name: Build LuaJIT | |
| if: steps.cache-luajit.outputs.cache-hit != 'true' | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment }} | |
| run: | | |
| set -e | |
| git clone --depth 1 --branch "$LUAJIT_REV" https://github.com/LuaJIT/LuaJIT.git luajit | |
| make -C luajit -j"$(sysctl -n hw.ncpu)" | |
| - name: Configure CMake | |
| run: | | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Release -DSTANDALONE=1 -DWITH_LUAJIT=1 \ | |
| -DCMAKE_PREFIX_PATH="$RUNNER_TEMP/prefix" \ | |
| -DCMAKE_INSTALL_RPATH=@executable_path \ | |
| -DCMAKE_OSX_DEPLOYMENT_TARGET="${{ matrix.deployment }}" \ | |
| -DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \ | |
| -DLUA_INCLUDE_DIR="$PWD/luajit/src" \ | |
| -DLUA_LIBRARY="$PWD/luajit/src/libluajit.a" | |
| - name: Build | |
| run: cmake --build build | |
| - name: Prepare runtime | |
| run: | | |
| set -e | |
| cmake --install build | |
| PREFIX="$RUNNER_TEMP/prefix" | |
| STAGE=build/standalone | |
| # the staged binary looks for the SDL libraries next to itself | |
| cp -a "$PREFIX"/lib/libSDL3*.dylib "$STAGE"/ | |
| LIBS=$(find "$STAGE" -maxdepth 1 -name 'libSDL3*.dylib' ! -type l) | |
| for f in "$STAGE/sdl-instead" $LIBS; do | |
| otool -L "$f" | tail -n +2 | awk '{print $1}' | while read -r dep; do | |
| case "$dep" in | |
| "$PREFIX"/*) | |
| install_name_tool -change "$dep" \ | |
| "@executable_path/$(basename "$dep")" "$f" ;; | |
| esac | |
| done | |
| codesign --force --sign - "$f" | |
| done | |
| echo "== dependencies:" | |
| otool -L "$STAGE/sdl-instead" | |
| if otool -L "$STAGE/sdl-instead" "$STAGE"/libSDL3*.dylib | grep -q "$PREFIX"; then | |
| echo "error: absolute dependencies on the build prefix" | |
| exit 1 | |
| fi | |
| - name: Test | |
| run: ctest --test-dir build --output-on-failure | |
| - name: Create Artifact | |
| run: | | |
| set -e | |
| VER=$(sed -n 's/^SET(INSTEAD_VERSION "\(.*\)")$/\1/p' CMakeLists.txt) | |
| APP=INSTEAD.app | |
| rm -rf "$APP" INSTEAD.icns icon.iconset | |
| mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" | |
| cp build/standalone/sdl-instead "$APP/Contents/MacOS/" | |
| cp -a build/standalone/libSDL3*.dylib "$APP/Contents/MacOS/" | |
| cp -R build/standalone/stead build/standalone/themes build/standalone/lang \ | |
| build/standalone/icon build/standalone/games "$APP/Contents/Resources/" | |
| # the engine changes cwd to Contents/Resources, so a bundle just works | |
| ICON_KEY="" | |
| mkdir icon.iconset | |
| for s in 16 32 128 256 512; do | |
| sips -z $s $s icon/sdl_instead.png --out "icon.iconset/icon_${s}x${s}.png" >/dev/null 2>&1 | |
| sips -z $((s * 2)) $((s * 2)) icon/sdl_instead.png --out "icon.iconset/icon_${s}x${s}@2x.png" >/dev/null 2>&1 | |
| done | |
| if iconutil -c icns icon.iconset -o INSTEAD.icns 2>/dev/null; then | |
| cp INSTEAD.icns "$APP/Contents/Resources/" | |
| ICON_KEY="<key>CFBundleIconFile</key><string>INSTEAD.icns</string>" | |
| fi | |
| cat > "$APP/Contents/Info.plist" <<EOF | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>CFBundleName</key><string>INSTEAD</string> | |
| <key>CFBundleDisplayName</key><string>INSTEAD</string> | |
| <key>CFBundleExecutable</key><string>sdl-instead</string> | |
| <key>CFBundleIdentifier</key><string>ru.instead.interpreter</string> | |
| <key>CFBundlePackageType</key><string>APPL</string> | |
| <key>CFBundleShortVersionString</key><string>$VER</string> | |
| <key>CFBundleVersion</key><string>$VER</string> | |
| $ICON_KEY | |
| <key>LSMinimumSystemVersion</key><string>${{ matrix.deployment }}</string> | |
| <key>NSHighResolutionCapable</key><true/> | |
| </dict> | |
| </plist> | |
| EOF | |
| # ad-hoc signature: arm64 binaries are unsigned otherwise and the | |
| # bundle won't start; users still need to clear the quarantine flag | |
| codesign --force --deep --sign - "$APP" | |
| ditto -c -k --sequesterRsrc --keepParent "$APP" "INSTEAD-macos-${{ matrix.arch }}.zip" | |
| - name: Create DMG | |
| run: | | |
| set -e | |
| APP=INSTEAD.app | |
| DMG="INSTEAD-macos-${{ matrix.arch }}.dmg" | |
| rm -rf dmg "$DMG" | |
| mkdir dmg | |
| mv "$APP" dmg/ | |
| # drag-and-drop install | |
| ln -s /Applications dmg/Applications | |
| # HFS+ so the image mounts on the deployment target too | |
| hdiutil create -volname "INSTEAD" -fs HFS+ -srcfolder dmg -ov \ | |
| -format UDZO "$DMG" | |
| hdiutil verify "$DMG" | |
| mkdir -p "$RUNNER_TEMP/dmg-mount" | |
| hdiutil attach "$DMG" -nobrowse -readonly \ | |
| -mountpoint "$RUNNER_TEMP/dmg-mount" | |
| ls -la "$RUNNER_TEMP/dmg-mount" | |
| test -d "$RUNNER_TEMP/dmg-mount/INSTEAD.app" | |
| test -L "$RUNNER_TEMP/dmg-mount/Applications" | |
| codesign --verify --deep --strict "$RUNNER_TEMP/dmg-mount/INSTEAD.app" | |
| hdiutil detach "$RUNNER_TEMP/dmg-mount" | |
| - name: Publish Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: instead-macos-${{ matrix.arch }} | |
| path: | | |
| INSTEAD-macos-${{ matrix.arch }}.zip | |
| INSTEAD-macos-${{ matrix.arch }}.dmg | |
| retention-days: 1 |