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