-
Notifications
You must be signed in to change notification settings - Fork 4
319 lines (275 loc) · 12.8 KB
/
Copy pathbuild.yml
File metadata and controls
319 lines (275 loc) · 12.8 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
name: Build
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
branches:
- '**'
permissions: write-all
env:
OBGGCC_BUILD_PARALLEL_LEVEL: 40
OBGGCC_BUILD_DIRECTORY: /tmp
OBGGCC_RELEASE: '16'
OBGGCC_TARGETS: '*'
jobs:
native-build:
name: 'Native build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
submodules: true
- name: Checkout submodules
run: |
git -C submodules/nz submodule update --init --depth=1
- name: Install required dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential autoconf libtool zsh
- name: Check for cache
id: check-cache
uses: actions/cache@main
with:
key: 'cache-${{ env.OBGGCC_RELEASE }}'
lookup-only: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Build OBGGCC
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
run: |
if [ "${OBGGCC_RELEASE}" = '2.95' ]; then
export OBGGCC_BUILD_PARALLEL_LEVEL='1'
fi
zsh './build.sh'
- name: Generate tarball
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
run: |
declare tarball_filename='/tmp/x86_64-linux-gnu.tar.xz'
tar --directory='/tmp' --create --file=- 'obggcc' | xz --threads='0' --extreme --memlimit-compress='100%' --compress -9 > "${tarball_filename}"
sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256"
- name: Upload artifact
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
uses: actions/upload-artifact@main
with:
name: native-toolchain
if-no-files-found: error
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Cache artifact
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
uses: actions/cache@main
with:
key: 'cache-${{ env.OBGGCC_RELEASE }}'
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
cross-build:
name: 'Cross build'
needs: native-build
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
target: [
# Windows
'x86_64-w64-mingw32',
'i686-w64-mingw32',
# macOS
'aarch64-unknown-apple-darwin',
'x86_64-unknown-apple-darwin',
# Linux (musl)
'aarch64-unknown-linux-musl',
'x86_64-unknown-linux-musl',
'armv6-unknown-linux-musleabihf',
'armv7-unknown-linux-musleabihf',
'i386-unknown-linux-musl',
# Linux (glibc)
'x86_64-unknown-linux-gnu',
'i386-unknown-linux-gnu',
'arm-unknown-linux-gnueabi',
'arm-unknown-linux-gnueabihf',
'aarch64-unknown-linux-gnu',
# FreeBSD
'x86_64-unknown-freebsd',
'aarch64-unknown-freebsd',
'i386-unknown-freebsd',
# NetBSD
'i386-unknown-netbsdelf',
'x86_64-unknown-netbsd',
# DragonFly BSD
'x86_64-unknown-dragonfly',
# Android
'x86_64-unknown-linux-android',
'i686-unknown-linux-android21',
'aarch64-unknown-linux-android',
'armv7-unknown-linux-androideabi21',
]
steps:
- uses: actions/checkout@main
with:
submodules: true
- name: Checkout submodules
run: |
git -C submodules/nz submodule update --init --depth=1
- name: Install required dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential autoconf libtool zsh
- name: Restore from cache
uses: actions/cache@main
with:
key: 'cache-${{ env.OBGGCC_RELEASE }}'
fail-on-cache-miss: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Setup toolchain
run: |
tar --directory='/tmp' --extract --file='/tmp/x86_64-linux-gnu.tar.xz'
mv '/tmp/obggcc' '/tmp/obggcc-toolchain'
- name: Cross-compile OBGGCC to ${{ matrix.target }}
run: |
source './tools/setup_toolchain.sh'
wget 'https://github.com/AmanoTeam/musl-gcc-cross/releases/download/sysroot/x86_64-unknown-linux-musl.tar.xz'
tar -xf 'x86_64-unknown-linux-musl.tar.xz'
sudo ln -s "${PWD}/x86_64-unknown-linux-musl/lib/libc.so" '/lib/ld-musl-x86_64.so.1'
if [[ '${{ matrix.target }}' = *'-linux-musl'* ]]; then
declare -r RAIDEN_TAG='gcc-16'
declare -r RAIDEN_TARBALL='/tmp/toolchain.tar.xz'
declare -r RAIDEN_URL="https://github.com/AmanoTeam/musl-gcc-cross/releases/download/${RAIDEN_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${RAIDEN_URL}" --output "${RAIDEN_TARBALL}"
tar --directory="$(dirname "${RAIDEN_TARBALL}")" --extract --file="${RAIDEN_TARBALL}"
export RAIDEN_HOME='/tmp/musl-gcc-cross'
export PATH="${RAIDEN_HOME}/bin:${PATH}"
source "${RAIDEN_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-linux-gnu'* ]]; then
declare -r OBGGCC_TAG='gcc-16'
declare -r OBGGCC_TARBALL='/tmp/toolchain.tar.xz'
declare -r OBGGCC_URL="https://github.com/AmanoTeam/obggcc/releases/download/${OBGGCC_TAG}/x86_64-unknown-linux-musl.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${OBGGCC_URL}" --output "${OBGGCC_TARBALL}"
tar --directory="$(dirname "${OBGGCC_TARBALL}")" --extract --file="${OBGGCC_TARBALL}"
mv '/tmp/obggcc' '/tmp/obggcc-toolchain-bin'
export OBGGCC_ARM_MODE='true'
export OBGGCC_HOME='/tmp/obggcc-toolchain-bin'
# export PATH="${OBGGCC_HOME}/bin:${PATH}"
source "${OBGGCC_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-freebsd' ]]; then
declare -r LOKI_TAG='gcc-16'
declare -r LOKI_TARBALL='/tmp/toolchain.tar.xz'
declare -r LOKI_URL="https://github.com/AmanoTeam/freebsd-gcc-cross/releases/download/${LOKI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --silent --connect-timeout '10' --retry '15' --retry-all-errors --fail --location --url "${LOKI_URL}" --output "${LOKI_TARBALL}"
tar --directory="$(dirname "${LOKI_TARBALL}")" --extract --file="${LOKI_TARBALL}"
export LOKI_HOME='/tmp/freebsd-gcc-cross'
export PATH="${LOKI_HOME}/bin:${PATH}"
source "${LOKI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-netbsd'* ]]; then
declare -r DAKINI_TAG='gcc-16'
declare -r DAKINI_TARBALL='/tmp/toolchain.tar.xz'
declare -r DAKINI_URL="https://github.com/AmanoTeam/netbsd-gcc-cross/releases/download/${DAKINI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${DAKINI_URL}" --output "${DAKINI_TARBALL}"
tar --directory="$(dirname "${DAKINI_TARBALL}")" --extract --file="${DAKINI_TARBALL}"
export DAKINI_HOME='/tmp/netbsd-gcc-cross'
export PATH="${DAKINI_HOME}/bin:${PATH}"
source "${DAKINI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-dragonfly' ]]; then
declare -r VENTI_TAG='gcc-16'
declare -r VENTI_TARBALL='/tmp/toolchain.tar.xz'
declare -r VENTI_URL="https://github.com/AmanoTeam/dragonfly-gcc-cross/releases/download/${VENTI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${VENTI_URL}" --output "${VENTI_TARBALL}"
tar --directory="$(dirname "${VENTI_TARBALL}")" --extract --file="${VENTI_TARBALL}"
export VENTI_HOME='/tmp/dragonfly-gcc-cross'
export PATH="${VENTI_HOME}/bin:${PATH}"
source "${VENTI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-android'* ]]; then
declare -r PINO_TAG='gcc-16'
declare -r PINO_TARBALL='/tmp/toolchain.tar.xz'
declare -r PINO_URL="https://github.com/AmanoTeam/android-gcc-cross/releases/download/${PINO_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${PINO_URL}" --output "${PINO_TARBALL}"
tar --directory="$(dirname "${PINO_TARBALL}")" --extract --file="${PINO_TARBALL}"
export PINO_HOME='/tmp/android-gcc-cross'
export PATH="${PINO_HOME}/bin:${PATH}"
source "${PINO_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-mingw32' ]]; then
declare -r MINGW_TAG='gcc-16'
declare -r MINGW_TARBALL='/tmp/toolchain.tar.xz'
declare -r MINGW_URL="https://github.com/AmanoTeam/mingw-gcc-cross/releases/download/${MINGW_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${MINGW_URL}" --output "${MINGW_TARBALL}"
tar --directory="$(dirname "${MINGW_TARBALL}")" --extract --file="${MINGW_TARBALL}"
export MINGW_HOME='/tmp/mingw-gcc-cross'
export PATH="${MINGW_HOME}/bin:${PATH}"
source "${MINGW_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-darwin' ]]; then
curl \
--silent \
--show-error \
--fail \
--url 'https://raw.githubusercontent.com/AmanoTeam/darwin-clang-cross/refs/heads/master/main.sh' \
| bash -s -- install
export DARWIN_HOME='/tmp/darwin-clang-cross'
export PATH="${DARWIN_HOME}/bin:${PATH}"
source "${DARWIN_HOME}/build/autotools/${{ matrix.target }}.sh"
fi
if [ "${OBGGCC_RELEASE}" = '2.95' ]; then
export OBGGCC_BUILD_PARALLEL_LEVEL='1'
fi
zsh './build.sh'
- name: Create logs
if: always()
run: |
declare logs=''
while read file; do
logs+="${file} "
done <<< $(find "/tmp/"*"/build" -wholename '*.log' -o -wholename '*.yaml')
tar --create --file=- ${logs} | xz --threads='0' --compress -9 > '/tmp/logs.tar.xz'
- name: Upload logs
if: always()
uses: actions/upload-artifact@main
with:
name: ${{ matrix.target }}-logs
if-no-files-found: error
path: |
/tmp/logs.tar.xz
- name: Generate tarball
run: |
if [[ '${{ matrix.target }}' = *'-mingw32' ]]; then
declare tarball_filename='/tmp/${{ matrix.target }}.7z'
cd '/tmp'
7z a "${tarball_filename}" 'obggcc' \
-t7z \
-mx=9 \
-m0=lzma2:d=128m:fb=128 \
-ms=on \
-mmt="$(nproc)"
else
declare tarball_filename='/tmp/${{ matrix.target }}.tar.xz'
tar --directory='/tmp' --create --file=- 'obggcc' | xz --threads='0' --extreme --memlimit-compress='100%' --compress -9 > "${tarball_filename}"
fi
sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256"
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: ${{ matrix.target }}
if-no-files-found: error
path: |
/tmp/${{ matrix.target }}.*
release:
needs: cross-build
runs-on: ubuntu-latest
name: Collect all artifacts
steps:
- name: Download all artifacts
uses: actions/download-artifact@main
- name: Create release
uses: softprops/action-gh-release@master
with:
tag_name: 'gcc-${{ env.OBGGCC_RELEASE }}'
name: 'GCC ${{ env.OBGGCC_RELEASE }}'
files: ./*/*-{unknown,w64}-*.{tar.xz,7z}*
draft: false
prerelease: false
fail_on_unmatched_files: true
body: "* Update to GCC ${{ env.OBGGCC_RELEASE }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}