|
| 1 | +name: Setup Build Environment |
| 2 | +description: Install system dependencies for building |
| 3 | +runs: |
| 4 | + using: composite |
| 5 | + steps: |
| 6 | + - name: Install Linux dependencies |
| 7 | + if: runner.os == 'Linux' |
| 8 | + shell: bash |
| 9 | + run: | |
| 10 | + sudo apt-get update |
| 11 | + sudo apt-get install -y libsqlite3-dev |
| 12 | +
|
| 13 | + - name: Install macOS cross-build toolchains |
| 14 | + if: runner.os == 'macOS' |
| 15 | + shell: bash |
| 16 | + run: | |
| 17 | + set -euo pipefail |
| 18 | +
|
| 19 | + if ! command -v zig >/dev/null 2>&1; then |
| 20 | + brew install zig |
| 21 | + fi |
| 22 | +
|
| 23 | + if ! command -v cargo-zigbuild >/dev/null 2>&1; then |
| 24 | + cargo install cargo-zigbuild --locked |
| 25 | + fi |
| 26 | +
|
| 27 | + llvm_mingw_version="20260324" |
| 28 | + archive="llvm-mingw-${llvm_mingw_version}-ucrt-macos-universal.tar.xz" |
| 29 | + archive_path="$RUNNER_TEMP/$archive" |
| 30 | + tool_root="$RUNNER_TEMP/llvm-mingw-${llvm_mingw_version}-ucrt-macos-universal" |
| 31 | +
|
| 32 | + if [ ! -d "$tool_root" ]; then |
| 33 | + curl -L "https://github.com/mstorsjo/llvm-mingw/releases/download/${llvm_mingw_version}/${archive}" -o "$archive_path" |
| 34 | + tar -xf "$archive_path" -C "$RUNNER_TEMP" |
| 35 | + fi |
| 36 | +
|
| 37 | + echo "$tool_root/bin" >> "$GITHUB_PATH" |
| 38 | + { |
| 39 | + echo "CC_x86_64_pc_windows_gnullvm=$tool_root/bin/x86_64-w64-mingw32-clang" |
| 40 | + echo "CXX_x86_64_pc_windows_gnullvm=$tool_root/bin/x86_64-w64-mingw32-clang++" |
| 41 | + echo "CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER=$tool_root/bin/x86_64-w64-mingw32-clang" |
| 42 | + echo "AR_x86_64_pc_windows_gnullvm=$tool_root/bin/llvm-ar" |
| 43 | + echo "RANLIB_x86_64_pc_windows_gnullvm=$tool_root/bin/llvm-ranlib" |
| 44 | + echo "CC_aarch64_pc_windows_gnullvm=$tool_root/bin/aarch64-w64-mingw32-clang" |
| 45 | + echo "CXX_aarch64_pc_windows_gnullvm=$tool_root/bin/aarch64-w64-mingw32-clang++" |
| 46 | + echo "CARGO_TARGET_AARCH64_PC_WINDOWS_GNULLVM_LINKER=$tool_root/bin/aarch64-w64-mingw32-clang" |
| 47 | + echo "AR_aarch64_pc_windows_gnullvm=$tool_root/bin/llvm-ar" |
| 48 | + echo "RANLIB_aarch64_pc_windows_gnullvm=$tool_root/bin/llvm-ranlib" |
| 49 | + } >> "$GITHUB_ENV" |
| 50 | +
|
| 51 | + - name: Install Windows gnullvm toolchain |
| 52 | + if: runner.os == 'Windows' && contains(env.TARGET, 'windows-gnullvm') |
| 53 | + shell: pwsh |
| 54 | + run: | |
| 55 | + $llvmMingwVersion = "20260324" |
| 56 | + $archive = switch ($env:TARGET) { |
| 57 | + "x86_64-pc-windows-gnullvm" { "llvm-mingw-$llvmMingwVersion-ucrt-x86_64.zip" } |
| 58 | + "aarch64-pc-windows-gnullvm" { "llvm-mingw-$llvmMingwVersion-ucrt-aarch64.zip" } |
| 59 | + default { throw "Unsupported Windows gnullvm target: $env:TARGET" } |
| 60 | + } |
| 61 | + $uri = "https://github.com/mstorsjo/llvm-mingw/releases/download/$llvmMingwVersion/$archive" |
| 62 | + $archivePath = Join-Path $env:RUNNER_TEMP $archive |
| 63 | + $installRoot = Join-Path $env:RUNNER_TEMP "llvm-mingw" |
| 64 | + Invoke-WebRequest -Uri $uri -OutFile $archivePath |
| 65 | + Expand-Archive -LiteralPath $archivePath -DestinationPath $installRoot -Force |
| 66 | + $toolRoot = Get-ChildItem -Path $installRoot -Directory | Select-Object -First 1 |
| 67 | + "$($toolRoot.FullName)\bin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 |
| 68 | +
|
| 69 | + if ($env:TARGET -eq "x86_64-pc-windows-gnullvm") { |
| 70 | + "CC_x86_64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\x86_64-w64-mingw32-clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 71 | + "CXX_x86_64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\x86_64-w64-mingw32-clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 72 | + "CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER=$($toolRoot.FullName)\bin\x86_64-w64-mingw32-clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 73 | + "AR_x86_64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\llvm-ar.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 74 | + "RANLIB_x86_64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\llvm-ranlib.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 75 | + } else { |
| 76 | + "CC_aarch64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\aarch64-w64-mingw32-clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 77 | + "CXX_aarch64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\aarch64-w64-mingw32-clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 78 | + "CARGO_TARGET_AARCH64_PC_WINDOWS_GNULLVM_LINKER=$($toolRoot.FullName)\bin\aarch64-w64-mingw32-clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 79 | + "AR_aarch64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\llvm-ar.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 80 | + "RANLIB_aarch64_pc_windows_gnullvm=$($toolRoot.FullName)\bin\llvm-ranlib.exe" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 81 | + } |
0 commit comments