forked from dolphin-emu/dolphin
-
Notifications
You must be signed in to change notification settings - Fork 44
161 lines (145 loc) · 5.5 KB
/
macos_build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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"