-
Notifications
You must be signed in to change notification settings - Fork 108
254 lines (228 loc) · 11.1 KB
/
build-toolchain-matrix.yml
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
name: Build-Native
# This workflow will build the libdragon N64 GCC toolchain to keep it up-to-date.
on:
# This action will take about 40-70 minutes to run!
# It is designed to only fire if the GCC toolchain build file changes.
push:
paths:
- 'tools/build-toolchain.sh'
pull_request:
paths:
- 'tools/build-toolchain.sh'
jobs:
Build-Toolchain:
# targets the oldest ubuntu image available to create valid packages for as many versions possible.
# TODO: move to using a docker container to support older versions.
outputs:
gcc-version: ${{ steps.gcc-version-generator.outputs.GCC_VERSION }}
newlib-version: ${{ steps.gcc-version-generator.outputs.NEWLIB_VERSION }}
binutils-version: ${{ steps.gcc-version-generator.outputs.BINUTILS_VERSION }}
gmp-version: ${{ steps.gcc-version-generator.outputs.GMP_VERSION }}
mpc-version: ${{ steps.gcc-version-generator.outputs.MPC_VERSION }}
mpfr-version: ${{ steps.gcc-version-generator.outputs.MPFR_VERSION }}
make-version: ${{ steps.gcc-version-generator.outputs.MAKE_VERSION }}
strategy:
fail-fast: false
matrix:
include: [
{ host-os: ubuntu-20.04, target-platform: Windows-x86_64, host: x86_64-w64-mingw32, makefile-version: 4.4 },
{ host-os: ubuntu-20.04, target-platform: Linux-x86_64, host: '', makefile-version: '' }
]
runs-on: ${{ matrix.host-os }}
env:
Build_Directory: libdragon
steps:
- name: Install native system build dependencies
run: |
sudo apt-get install libmpfr-dev
sudo apt-get install texinfo
sudo apt-get install libmpc-dev
sudo apt-get install squashfs-tools
# If there are other dependencies, we should add them here and make sure the documentation is updated!
continue-on-error: true
- name: Install x-compile system build dependencies
if: ${{ matrix.target-platform == 'Windows-x86_64' }}
run: |
sudo apt-get install -y mingw-w64
# If there are other dependencies, we should add them here and make sure the documentation is updated!
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
- name: Set up Ruby
if: ${{ matrix.target-platform == 'Linux-x86_64' }}
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.3'
continue-on-error: true
- name: Install Package Creator
if: ${{ matrix.target-platform == 'Linux-x86_64' }}
run: |
echo installing jordansissel/fpm ruby package
gem install fpm
fpm --version
continue-on-error: true
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1 # we only require the last check-in, unless we want to create a changelog.
# Cache and restore dependencies instead of downloading them to increase build speed.
# Expires after 7 days.
- uses: actions/cache@v4
id: cache
with:
path: |
./tools/**/*.tar.gz
./tools/**/*.tar.bz2
key: ${{ runner.os }}-dependency-downloads # TODO: concurrency errors may currently occur due to matrix, but they are the same files.
- name: Get versions from toolchain file
id: gcc-version-generator
run: |
echo "BINUTILS_VERSION=$(grep -Po 'BINUTILS_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "GCC_VERSION=$(grep -Po 'GCC_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "NEWLIB_VERSION=$(grep -Po 'NEWLIB_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "GMP_VERSION=$(grep -Po 'GMP_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "MPC_VERSION=$(grep -Po 'MPC_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "MPFR_VERSION=$(grep -Po 'MPFR_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
# TODO: this version is set explicitly. We need to fix!
echo "MAKE_VERSION=4.4" >> $GITHUB_OUTPUT
continue-on-error: false
- name: Build N64 MIPS GCC toolchain for ${{ matrix.target-platform }}
run: |
# required for newlib (as not the default?!)
export PATH="$PATH:${{ runner.temp }}/${{ env.Build_Directory }}"
cd ./tools/
N64_INST=${{ runner.temp }}/${{ env.Build_Directory }} N64_HOST=${{ matrix.host }} MAKE_V=${{ matrix.makefile-version }} ./build-toolchain.sh
echo Remove un-necessary content
rm -rf ${N64_INST}/share/locale/*
continue-on-error: true
# https://fpm.readthedocs.io/en/v1.15.0/getting-started.html
# TODO: add --deb-changelog with versions (like we do in release)
- name: Generate toolchain packages for Linux based OS
if: ${{ matrix.target-platform == 'Linux-x86_64' }}
run: |
echo Generate environment var file
echo 'export N64_INST=${{ env.Package_Installation_Directory }}' > "$Package_Name-env.sh"
chmod 755 "$Package_Name-env.sh"
# TODO: there is currently a dependency on makefile. but it is not added.
# packages need something like `--depends bash \`
echo Generating debian package
# TODO: a warning is generated when adding files to `\etc`. The current workaround is: --deb-no-default-config-files
fpm \
-t deb \
-s dir \
-p $Package_Name-$Package_Architecture.deb \
--name $Package_Name \
--license $Package_License \
--version $Package_Version.$Package_Revision \
--architecture $Package_Architecture \
--description "$Package_Description" \
--url "$Package_Url" \
--maintainer "$Package_Maintainer" \
--deb-no-default-config-files \
$Package_Source_Directory=$Package_Installation_Directory/ \
$Package_Name-env.sh=/etc/profile.d/$Package_Name-env.sh
echo Generating rpm package
fpm \
-t rpm \
-s dir \
-p $Package_Name-$Package_Architecture.rpm \
--name $Package_Name \
--license $Package_License \
--version $Package_Version.$Package_Revision \
--architecture $Package_Architecture \
--description "$Package_Description" \
--url "$Package_Url" \
--maintainer "$Package_Maintainer" \
$Package_Source_Directory=$Package_Installation_Directory/ \
$Package_Name-env.sh=/etc/profile.d/$Package_Name-env.sh
continue-on-error: true
env:
Package_Source_Directory: ${{ runner.temp }}/${{ env.Build_Directory }}/
Package_Installation_Directory: /opt/${{ env.Build_Directory }}
Package_Name: gcc-toolchain-mips64
Package_Version: ${{ steps.gcc-version-generator.outputs.GCC_VERSION }}
Package_Revision: ${{ github.run_id }}
Package_Architecture: x86_64
Package_License: GPL
Package_Description: MIPS GCC toolchain for the N64
Package_Url: https://n64brew.com
Package_Maintainer: N64 Brew Community
- name: Publish Windows-x86_64 Build Artifact
if: ${{ matrix.target-platform == 'Windows-x86_64' }}
uses: actions/upload-artifact@v4
with:
name: gcc-toolchain-mips64-${{ matrix.target-platform }}
path: |
${{ runner.temp }}/${{ env.Build_Directory }}
continue-on-error: true
- name: Publish Linux-x86_64 Build Artifacts
if: ${{ matrix.target-platform == 'Linux-x86_64' }}
uses: actions/upload-artifact@v4
with:
name: gcc-toolchain-mips64-${{ matrix.target-platform }}
path: |
./**/*.deb
./**/*.rpm
continue-on-error: true
Publish-Toolchain:
runs-on: ubuntu-latest
needs: Build-Toolchain
steps:
- uses: actions/checkout@v4
- name: Download Windows artifact
id: download-windows-artifact
uses: actions/download-artifact@v4
with:
name: gcc-toolchain-mips64-Windows-x86_64
path: ${{ runner.temp }}/gcc-toolchain-mips64-Windows-x86_64
- name: Download Linux artifact
id: download-linux-artifact
uses: actions/download-artifact@v4
with:
name: gcc-toolchain-mips64-Linux-x86_64
path: ${{ runner.temp }}/gcc-toolchain-mips64-Linux-x86_64
- name: Convert files for release upload
run: |
mv ${{ github.workspace }}/LICENSE.md ${{ github.workspace }}/LICENSE.txt
# TODO: should also include GPLV3 licence (and any other dependency licences).
# TODO: include an installation readme.
- name: Generate Changelog
run: |
CHANGELOG_TEXT="Latest GCC toolchain for the N64</br>"
CHANGELOG_TEXT+="Generated from https://github.com/DragonMinded/libdragon/trunk on $(date).</br>"
CHANGELOG_TEXT+='Installation instructions are [available in the wiki](https://github.com/DragonMinded/libdragon/wiki/Installing-libdragon)</br>'
CHANGELOG_TEXT+='</br>'
CHANGELOG_TEXT+="Builds toolchain dependencies:</br>"
CHANGELOG_TEXT+=" * GCC: V${{ needs.build-toolchain.outputs.gcc-version }}</br>"
CHANGELOG_TEXT+=" * Newlib: V${{ needs.build-toolchain.outputs.newlib-version }}</br>"
CHANGELOG_TEXT+=" * BinUtils: V${{ needs.build-toolchain.outputs.binutils-version }}</br>"
CHANGELOG_TEXT+='</br>'
CHANGELOG_TEXT+="With dependencies:</br>"
CHANGELOG_TEXT+=" * GMP: V${{ needs.build-toolchain.outputs.gmp-version }}</br>"
CHANGELOG_TEXT+=" * MPC: V${{ needs.build-toolchain.outputs.mpc-version }}</br>"
CHANGELOG_TEXT+=" * MPFR: V${{ needs.build-toolchain.outputs.mpfr-version }}</br>"
CHANGELOG_TEXT+='</br>'
CHANGELOG_TEXT+="Also generates Windows toolchain dependencies:</br>"
CHANGELOG_TEXT+=" * MAKEFILE: V${{ needs.build-toolchain.outputs.make-version }}</br>"
CHANGELOG_TEXT+='</br>'
CHANGELOG_TEXT+='The GCC toolchain is licensed under GPLv3</br>'
CHANGELOG_TEXT+='</br>'
echo "$CHANGELOG_TEXT" > ${{ github.workspace }}/CHANGELOG
# Compress and move the windows folder ready for upload.
- name: Compress and move windows artifacts
run: |
cd ${{ steps.download-windows-artifact.outputs.download-path }}
zip -r -q ${{ runner.temp }}/gcc-toolchain-mips64-win64.zip *
- name: Generate Release
if: github.ref == 'refs/heads/trunk'
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
body_path: CHANGELOG
generate_release_notes: false
name: 'V${{ needs.build-toolchain.outputs.gcc-version }}-${{ github.run_id }}'
tag_name: "toolchain-continuous-prerelease"
files: |
${{ runner.temp }}/**/*.deb
${{ runner.temp }}/**/*.rpm
${{ runner.temp }}/*.zip