Cross-Compilation Build #31
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cross-Compilation Build | |
| on: | |
| workflow_dispatch: | |
| env: | |
| FPC_VERSION: "3.2.2" | |
| jobs: | |
| toolchain: | |
| uses: ./.github/workflows/toolchain.yml | |
| build: | |
| needs: toolchain | |
| runs-on: macos-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-darwin | |
| cpu: x86_64 | |
| os: darwin | |
| - target: x86_64-linux | |
| cpu: x86_64 | |
| os: linux | |
| - target: aarch64-linux | |
| cpu: aarch64 | |
| os: linux | |
| - target: x86_64-win64 | |
| cpu: x86_64 | |
| os: win64 | |
| - target: i386-win32 | |
| cpu: i386 | |
| os: win32 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Restore toolchain cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| fpc-cross | |
| cross-binutils | |
| key: ${{ needs.toolchain.outputs.cache-key }} | |
| fail-on-cache-miss: true | |
| - name: Cross-compile GocciaScript | |
| run: | | |
| set -euo pipefail | |
| PREFIX="$PWD/fpc-cross" | |
| export PATH="$PREFIX/bin:$PWD/cross-binutils/bin:$PATH" | |
| # Verify fpc wrapper is available | |
| echo "FPC wrapper: $(which fpc)" | |
| echo "Target: ${{ matrix.target }}" | |
| # For cross-compilation we call fpc directly with the right flags | |
| # instead of using build.pas (which needs a native fpc to run as | |
| # an instantfpc script). | |
| CPU="${{ matrix.cpu }}" | |
| OS="${{ matrix.os }}" | |
| TARGET="${CPU}-${OS}" | |
| # Determine the cross-compiler binary | |
| case "$CPU" in | |
| x86_64) CROSS_FPC="$PREFIX/lib/fpc/${FPC_VERSION}/ppcrossx64" ;; | |
| i386) CROSS_FPC="$PREFIX/lib/fpc/${FPC_VERSION}/ppcross386" ;; | |
| aarch64) CROSS_FPC="$PREFIX/lib/fpc/${FPC_VERSION}/ppca64" ;; | |
| esac | |
| # Determine extra flags for cross targets | |
| EXTRA_FLAGS="" | |
| case "$OS" in | |
| linux) | |
| EXTRA_FLAGS="-XP${CPU}-linux-" | |
| ;; | |
| win32|win64) | |
| EXTRA_FLAGS="-WG" | |
| ;; | |
| esac | |
| # Set output extension for Windows | |
| EXT="" | |
| if [[ "$OS" == win32 || "$OS" == win64 ]]; then | |
| EXT=".exe" | |
| fi | |
| mkdir -p "build-${TARGET}" | |
| RTL_DIR="$PREFIX/lib/fpc/${FPC_VERSION}/units/${TARGET}/rtl" | |
| OBJPAS_DIR="$PREFIX/lib/fpc/${FPC_VERSION}/units/${TARGET}/rtl-objpas" | |
| GEN_DIR="$PREFIX/lib/fpc/${FPC_VERSION}/units/${TARGET}/rtl-generics" | |
| FCL_DIR="$PREFIX/lib/fpc/${FPC_VERSION}/units/${TARGET}/fcl-process" | |
| # Verify RTL units exist | |
| echo "RTL units: $(ls "$RTL_DIR"/*.ppu 2>/dev/null | wc -l) .ppu files" | |
| echo "rtl-objpas units: $(ls "$OBJPAS_DIR"/*.ppu 2>/dev/null | wc -l) .ppu files" | |
| echo "rtl-generics units: $(ls "$GEN_DIR"/*.ppu 2>/dev/null | wc -l) .ppu files" | |
| echo "fcl-process units: $(ls "$FCL_DIR"/*.ppu 2>/dev/null | wc -l) .ppu files" | |
| # Build each target with the cross-compiler | |
| for src in ScriptLoader.dpr TestRunner.dpr BenchmarkRunner.dpr REPL.dpr; do | |
| name="${src%.dpr}" | |
| echo "" | |
| echo "=== Building ${name} for ${TARGET} ===" | |
| "$CROSS_FPC" -T"${OS}" -O4 -dPRODUCTION -Xs -CX -XX -B \ | |
| -Fu./units -Fu./souffle \ | |
| -Fi./units -Fi./souffle \ | |
| -Fu"$RTL_DIR" -Fu"$OBJPAS_DIR" -Fu"$GEN_DIR" -Fu"$FCL_DIR" \ | |
| -FU"build-${TARGET}" -FE"build-${TARGET}" \ | |
| $EXTRA_FLAGS \ | |
| -dFPC_SOFT_FPUX80 \ | |
| "$src" | |
| echo "${name} built successfully for ${TARGET}" | |
| done | |
| echo "" | |
| echo "=== Build artifacts for ${TARGET} ===" | |
| ls -la "build-${TARGET}/" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gocciascript-${{ matrix.target }} | |
| retention-days: 1 | |
| path: build-${{ matrix.target }}/ |