Repository navigation
408 lines (358 loc) 路 16.3 KB
/
Copy pathbuild.yml
File metadata and controls
408 lines (358 loc) 路 16.3 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-glfw-linux-x86_64:
name: Build (GLFW/Linux x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get commit info
id: commit-info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=short)" >> $GITHUB_OUTPUT
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake libglfw3-dev libbz2-dev
- name: Configure
run: cmake -B build -DDESKTOP_BACKEND=glfw3 -DCMAKE_BUILD_TYPE=Release "-DBUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }}" "-DBUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}"
- name: Build
run: cmake --build build -j$(nproc)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-glfw-linux-x86_64
path: build/butterscotch
build-glfw-windows-x86_64:
name: Build (GLFW/Windows x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get commit info
id: commit-info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=short)" >> $GITHUB_OUTPUT
- name: Install MinGW and dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake mingw-w64
- name: Build GLFW for MinGW
run: |
git clone https://github.com/glfw/glfw.git /tmp/glfw
git -C /tmp/glfw checkout fdd14e65b1c29e4e6df875fb5669ec00d6793531
cmake -B /tmp/glfw/build -S /tmp/glfw \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/mingw-w64.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32 \
-DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF
make -C /tmp/glfw/build -j$(nproc)
sudo make -C /tmp/glfw/build install
- name: Build bzip2 for MinGW
run: |
curl -L https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz -o /tmp/bzip2.tar.gz
tar -xf /tmp/bzip2.tar.gz -C /tmp
make -C /tmp/bzip2-1.0.8 libbz2.a CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib -j$(nproc)
sudo cp /tmp/bzip2-1.0.8/libbz2.a /usr/x86_64-w64-mingw32/lib/
sudo cp /tmp/bzip2-1.0.8/bzlib.h /usr/x86_64-w64-mingw32/include/
- name: Configure
run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64.cmake -DDESKTOP_BACKEND=glfw3 -DCMAKE_BUILD_TYPE=Release "-DBUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }}" "-DBUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}"
- name: Build
run: cmake --build build -j$(nproc)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-glfw-windows-x86_64
path: build/butterscotch.exe
build-glfw-linux-x86:
name: Build (GLFW/Linux x86)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get commit info
id: commit-info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=short)" >> $GITHUB_OUTPUT
- name: Install 32-bit toolchain and dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y cmake gcc-multilib g++-multilib pkg-config libbz2-dev:i386 libx11-dev:i386 libxrandr-dev:i386 libxinerama-dev:i386 libxcursor-dev:i386 libxi-dev:i386 libgl-dev:i386
- name: Build GLFW (32-bit)
run: |
git clone https://github.com/glfw/glfw.git /tmp/glfw
git -C /tmp/glfw checkout fdd14e65b1c29e4e6df875fb5669ec00d6793531
cmake -B /tmp/glfw/build -S /tmp/glfw \
-DCMAKE_C_FLAGS=-m32 \
-DCMAKE_INSTALL_PREFIX=/usr/local/glfw-x86 \
-DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_WAYLAND=OFF
make -C /tmp/glfw/build -j$(nproc)
sudo make -C /tmp/glfw/build install
- name: Configure
run: |
export PKG_CONFIG_PATH=/usr/local/glfw-x86/lib/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig
cmake -B build -DDESKTOP_BACKEND=glfw3 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_EXE_LINKER_FLAGS=-m32 "-DBUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }}" "-DBUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}"
- name: Build
run: cmake --build build -j$(nproc)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-glfw-linux-x86
path: build/butterscotch
build-glfw-windows-x86:
name: Build (GLFW/Windows x86)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Time
id: get-time
run: echo "time=$(date -u '+%Y-%m-%d-%H:%M:%S')" >> $GITHUB_OUTPUT
- uses: actions/cache@v5
with:
path: ~/ccache.tar.xz
key: win32-artifact-${{ steps.get-time.outputs.time }}
restore-keys: win32-artifact-
- name: Unpack cache
run: |
cd ~
[ -f ccache.tar.xz ] && tar xf ccache.tar.xz || true
[ -f workspacecache.tar ] && mv workspacecache.tar ${{ github.workspace }} || true
- name: Get commit info
id: commit-info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=short)" >> $GITHUB_OUTPUT
- name: Install MinGW and dependencies
run: |
sudo apt-get update
sudo apt-get install -y ccache libgmp-dev libmpfr-dev libmpc-dev
[ -f workspacecache.tar ] && tar xf workspacecache.tar
ARCH=i486 ./artifacts/windows/build-toolchain.sh
tar cf workspacecache.tar artifacts/windows/build/toolchain-i486
mv workspacecache.tar ~
- name: Build
run: |
PATH="$PWD/artifacts/windows/build/toolchain-i486/bin:$PATH" make \
CC='ccache i486-w64-mingw32-gcc' \
OS=Windows \
DESKTOP_BACKEND=glfw2 \
GLFW2_LIBS='-lglfw -lopengl32' \
EXTRALIBS='-latomic' \
BUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }} \
BUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-glfw-windows-x86
path: build/butterscotch.exe
- name: Pack cache
run: cd ~ && tar cJf ccache.tar.xz .cache/ccache workspacecache.tar
build-ps2:
name: Build (PS2)${{ matrix.label }}
runs-on: ubuntu-latest
container:
image: ps2dev/ps2dev:latest
strategy:
fail-fast: false
matrix:
include:
- label: ""
artifact: butterscotch-ps2
extra_flags: ""
- label: " [WAD Version 14]"
artifact: butterscotch-ps2-wad14
extra_flags: "-DENABLE_WAD14=ON -DENABLE_WAD16=OFF -DENABLE_WAD17=OFF"
- label: " [WAD Version 16]"
artifact: butterscotch-ps2-wad16
extra_flags: "-DENABLE_WAD14=OFF -DENABLE_WAD16=ON -DENABLE_WAD17=OFF"
- label: " [WAD Version 17]"
artifact: butterscotch-ps2-wad17
extra_flags: "-DENABLE_WAD14=OFF -DENABLE_WAD16=OFF -DENABLE_WAD17=ON"
steps:
- name: Install build tools
run: apk add --no-cache cmake make gmp-dev mpfr-dev mpc1-dev git
- uses: actions/checkout@v4
# Yeah, the safe.directory is needed because "fatal: detected dubious ownership in repository at '/__w/Butterscotch/Butterscotch'"
- name: Get commit info
id: commit-info
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
- name: Configure
run: |
mkdir -p build
export CFLAGS="-fopt-info-inline-optimized=$PWD/build/inline_report.txt"
cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PS2SDK/ps2dev.cmake -DPLATFORM=ps2 ${{ matrix.extra_flags }} -DCMAKE_BUILD_TYPE=Release "-DBUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }}" "-DBUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}"
- name: Build
run: |
cmake --build build -j$(nproc)
cp build/butterscotch build/butterscotch.elf
- name: Check executeLoop I-Cache fit
run: |
# Extract executeLoop function size(s) from the ELF symbol table.
# GCC IPA passes (constprop/isra/part) may clone a static function and
# suffix the clones (e.g. "executeLoop.constprop.0"). Sum all variants
# since they all share the 16 KB I-Cache budget.
# nm -S prints: address size type name
echo "Getting executeLoop size from ELF symbol table..."
SYMBOL_LINES=$(mips64r5900el-ps2-elf-nm -S build/butterscotch.elf | grep -E ' executeLoop(\..*)?$' || true)
if [ -z "$SYMBOL_LINES" ]; then
echo "::error::Could not find executeLoop symbol in ELF (is it stripped?)"
exit 1
fi
echo "$SYMBOL_LINES"
SIZE_DEC=0
VARIANT_COUNT=0
for SIZE_HEX in $(echo "$SYMBOL_LINES" | awk '{print $2}'); do
SIZE_DEC=$((SIZE_DEC + 0x$SIZE_HEX))
VARIANT_COUNT=$((VARIANT_COUNT + 1))
done
LIMIT=16384
if [ "$SIZE_DEC" -gt "$LIMIT" ]; then
echo "::error::executeLoop is $SIZE_DEC bytes across $VARIANT_COUNT variant(s), exceeding the PS2 16 KB I-Cache ($LIMIT bytes) by $((SIZE_DEC - LIMIT)) bytes"
echo "| Function | Size | Limit | Status |" >> $GITHUB_STEP_SUMMARY
echo "|----------|------|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| \`executeLoop\` ($VARIANT_COUNT variant(s)) | $SIZE_DEC bytes | $LIMIT bytes (16 KB) | **EXCEEDED** by $((SIZE_DEC - LIMIT)) bytes |" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "| Function | Size | Limit | Status |" >> $GITHUB_STEP_SUMMARY
echo "|----------|------|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| \`executeLoop\` ($VARIANT_COUNT variant(s)) | $SIZE_DEC bytes | $LIMIT bytes (16 KB) | $((LIMIT - SIZE_DEC)) bytes remaining |" >> $GITHUB_STEP_SUMMARY
- name: Report executeLoop inlining
run: |
REPORT=build/inline_report.txt
if [ ! -s "$REPORT" ]; then
echo "::warning::No inline report produced at $REPORT"
exit 0
fi
# Extract callees that GCC reported as inlined into executeLoop
INLINED=$(grep -E "Inlin(ed|ing) .* into executeLoop" "$REPORT" \
| awk '{for(i=1;i<=NF;i++) if($i=="into" && $(i+1) ~ /^executeLoop/) {name=$(i-1); sub(/\/[0-9]+$/,"",name); print name}}' \
| sort -u)
# Cross-check: jal targets still present in the compiled executeLoop
# (including GCC-cloned variants like executeLoop.constprop.0).
VARIANT_NAMES=$(mips64r5900el-ps2-elf-nm build/butterscotch.elf | awk '/ executeLoop(\..*)?$/ {print $3}')
DISASM_ARGS=""
for NAME in $VARIANT_NAMES; do
DISASM_ARGS="$DISASM_ARGS --disassemble=$NAME"
done
NOT_INLINED=$(mips64r5900el-ps2-elf-objdump -d $DISASM_ARGS build/butterscotch.elf 2>/dev/null \
| grep -oE "jal[[:space:]]+[0-9a-f]+ <[^>]+>" \
| sed -E 's/.*<([^>]+)>/\1/' \
| sort -u)
INLINED_COUNT=$(printf "%s\n" "$INLINED" | grep -c . || true)
NOT_INLINED_COUNT=$(printf "%s\n" "$NOT_INLINED" | grep -c . || true)
{
echo ""
echo "### \`executeLoop\` inlining report"
echo ""
echo "<details><summary>Inlined into <code>executeLoop</code> ($INLINED_COUNT callees, per GCC <code>-fopt-info-inline-optimized</code>)</summary>"
echo ""
echo '```'
printf "%s\n" "$INLINED"
echo '```'
echo ""
echo "</details>"
echo ""
echo "<details><summary>Still called via <code>jal</code> from <code>executeLoop</code> ($NOT_INLINED_COUNT symbols, per <code>objdump</code>)</summary>"
echo ""
echo '```'
printf "%s\n" "$NOT_INLINED"
echo '```'
echo ""
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: build/butterscotch.elf
build-web:
name: Build (Web)${{ matrix.label }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- label: ""
platform: web
artifact: butterscotch-web
output_glob: build/butterscotch.*
- label: " [Meta]"
platform: web-meta
artifact: butterscotch-web-meta
output_glob: build/butterscotch-meta.*
steps:
- uses: actions/checkout@v4
- name: Get commit info
id: commit-info
run: |
echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "date=$(git log -1 --format=%cd --date=short)" >> $GITHUB_OUTPUT
- name: Setup Emscripten SDK
uses: mymindstorm/setup-emsdk@v14
with:
version: latest
- name: Configure
run: emcmake cmake -B build -DPLATFORM=${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release "-DBUTTERSCOTCH_COMMIT_HASH=${{ steps.commit-info.outputs.hash }}" "-DBUTTERSCOTCH_COMMIT_DATE=${{ steps.commit-info.outputs.date }}"
- name: Build
run: cmake --build build -j$(nproc)
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.output_glob }}
build-ps3:
name: Build (PS3)
runs-on: ubuntu-latest
container: scummvm/dockerized-toolchains:ps3
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -B build -DPLATFORM=ps3 -DCMAKE_TOOLCHAIN_FILE=cmake/ppu.cmake -DCMAKE_BUILD_TYPE=Release
- name: Build bzip2 for PS3
run: |
curl -L https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz -o /tmp/bzip2.tar.gz
tar -xf /tmp/bzip2.tar.gz -C /tmp
make -C /tmp/bzip2-1.0.8 libbz2.a CFLAGS="-mcpu=cell -mtune=cell -maltivec -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections -fomit-frame-pointer -fstrict-aliasing -funroll-loops -ftree-vectorize -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64" CC=powerpc64-ps3-elf-gcc AR=powerpc64-ps3-elf-ar RANLIB=powerpc64-ps3-elf-ranlib -j$(nproc)
cp /tmp/bzip2-1.0.8/libbz2.a /usr/local/ps3dev/portlibs/ppu/lib/
cp /tmp/bzip2-1.0.8/bzlib.h /usr/local/ps3dev/portlibs/ppu/include/
- name: Build
run: |
cmake --build build -j$(nproc)
sprxlinker build/butterscotch.elf
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-ps3
path: build/butterscotch.elf
build-old-gcc:
strategy:
fail-fast: false
matrix:
include:
- name: GCC 3.0
compiler: gcc-3.0
flags: '-std=gnu99 -w'
- name: GCC 2.95
compiler: g++-2.95
flags: '-fpermissive -w'
name: Build (${{ matrix.name }})
runs-on: ubuntu-latest
steps:
- name: Create Debian Woody chroot
run: |
sudo apt-get install --no-install-recommends -y debootstrap
sudo debootstrap --arch=i386 --include='${{ matrix.compiler }},make,libsdl1.2-dev' woody ~/woody http://archive.debian.org/debian
- name: Checkout repo
uses: actions/checkout@v4
with:
path: butterscotch
- name: Build
run: |
sudo mv butterscotch ~/woody
sudo chroot ~/woody /bin/sh --login -c 'make -C /butterscotch CC="${{ matrix.compiler }} ${{ matrix.flags }}" DESKTOP_BACKEND=sdl1 AUDIO_BACKEND=none SDL1_LIBS='-lSDL' DISABLE_MMD=1'