-
Notifications
You must be signed in to change notification settings - Fork 22
216 lines (181 loc) · 8.6 KB
/
build.yml
File metadata and controls
216 lines (181 loc) · 8.6 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
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
- name: Configure
run: cmake -B build -DPLATFORM=glfw -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: Configure
run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64.cmake -DPLATFORM=glfw -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 -DPLATFORM=glfw -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 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 (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_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/mingw-w64-i686.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/i686-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: Configure
run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64-i686.cmake -DPLATFORM=glfw -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
path: build/butterscotch.exe
build-ps2:
name: Build (PS2)
runs-on: ubuntu-latest
container:
image: ps2dev/ps2dev:latest
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: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PS2SDK/ps2dev.cmake -DPLATFORM=ps2 -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 from the ELF symbol table
# nm -S prints: address size type name
echo "Getting executeLoop size from ELF symbol table..."
SYMBOL_LINE=$(mips64r5900el-ps2-elf-nm -S build/butterscotch.elf | grep ' executeLoop$' || true)
if [ -z "$SYMBOL_LINE" ]; then
echo "::error::Could not find executeLoop symbol in ELF (is it stripped?)"
exit 1
fi
# Size is the second hex field
SIZE_HEX=$(echo "$SYMBOL_LINE" | awk '{print $2}')
SIZE_DEC=$((16#$SIZE_HEX))
LIMIT=16384
if [ "$SIZE_DEC" -gt "$LIMIT" ]; then
echo "::error::executeLoop is $SIZE_DEC bytes, 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\` | $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\` | $SIZE_DEC bytes | $LIMIT bytes (16 KB) | $((LIMIT - SIZE_DEC)) bytes remaining |" >> $GITHUB_STEP_SUMMARY
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: butterscotch-ps2
path: build/butterscotch.elf