-
Notifications
You must be signed in to change notification settings - Fork 71
206 lines (178 loc) · 7.2 KB
/
build.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
# PSn00bSDK GitHub Actions CI script
# (C) 2021-2023 spicyjpeg - MPL licensed
# The GCC toolchain is stored in the GitHub Actions cache after being built. To
# minimize build times, all the toolchain build steps are skipped if there is a
# cached copy of the toolchain that has not expired (even though the build-gcc
# job still has to run in order to check the cache's contents). The cache is
# shared between all actions in a repo.
name: Build PSn00bSDK
on: [ push, pull_request ]
env:
BINUTILS_VERSION: '2.43'
BINUTILS_OPTIONS: '--disable-docs --disable-nls --disable-werror --with-float=soft'
GCC_VERSION: '14.2.0'
GCC_OPTIONS: '--disable-docs --disable-nls --disable-werror --disable-libada --disable-libssp --disable-libquadmath --disable-threads --disable-libgomp --disable-libstdcxx-pch --disable-hosted-libstdcxx --enable-languages=c,c++ --without-isl --without-headers --with-float=soft --with-gnu-as --with-gnu-ld'
GCC_TARGET: 'mipsel-none-elf'
jobs:
# This is based on doc/toolchain.md, no surprises here other than the cache.
build-gcc:
name: Build GCC toolchain
runs-on: ubuntu-latest
steps:
- name: Initialize toolchain cache
id: _cache
uses: actions/cache@v4
with:
enableCrossOsArchive: true
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
- name: Install prerequisites
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends make g++-mingw-w64-x86-64
- name: Download and extract sources
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
wget -q -O binutils.tar.xz https://ftpmirror.gnu.org/gnu/binutils/binutils-${{ env.BINUTILS_VERSION }}.tar.xz
wget -q -O gcc.tar.xz https://ftpmirror.gnu.org/gnu/gcc/gcc-${{ env.GCC_VERSION }}/gcc-${{ env.GCC_VERSION }}.tar.xz
tar xf binutils.tar.xz
tar xf gcc.tar.xz
cd gcc-${{ env.GCC_VERSION }}
contrib/download_prerequisites
- name: Build binutils for Linux
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
mkdir binutils_linux
cd binutils_linux
../binutils-${{ env.BINUTILS_VERSION }}/configure --prefix=${{ github.workspace }}/gcc/linux --target=${{ env.GCC_TARGET }} ${{ env.BINUTILS_OPTIONS }}
make -j 2
make install-strip
echo "${{ github.workspace }}/gcc/linux/bin" >>$GITHUB_PATH
- name: Build GCC for Linux
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
mkdir gcc_linux
cd gcc_linux
../gcc-${{ env.GCC_VERSION }}/configure --prefix=${{ github.workspace }}/gcc/linux --target=${{ env.GCC_TARGET }} ${{ env.GCC_OPTIONS }}
make -j 2
make install-strip
- name: Build binutils for Windows
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
mkdir binutils_windows
cd binutils_windows
../binutils-${{ env.BINUTILS_VERSION }}/configure --prefix=${{ github.workspace }}/gcc/windows --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --target=${{ env.GCC_TARGET }} ${{ env.BINUTILS_OPTIONS }}
make -j 2
make install-strip
- name: Build GCC for Windows
if: ${{ steps._cache.outputs.cache-hit != 'true' }}
run: |
mkdir gcc_windows
cd gcc_windows
../gcc-${{ env.GCC_VERSION }}/configure --prefix=${{ github.workspace }}/gcc/windows --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 --target=${{ env.GCC_TARGET }} ${{ env.GCC_OPTIONS }}
make -j 2
make install-strip
# No surprises here either. The GitHub Actions VMs even come with most of the
# dependencies required to build PSn00bSDK preinstalled.
build-sdk-windows:
name: Build PSn00bSDK on Windows
runs-on: windows-2022
needs: build-gcc
steps:
- name: Add MSys2 to PATH
run: |
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Initialize toolchain cache
uses: actions/cache@v4
with:
enableCrossOsArchive: true
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
- name: Install prerequisites
run: |
pacman -S --noconfirm mingw-w64-x86_64-ninja
- name: Fetch repo contents
uses: actions/checkout@v4
with:
path: sdk
submodules: recursive
- name: Build and package PSn00bSDK
run: |
cmake --preset ci -S sdk -G "Visual Studio 17 2022" -DPSN00BSDK_TC=${{ github.workspace }}\gcc\windows
cmake --build build
cmake --build build -t package
# The GitHub Actions UI doesn't allow downloading individual files from
# an artifact, so it's best to upload each package type as a separate
# artifact.
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: psn00bsdk-windows
path: build/packages/*.zip
build-sdk-linux:
name: Build PSn00bSDK on Linux
runs-on: ubuntu-latest
needs: build-gcc
steps:
- name: Initialize toolchain cache
uses: actions/cache@v4
with:
enableCrossOsArchive: true
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
- name: Install prerequisites
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends ninja-build
- name: Fetch repo contents
uses: actions/checkout@v4
with:
path: sdk
submodules: recursive
- name: Build and package PSn00bSDK
run: |
cmake --preset ci -S sdk -G "Ninja" -DPSN00BSDK_TC=${{ github.workspace }}/gcc/linux
cmake --build build
cmake --build build -t package
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: psn00bsdk-linux
path: build/packages/*.zip
# This job takes care of creating a new release and upload the build
# artifacts if the last commit is associated to a tag.
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ build-sdk-windows, build-sdk-linux ]
steps:
- name: Initialize toolchain cache
if: ${{ github.ref_type == 'tag' }}
uses: actions/cache@v4
with:
enableCrossOsArchive: true
key: gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}
path: gcc
- name: Package GCC toolchains
if: ${{ github.ref_type == 'tag' }}
run: |
cd gcc/windows
zip -9 -q -r ../../gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}-windows.zip .
cd ../linux
zip -9 -q -r ../../gcc-${{ env.GCC_TARGET }}-${{ env.GCC_VERSION }}-linux.zip .
- name: Fetch build artifacts
if: ${{ github.ref_type == 'tag' }}
uses: actions/[email protected]
with:
path: .
- name: Publish release
if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v1
with:
#fail_on_unmatched_files: true
files: |
*.zip
psn00bsdk-windows/*
psn00bsdk-linux/*