@@ -169,13 +169,33 @@ jobs:
169169 run : ./bin/test-packaged-gem-manifest
170170
171171 precompiled-gem-build :
172- name : precompiled gem build / ${{ matrix.os }}
172+ name : precompiled gem build / ${{ matrix.label }}
173173 runs-on : ${{ matrix.os }}
174- timeout-minutes : 60
174+ timeout-minutes : 90
175175 strategy :
176176 fail-fast : false
177177 matrix :
178- os : [ubuntu-latest, macos-14]
178+ include :
179+ - os : ubuntu-latest
180+ platform : x86_64-linux
181+ label : linux-x86_64
182+ kind : linux
183+ - os : ubuntu-latest
184+ platform : x86_64-linux-musl
185+ label : linux-musl-x86_64
186+ kind : musl
187+ - os : macos-15-intel
188+ platform : x86_64-darwin
189+ label : macos-x86_64
190+ kind : macos
191+ - os : macos-14
192+ platform : arm64-darwin
193+ label : macos-arm64
194+ kind : macos
195+ - os : windows-latest
196+ platform : x64-mingw-ucrt
197+ label : windows-x64-mingw-ucrt
198+ kind : windows
179199
180200 steps :
181201 - uses : actions/checkout@v4
@@ -187,20 +207,104 @@ jobs:
187207 bundler-cache : true
188208
189209 - name : Set up Rust toolchain
210+ if : ${{ matrix.kind != 'musl' }}
190211 uses : dtolnay/rust-toolchain@stable
191212
213+ - name : Install Rust GNU toolchain for RubyInstaller ABI
214+ if : ${{ matrix.kind == 'windows' }}
215+ shell : pwsh
216+ run : |
217+ rustup toolchain install stable-x86_64-pc-windows-gnu
218+ "RUSTUP_TOOLCHAIN=stable-x86_64-pc-windows-gnu" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
219+
220+ - name : Resolve cargo path for bash steps
221+ if : ${{ matrix.kind == 'windows' }}
222+ shell : pwsh
223+ run : |
224+ $cargo = (Get-Command cargo -ErrorAction Stop).Source
225+ "CARGO=$cargo" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
226+ Write-Host "Resolved cargo executable: $cargo"
227+
192228 - name : Install Rust bindgen dependencies (Linux)
193- if : ${{ runner.os == 'Linux ' }}
229+ if : ${{ matrix.kind == 'linux ' }}
194230 run : sudo apt-get update && sudo apt-get install -y clang libclang-dev pkg-config
195231
196232 - name : Install Rust bindgen dependencies (macOS)
197- if : ${{ runner.os == 'macOS ' }}
233+ if : ${{ matrix.kind == 'macos ' }}
198234 run : |
199235 brew install llvm
200236 echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> "${GITHUB_ENV}"
201237
238+ - name : Install LLVM (bindgen dependency)
239+ if : ${{ matrix.kind == 'windows' }}
240+ uses : KyleMayes/install-llvm-action@v2
241+ with :
242+ version : " 18.1.8"
243+
244+ - name : Configure bindgen include paths for Windows Ruby headers
245+ if : ${{ matrix.kind == 'windows' }}
246+ shell : pwsh
247+ run : |
248+ $shimInclude = (Resolve-Path "ext/lda-ruby-rust/include").Path.Replace('\', '/')
249+ $includeDirs = @($shimInclude)
250+ $devkitRoot = $null
251+
252+ if ($env:RI_DEVKIT) {
253+ $devkitRoot = $env:RI_DEVKIT.Replace('\', '/')
254+ $candidateDirs = @(
255+ "$devkitRoot/ucrt64/include",
256+ "$devkitRoot/mingw64/include",
257+ "$devkitRoot/usr/include"
258+ )
259+ $withStrings = $candidateDirs | Where-Object { Test-Path "$_/strings.h" } | Select-Object -Unique
260+ if ($withStrings) {
261+ $includeDirs += $withStrings
262+ }
263+ }
264+
265+ $bindgenArgList = @("--target=x86_64-w64-windows-gnu")
266+ if ($devkitRoot) {
267+ $bindgenArgList += "--sysroot=$devkitRoot/ucrt64"
268+ }
269+ $bindgenArgList += ($includeDirs | Select-Object -Unique | ForEach-Object { "-I$_" })
270+ $bindgenArgList += @("-msse2", "-mavx")
271+ $bindgenArgs = $bindgenArgList -join " "
272+
273+ "BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-gnu=$bindgenArgs" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
274+ "BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu=$bindgenArgs" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
275+ "BINDGEN_EXTRA_CLANG_ARGS=$bindgenArgs" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
276+
277+ $existingCppFlags = ruby -rrbconfig -e 'print RbConfig::CONFIG.fetch("CPPFLAGS", "")'
278+ $mergedCppFlags = "$existingCppFlags $bindgenArgs".Trim()
279+ "RBCONFIG_CPPFLAGS=$mergedCppFlags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
280+
281+ Write-Host "Configured bindgen extra clang args: $bindgenArgs"
282+ Write-Host "Configured RBCONFIG_CPPFLAGS: $mergedCppFlags"
283+
202284 - name : Build and verify precompiled gem
203- run : ./bin/release-precompiled-artifacts --skip-preflight
285+ if : ${{ matrix.kind != 'musl' }}
286+ shell : bash
287+ run : ./bin/release-precompiled-artifacts --platform "${{ matrix.platform }}" --skip-preflight
288+
289+ - name : Build and verify musl precompiled gem (Alpine container)
290+ if : ${{ matrix.kind == 'musl' }}
291+ env :
292+ PLATFORM : ${{ matrix.platform }}
293+ run : |
294+ docker run --rm \
295+ -e PLATFORM="${PLATFORM}" \
296+ -v "${PWD}:/workspace" \
297+ -w /workspace \
298+ alpine:3.20 \
299+ sh -lc '
300+ set -euo pipefail
301+ apk add --no-cache bash build-base git ruby ruby-dev ruby-bundler rust cargo clang llvm-dev clang17-libclang pkgconf
302+ mkdir -p /workspace/pkg
303+ libclang_path="$(dirname "$(find /usr/lib -name libclang.so | head -n1)")"
304+ export LIBCLANG_PATH="${libclang_path}"
305+ bundle install
306+ ./bin/release-precompiled-artifacts --platform "${PLATFORM}" --skip-preflight
307+ '
204308
205309 rust-scaffold :
206310 name : rust scaffold / ubuntu-latest
0 commit comments