Skip to content

Commit 84e289e

Browse files
committed
feat(jq): add windows/x86-64 cross-compile pilot
Phase-0 pilot recipe for the Windows-port architecture sketched at pkgxdev/brewkit#346. Cross-compiles jq from a Linux runner (via #12984's llvm.org/mingw-w64 toolchain), produces bin/jq.exe, runs it through wine in the test step (via #12986's headless winehq.org recipe). Build side: - Detect platform via {{hw.platform}}; on windows/* set --host triple + CC=<triple>-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, #12984, #12986.
1 parent e2ad4c1 commit 84e289e

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

projects/stedolan.github.io/jq/package.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,80 @@ versions:
88

99
dependencies:
1010
github.com/kkos/oniguruma: 6
11+
# NOTE on windows/* the build is configured with --disable-onigjq,
12+
# so this dep is unused at runtime there. Tracking the gap at
13+
# pkgxdev/brewkit#346 — once oniguruma has a Windows bottle we
14+
# can re-enable regex support on Windows.
1115

1216
build:
1317
dependencies:
1418
git-scm.org: 2
19+
llvm.org/mingw-w64: '*' # cross-compiler used only when targeting windows/*
1520
script:
1621
- run: |
1722
if test "{{hw.platform}}" = "darwin"; then
1823
git apply props/darwin.diff
1924
git apply props/lgamma_r.diff
2025
fi
2126
if: <1.7
22-
- ./configure --disable-maintainer-mode --prefix={{prefix}}
27+
28+
# Configure step: cross-compile on windows/*, native otherwise.
29+
# Pilot for the cross-compile-from-Linux story sketched in
30+
# pkgxdev/brewkit#346. The Windows path:
31+
# - --host=<triple> → autoconf knows we cross-compile
32+
# - CC overridden to the mingw clang driver
33+
# - --disable-onigjq because no Windows oniguruma bottle yet
34+
# - --disable-shared (we want a single self-contained .exe)
35+
- run: |
36+
if [ "{{hw.platform}}" = "windows" ]; then
37+
case "{{hw.arch}}" in
38+
x86-64) TRIPLE=x86_64-w64-mingw32 ;;
39+
aarch64) TRIPLE=aarch64-w64-mingw32 ;;
40+
esac
41+
./configure \
42+
--host=$TRIPLE \
43+
--disable-maintainer-mode \
44+
--disable-onigjq \
45+
--disable-shared \
46+
--prefix={{prefix}} \
47+
CC=$TRIPLE-clang
48+
else
49+
./configure --disable-maintainer-mode --prefix={{prefix}}
50+
fi
2351
- make -j {{hw.concurrency}}
2452
- make install
2553

2654
test:
27-
script: test $(jq .devs[1].github < test.json) = '"jhheider"'
55+
# On windows/* we need wine to actually run the cross-compiled
56+
# jq.exe — same pattern as pkgxdev/pantry#12984's test step.
57+
# On other platforms the dep is harmless (just unused).
58+
dependencies:
59+
winehq.org: '*'
60+
script:
61+
- run: |
62+
if [ "{{hw.platform}}" = "windows" ]; then
63+
# Cross-compiled jq.exe — run through wine if available.
64+
if command -v wine64 >/dev/null 2>&1; then
65+
export WINEDEBUG=-all
66+
export WINEDLLOVERRIDES="mscoree=;mshtml="
67+
export WINEPREFIX=$PWD/.wine
68+
out=$(wine64 {{prefix}}/bin/jq.exe .devs[1].github < test.json 2>&1)
69+
else
70+
# Fallback: verify PE magic on the produced binary only.
71+
echo "wine not available; verifying PE magic only"
72+
magic=$(head -c 2 {{prefix}}/bin/jq.exe | od -An -c | tr -s ' ')
73+
case "$magic" in
74+
*"M Z"*) echo "jq.exe: PE/COFF DOS header OK"; exit 0 ;;
75+
*) echo "jq.exe: NOT a PE binary"; exit 1 ;;
76+
esac
77+
fi
78+
else
79+
out=$(jq .devs[1].github < test.json)
80+
fi
81+
test "$out" = '"jhheider"'
2882
83+
# linux/darwin keep bin/jq; on windows/* the binary is bin/jq.exe.
84+
# Pantry's audit should accept either filename for the same logical
85+
# tool — if it doesn't yet, that's a brewkit hook we'd need.
2986
provides:
3087
- bin/jq

0 commit comments

Comments
 (0)