Skip to content

Commit 08bf6c1

Browse files
committed
Added macos build
1 parent b824aa6 commit 08bf6c1

3 files changed

Lines changed: 142 additions & 0 deletions

File tree

.github/workflows/all-builds.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
uses: ./.github/workflows/android-apk.yml
1818
secrets: inherit
1919

20+
macos:
21+
name: macOS
22+
uses: ./.github/workflows/macos.yml
23+
2024
windows:
2125
name: Windows
2226
uses: ./.github/workflows/windows.yml

.github/workflows/macos.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: macOS Build
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
name: macOS arm64
9+
runs-on: macos-15
10+
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
submodules: recursive
17+
18+
- name: Fetch vcpkg history and baseline
19+
shell: bash
20+
run: |
21+
manifest="vcpkg.json"
22+
baseline="$(sed -nE 's/.*"builtin-baseline":[[:space:]]*"([0-9a-f]{40})".*/\1/p' "${manifest}" | head -n1)"
23+
24+
if [ -z "${baseline}" ]; then
25+
echo "Unable to determine vcpkg builtin-baseline from ${manifest}"
26+
exit 1
27+
fi
28+
29+
if git -C extern/vcpkg rev-parse --is-shallow-repository | grep -q true; then
30+
git -C extern/vcpkg fetch --force --prune --tags --unshallow origin \
31+
"+refs/heads/*:refs/remotes/origin/*"
32+
else
33+
git -C extern/vcpkg fetch --force --prune --tags origin \
34+
"+refs/heads/*:refs/remotes/origin/*"
35+
fi
36+
37+
if ! git -C extern/vcpkg cat-file -e "${baseline}^{commit}" 2>/dev/null; then
38+
git -C extern/vcpkg fetch --force origin "${baseline}"
39+
fi
40+
41+
git -C extern/vcpkg cat-file -e "${baseline}^{commit}"
42+
43+
- name: Build libromfs generator
44+
shell: bash
45+
run: |
46+
chmod +x build_libromfs_generator.sh
47+
./build_libromfs_generator.sh
48+
49+
- name: Bootstrap vcpkg
50+
shell: bash
51+
working-directory: extern/vcpkg
52+
run: |
53+
chmod +x bootstrap-vcpkg.sh
54+
./bootstrap-vcpkg.sh -disableMetrics
55+
56+
- name: Compute vcpkg cache key
57+
id: vcpkg-cache-key
58+
shell: bash
59+
run: |
60+
vcpkg_revision="$(git -C extern/vcpkg rev-parse HEAD)"
61+
manifest_hash="${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'extern/cmake/vcpkg-triplets/arm64-osx.cmake') }}"
62+
echo "key=macOS-arm64-vcpkg-${vcpkg_revision}-${manifest_hash}" >> "$GITHUB_OUTPUT"
63+
echo "restore-prefix=macOS-arm64-vcpkg-${vcpkg_revision}-" >> "$GITHUB_OUTPUT"
64+
65+
- name: Restore vcpkg cache
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
extern/vcpkg/buildtrees
70+
extern/vcpkg/downloads
71+
extern/vcpkg/packages
72+
build/macos/vcpkg_installed
73+
key: ${{ steps.vcpkg-cache-key.outputs.key }}
74+
restore-keys: |
75+
${{ steps.vcpkg-cache-key.outputs.restore-prefix }}
76+
77+
- name: Configure
78+
shell: bash
79+
run: |
80+
cmake -B build/macos \
81+
-DPLATFORM_DESKTOP=ON \
82+
-DBUNDLE_MACOS_APP=ON \
83+
-DCMAKE_BUILD_TYPE=Release \
84+
-DVCPKG_TARGET_TRIPLET=arm64-osx \
85+
-DVCPKG_OVERLAY_TRIPLETS="$GITHUB_WORKSPACE/extern/cmake/vcpkg-triplets"
86+
87+
- name: Build app bundle
88+
shell: bash
89+
run: cmake --build build/macos --config Release --parallel 3
90+
91+
- name: Sign and validate app bundle
92+
shell: bash
93+
run: |
94+
app="build/macos/Moonlight.app"
95+
96+
test -d "$app"
97+
test -x "$app/Contents/MacOS/Moonlight"
98+
plutil -lint "$app/Contents/Info.plist"
99+
codesign --force --deep --sign - "$app"
100+
codesign --verify --deep --strict "$app"
101+
102+
- name: Package app bundle
103+
shell: bash
104+
run: |
105+
mkdir -p dist
106+
ditto -c -k --sequesterRsrc --keepParent \
107+
build/macos/Moonlight.app \
108+
dist/Moonlight-macOS-arm64.zip
109+
110+
- name: Upload macOS build logs
111+
if: failure()
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: Moonlight-macOS-build-logs
115+
path: |
116+
build/macos/vcpkg-manifest-install.log
117+
build/macos/CMakeFiles/CMakeError.log
118+
build/macos/CMakeFiles/CMakeOutput.log
119+
extern/vcpkg/buildtrees/**/*.log
120+
if-no-files-found: ignore
121+
122+
- name: Upload artifact
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: Moonlight-macOS-arm64
126+
path: dist/Moonlight-macOS-arm64.zip
127+
if-no-files-found: error
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(VCPKG_TARGET_ARCHITECTURE arm64)
2+
set(VCPKG_CRT_LINKAGE dynamic)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
5+
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
6+
set(VCPKG_OSX_ARCHITECTURES arm64)
7+
8+
# mbedTLS 2.28 and other dependencies in the pinned vcpkg baseline still
9+
# declare compatibility with CMake policy versions older than CMake 4 accepts.
10+
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS
11+
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5")

0 commit comments

Comments
 (0)