Skip to content

Commit 3427512

Browse files
committed
ci: Add cross builds
1 parent 408080d commit 3427512

File tree

1 file changed

+189
-2
lines changed

1 file changed

+189
-2
lines changed

.github/workflows/build.yaml

Lines changed: 189 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: "Linux Build"
33
on: [push]
44

55
jobs:
6-
linux:
7-
name: '${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
6+
native:
7+
name: 'Native: ${{ matrix.os }}: ${{ matrix.compiler.vendor }}'
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
fail-fast: false
@@ -109,3 +109,190 @@ jobs:
109109
export TARGET_WORKSPACE="$(pwd)/projects"
110110
source docs/env.sh
111111
make -j"$(nproc)" TARGET=framebuffer
112+
113+
cross:
114+
name: 'Cross: ${{ matrix.build.toolchain }}: ${{ matrix.build.frontend }}'
115+
runs-on: ubuntu-24.04 # Matches toolchains workflow
116+
strategy:
117+
fail-fast: false
118+
matrix:
119+
build:
120+
- { toolchain: arm-riscos-gnueabi, frontend: riscos, pkg-file: netsurf.zip }
121+
- { toolchain: arm-unknown-riscos, frontend: riscos, pkg-file: netsurf.zip }
122+
- { toolchain: i686-w64-mingw32, frontend: windows, pkg-file: netsurf-installer.exe }
123+
- { toolchain: m5475-atari-mint, frontend: atari, pkg-file: nsv4e.zip }
124+
- { toolchain: m68k-atari-mint, frontend: atari, pkg-file: ns020.zip }
125+
- { toolchain: m68k-unknown-amigaos, frontend: amigaos3, pkg-file: NetSurf_Amiga/netsurf.lha }
126+
- { toolchain: ppc-amigaos, frontend: amiga, pkg-file: NetSurf_Amiga/netsurf.lha }
127+
- { toolchain: x86_64-w64-mingw32, frontend: windows, pkg-file: netsurf-installer.exe }
128+
129+
steps:
130+
- name: Checkout repository
131+
uses: actions/checkout@v3
132+
with:
133+
fetch-depth: 1
134+
135+
- name: apt-get install packages
136+
run: sudo apt-get update -qq &&
137+
sudo apt-get install --no-install-recommends -y
138+
bison
139+
build-essential
140+
ccache
141+
check
142+
clang
143+
flex
144+
git
145+
gperf
146+
jlha-utils
147+
libcurl4-openssl-dev
148+
libgtk-3-dev
149+
libhtml-parser-perl
150+
libjpeg-dev
151+
libpng-dev
152+
librsvg2-dev
153+
llvm
154+
nsis
155+
pkg-config
156+
157+
- name: ccache
158+
uses: hendrikmuhs/ccache-action@v1.2
159+
with:
160+
key: ${{ github.job }}-${{ matrix.build.toolchain }}
161+
max-size: 128M
162+
163+
# look for toolchain for this branch name first, then default to master
164+
- name: Download toolchain
165+
run: |
166+
set -e
167+
168+
TOOLCHAIN_NAME="${{ matrix.build.toolchain }}"
169+
BRANCH_NAME="${{ github.ref_name }}"
170+
171+
# Function to try downloading toolchain from a specific tag
172+
download_toolchain() {
173+
local ref="$1"
174+
local download_url="https://github.com/netsurf-browser/toolchains/releases/download/${ref}/${TOOLCHAIN_NAME}.tar.gz"
175+
176+
echo "Trying to download toolchain from ref: $ref"
177+
echo "URL: $download_url"
178+
179+
if curl -f -L -o "${TOOLCHAIN_NAME}.tar.gz" "$download_url"; then
180+
echo "Got toolchain with ref: $ref"
181+
return 0
182+
else
183+
echo "Failed to download toolchain with ref: $ref"
184+
return 1
185+
fi
186+
}
187+
188+
# Try branch-specific toolchain first
189+
safe_branch=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g')
190+
branch_tag="gh-${safe_branch}-unstable"
191+
192+
if download_toolchain "$branch_tag"; then
193+
echo "Downloaded branch-specific toolchain"
194+
elif download_toolchain "gh-master-unstable"; then
195+
echo "Downloaded fallback master toolchain"
196+
else
197+
echo "Failed to download any toolchain variant"
198+
exit 1
199+
fi
200+
201+
- name: Install toolchain
202+
run: |
203+
echo "Installing toolchain: ${{ matrix.build.toolchain }}"
204+
sudo tar -xzf "${{ matrix.build.toolchain }}.tar.gz" -C /
205+
rm "${{ matrix.build.toolchain }}.tar.gz"
206+
echo "Contents of /opt/netsurf/:"
207+
ls -la /opt/netsurf/
208+
echo "Contents of /opt/netsurf/${{ matrix.build.toolchain }}/:"
209+
ls -la /opt/netsurf/${{ matrix.build.toolchain }}/ || true
210+
echo "Contents of /opt/netsurf/${{ matrix.build.toolchain }}/cross/:"
211+
ls -la /opt/netsurf/${{ matrix.build.toolchain }}/cross/ || true
212+
echo "Contents of /opt/netsurf/${{ matrix.build.toolchain }}/cross/bin/:"
213+
ls -la /opt/netsurf/${{ matrix.build.toolchain }}/cross/bin/ || true
214+
215+
- name: Build and install project libs
216+
env:
217+
HOST: "${{ matrix.build.toolchain }}"
218+
TARGET_WORKSPACE: "${{ github.workspace }}/projects" # Same as "$(pwd)/projects"
219+
Q:
220+
run: |
221+
echo "HOST=$HOST"
222+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
223+
224+
echo "Looking for cross-compiler tools..."
225+
echo "Expected path: /opt/netsurf/${HOST}/cross/bin/"
226+
if [ -f "/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc" ]; then
227+
echo "Found: /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc"
228+
echo "Testing if it's executable:"
229+
/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc --version || echo "Failed to execute gcc --version"
230+
echo "Testing dumpmachine output:"
231+
/opt/netsurf/${HOST}/cross/bin/${HOST}-gcc -dumpmachine || echo "Failed to execute gcc -dumpmachine"
232+
else
233+
echo "NOT FOUND: /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc"
234+
fi
235+
236+
echo "Sourcing env.sh with error checking..."
237+
set -e # Exit on any error
238+
if ! source docs/env.sh; then
239+
echo "env.sh failed with exit code $?"
240+
exit 1
241+
fi
242+
echo "env.sh sourced successfully"
243+
echo "BUILD=$BUILD"
244+
echo "HOST=$HOST"
245+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
246+
echo "USE_CPUS=$USE_CPUS"
247+
248+
echo "Cloning libs..."
249+
ns-clone -d -s
250+
echo "Building and installing tools..."
251+
ns-make-tools install
252+
echo "Building and installing libs..."
253+
ns-make-libs install
254+
255+
- name: Build NetSurf
256+
env:
257+
HOST: "${{ matrix.build.toolchain }}"
258+
TARGET_WORKSPACE: "${{ github.workspace }}/projects" # Same as "$(pwd)/projects"
259+
Q:
260+
run: |
261+
set -e
262+
if ! source docs/env.sh; then
263+
echo "env.sh failed with exit code $?"
264+
exit 1
265+
fi
266+
echo "env.sh sourced successfully"
267+
echo "BUILD=$BUILD"
268+
echo "HOST=$HOST"
269+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
270+
echo "USE_CPUS=$USE_CPUS"
271+
make -j"$(nproc)" TARGET=${{ matrix.build.frontend }} Q=
272+
273+
- name: Make package
274+
env:
275+
HOST: "${{ matrix.build.toolchain }}"
276+
TARGET_WORKSPACE: "${{ github.workspace }}/projects" # Same as "$(pwd)/projects"
277+
Q:
278+
run: |
279+
set -e
280+
if ! source docs/env.sh; then
281+
echo "env.sh failed with exit code $?"
282+
exit 1
283+
fi
284+
echo "env.sh sourced successfully"
285+
echo "BUILD=$BUILD"
286+
echo "HOST=$HOST"
287+
echo "TARGET_WORKSPACE=$TARGET_WORKSPACE"
288+
echo "USE_CPUS=$USE_CPUS"
289+
make package TARGET=${{ matrix.build.frontend }} Q=
290+
291+
# Can't avoid `upload-artifact` zipping the package
292+
# https://github.com/actions/upload-artifact/issues/426
293+
- name: Upload artifact
294+
uses: actions/upload-artifact@v4
295+
with:
296+
name: ${{ matrix.build.toolchain }}-${{ matrix.build.frontend }}
297+
path: ${{ matrix.build.pkg-file }}
298+
compression-level: 0 # Avoid pointless recompression

0 commit comments

Comments
 (0)