From 84e289e04cfab41e7b2d5d9b2acdad608ff1a0ed Mon Sep 17 00:00:00 2001 From: tannevaled Date: Fri, 22 May 2026 08:42:43 +0200 Subject: [PATCH] feat(jq): add windows/x86-64 cross-compile pilot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase-0 pilot recipe for the Windows-port architecture sketched at pkgxdev/brewkit#346. Cross-compiles jq from a Linux runner (via pkgxdev/pantry#12984's llvm.org/mingw-w64 toolchain), produces bin/jq.exe, runs it through wine in the test step (via pkgxdev/pantry#12986's headless winehq.org recipe). Build side: - Detect platform via {{hw.platform}}; on windows/* set --host triple + CC=-clang - --disable-onigjq because oniguruma doesn't have a Windows bottle yet (gap tracked in #346); regex jq features disabled on Windows - --disable-shared so the .exe is self-contained (no .dll deps to bundle for the pilot) Test side: - On linux/darwin: same as before — `jq .devs[1].github` returns "jhheider" from the existing test.json fixture - On windows/*: run jq.exe through wine64 with the same fixture - If wine isn't available: fall back to a PE magic-byte check on the produced .exe (best-effort, lets the test pass when wine isn't yet in pantry, auto-upgrades to a real check when it is) Known limitations of this pilot: - Uses jq 1.x semantics; doesn't exercise oniguruma-dependent regex filters on Windows - provides: bin/jq — pantry's audit may complain about bin/jq.exe on Windows. If so we need a brewkit hook to accept platform- appropriate suffixes (e.g. bin/jq → bin/jq.exe on windows/*) - Build dep on llvm.org/mingw-w64 pulled unconditionally; harmless on non-Windows but ideally conditional. Worth fixing in brewkit once #346 settles on conditional-deps semantics. Refs: pkgxdev/brewkit#346, pkgxdev/pantry#12984, pkgxdev/pantry#12986. --- projects/stedolan.github.io/jq/package.yml | 61 +++++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/projects/stedolan.github.io/jq/package.yml b/projects/stedolan.github.io/jq/package.yml index 29003a3ac6..62bae5888a 100644 --- a/projects/stedolan.github.io/jq/package.yml +++ b/projects/stedolan.github.io/jq/package.yml @@ -8,10 +8,15 @@ versions: dependencies: github.com/kkos/oniguruma: 6 + # NOTE on windows/* the build is configured with --disable-onigjq, + # so this dep is unused at runtime there. Tracking the gap at + # pkgxdev/brewkit#346 — once oniguruma has a Windows bottle we + # can re-enable regex support on Windows. build: dependencies: git-scm.org: 2 + llvm.org/mingw-w64: '*' # cross-compiler used only when targeting windows/* script: - run: | if test "{{hw.platform}}" = "darwin"; then @@ -19,12 +24,64 @@ build: git apply props/lgamma_r.diff fi if: <1.7 - - ./configure --disable-maintainer-mode --prefix={{prefix}} + + # Configure step: cross-compile on windows/*, native otherwise. + # Pilot for the cross-compile-from-Linux story sketched in + # pkgxdev/brewkit#346. The Windows path: + # - --host= → autoconf knows we cross-compile + # - CC overridden to the mingw clang driver + # - --disable-onigjq because no Windows oniguruma bottle yet + # - --disable-shared (we want a single self-contained .exe) + - run: | + if [ "{{hw.platform}}" = "windows" ]; then + case "{{hw.arch}}" in + x86-64) TRIPLE=x86_64-w64-mingw32 ;; + aarch64) TRIPLE=aarch64-w64-mingw32 ;; + esac + ./configure \ + --host=$TRIPLE \ + --disable-maintainer-mode \ + --disable-onigjq \ + --disable-shared \ + --prefix={{prefix}} \ + CC=$TRIPLE-clang + else + ./configure --disable-maintainer-mode --prefix={{prefix}} + fi - make -j {{hw.concurrency}} - make install test: - script: test $(jq .devs[1].github < test.json) = '"jhheider"' + # On windows/* we need wine to actually run the cross-compiled + # jq.exe — same pattern as pkgxdev/pantry#12984's test step. + # On other platforms the dep is harmless (just unused). + dependencies: + winehq.org: '*' + script: + - run: | + if [ "{{hw.platform}}" = "windows" ]; then + # Cross-compiled jq.exe — run through wine if available. + if command -v wine64 >/dev/null 2>&1; then + export WINEDEBUG=-all + export WINEDLLOVERRIDES="mscoree=;mshtml=" + export WINEPREFIX=$PWD/.wine + out=$(wine64 {{prefix}}/bin/jq.exe .devs[1].github < test.json 2>&1) + else + # Fallback: verify PE magic on the produced binary only. + echo "wine not available; verifying PE magic only" + magic=$(head -c 2 {{prefix}}/bin/jq.exe | od -An -c | tr -s ' ') + case "$magic" in + *"M Z"*) echo "jq.exe: PE/COFF DOS header OK"; exit 0 ;; + *) echo "jq.exe: NOT a PE binary"; exit 1 ;; + esac + fi + else + out=$(jq .devs[1].github < test.json) + fi + test "$out" = '"jhheider"' +# linux/darwin keep bin/jq; on windows/* the binary is bin/jq.exe. +# Pantry's audit should accept either filename for the same logical +# tool — if it doesn't yet, that's a brewkit hook we'd need. provides: - bin/jq