Repository navigation
197 lines (181 loc) · 8.11 KB
/
Copy pathmacos.yml
File metadata and controls
197 lines (181 loc) · 8.11 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: macOS version
on:
push:
branches: [master]
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