Skip to content

Github CI: Fix Mac builder (#176) by TellowKrinkle #38

Github CI: Fix Mac builder (#176) by TellowKrinkle

Github CI: Fix Mac builder (#176) by TellowKrinkle #38

Workflow file for this run

name: MacOS Build Steps
on: [push, pull_request]
jobs:
build_macos:
name: macOS Build
runs-on: macos-14
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 9
CCACHE_MAXSIZE: 200M
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Packages
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_ANALYTICS: 1
run: |
if ! brew install ccache ninja; then
brew update
brew install ccache ninja
fi
- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: ~/deps
key: macOS deps ${{ hashFiles('.github/workflows/scripts/macos/build-dependencies.sh') }}
- name: Build Dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: .github/workflows/scripts/macos/build-dependencies.sh
- name: Cache MoltenVK
id: cache-moltenvk
uses: actions/cache@v4
with:
path: ~/moltenvk
key: macOS MoltenVK ${{ hashFiles('Externals/MoltenVK') }}
- name: Build MoltenVK
if: steps.cache-moltenvk.outputs.cache-hit != 'true'
run: |
MVK_VER="$(sed -nr 's/^.*set\(MOLTENVK_VERSION "([^"]+)".*$/\1/p' Externals/MoltenVK/CMakeLists.txt)"
if [ -z "$MVK_VER" ]; then
echo "::error::Failed to parse MoltenVK version from CMakeLists"
exit 1
fi
git clone --depth 1 --branch "$MVK_VER" https://github.com/KhronosGroup/MoltenVK.git mvk-build
pushd mvk-build
git apply ../Externals/MoltenVK/patches/*.patch
./fetchDependencies --macos
make macos
ls -l Package/Release/MoltenVK/dynamic/*
chmod 755 Package/Release/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib
mkdir -p "$HOME/moltenvk/lib/"
mv Package/Release/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib "$HOME/moltenvk/lib/"
popd
rm -rf mvk-build
# -- SETUP CCACHE - https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
run: echo "timestamp=$(date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
- name: Cache ccache cache
uses: actions/cache@v4
with:
path: .ccache
key: macOS ccache ${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: macOS ccache
- name: Generate CMake Files
run: |
COMMON_ARGS=(
-DCMAKE_PREFIX_PATH="$HOME/deps;$HOME/moltenvk"
-DCMAKE_BUILD_TYPE=Release
-DUSE_BUNDLED_MOLTENVK=OFF
-DMACOS_CODE_SIGNING=OFF
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON
-DUSE_SYSTEM_LIBS=OFF
-DUSE_SYSTEM_BZIP2=ON
-DUSE_SYSTEM_CURL=ON
-DUSE_SYSTEM_ICONV=ON
-DUSE_SYSTEM_SDL2=ON
-GNinja
)
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_SYSTEM_PROCESSOR=x86_64 \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
"${COMMON_ARGS[@]}" \
-B build .
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
"${COMMON_ARGS[@]}" \
-B build-arm .
- name: Build Dolphin (x86_64)
working-directory: build
run: |
ccache -p
ccache -s
ccache -z
ninja dolphin-emu
ccache -s
- name: Build Dolphin (arm64)
working-directory: build-arm
run: |
ccache -p
ccache -s
ccache -z
ninja dolphin-emu
ccache -s
- name: Prepare Build Artifacts
id: create-artifact
env:
EVENT_NAME: ${{ github.event_name }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUM: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
run: |
lipo -create build/Binaries/DolphinQt.app/Contents/MacOS/DolphinQt build-arm/Binaries/DolphinQt.app/Contents/MacOS/DolphinQt -o dolphin
mv dolphin build/Binaries/DolphinQt.app/Contents/MacOS/DolphinQt
TAG="$(git tag --points-at HEAD)"
if [ ! -z "$TAG" ]; then
SUFFIX="$TAG"
elif [ "$EVENT_NAME" == "pull_request" ]; then
PR_TITLE=$(echo "${PR_TITLE}" | tr -cd '[a-zA-Z0-9[:space:]]_-')
SUFFIX="pr[$PR_NUM]-sha[$PR_SHA]-title[$PR_TITLE"
SUFFIX=$(printf "%.99s]" "$SUFFIX")
else
SUFFIX="sha[$(git rev-parse --short HEAD)]"
fi
APPNAME="PrimeHack-$SUFFIX"
mv build/Binaries/DolphinQt.app "$APPNAME.app"
tar --options xz:compression-level=9 -cvJf "$APPNAME.tar.xz" "$APPNAME.app"
echo "name=$APPNAME" >> "$GITHUB_OUTPUT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.create-artifact.outputs.name }}
path: "*.tar.xz"