Rename static build deps to jerboa repos
ober
4aae8d1fd3cf852cc4a5fbd2e3b213cb8f6fa8f4
--- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,9 @@ -# Intermediate Podman image for jemacs-qt static builds. +# Intermediate image for jemacs-qt static builds. # Bakes static Qt6 + QScintilla from source, plus all Chez Scheme -# dependencies (jerboa, jsh, chez-pcre2, chez-scintilla, -# chez-qt) so that subsequent jemacs-qt builds only compile jemacs +# dependencies (jerboa, jsh, jerboa-pcre2, jerboa-scintilla, +# jerboa-qt) so that subsequent jemacs-qt builds only compile jemacs # itself (~5-10 min instead of ~30 min). # -# Build with: -# make podman-deps -# -# Uses Podman --build-context to pull dependency sources without -# copying them into the project directory. - ARG ARCH=x86_64 FROM alpine:3.21 @@ -53,7 +47,7 @@ RUN cd /tmp && \ make -j$(nproc) && make install && \ cd / && rm -rf /tmp/xcb-util-0.4.1* -# Build static OpenSSL (needed by chez-ssl for AWS API calls) +# Build static OpenSSL (needed by jerboa-ssl for AWS API calls) # Alpine's openssl-dev only ships shared libs; we need .a files for the static binary. RUN apk add --no-cache openssl-dev perl && \ OPENSSL_VER=$(apk info openssl 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "3.3.2") && \ @@ -253,20 +247,20 @@ RUN mkdir -p /opt/tree-sitter-grammars && \ build_grammar scheme 6cdh/tree-sitter-scheme main && \ echo "Grammars built:" && ls /opt/tree-sitter-grammars/ -# ── Phase 6: Jerboa/Chez dependencies ────────────────────────────────── +# ── Phase 6: Jerboa dependencies ─────────────────────────────────────── ENV PKG_CONFIG_PATH=/opt/qt6-static/lib/pkgconfig ENV SCHEME=/opt/chez/bin/scheme # Copy dependency sources from build contexts COPY --from=jerboa-src . /deps/jerboa COPY --from=jsh-src . /deps/jsh -COPY --from=pcre2-src . /deps/chez-pcre2 -COPY --from=sci-src . /deps/chez-scintilla -COPY --from=qt-src . /deps/chez-qt +COPY --from=pcre2-src . /deps/jerboa-pcre2 +COPY --from=sci-src . /deps/jerboa-scintilla +COPY --from=qt-src . /deps/jerboa-qt RUN mkdir -p /deps/qt-shim COPY support/vendor-overrides/qt_shim.cpp support/vendor-overrides/qt_shim.h /deps/qt-shim/ -# qt_chez_shim.c is maintained in support/vendor-overrides/ (not in chez-qt). -COPY support/vendor-overrides/qt_chez_shim.c support/vendor-overrides/qt_shim.h /deps/chez-qt/ +# qt_chez_shim.c is maintained in support/vendor-overrides/ (not in jerboa-qt). +COPY support/vendor-overrides/qt_chez_shim.c support/vendor-overrides/qt_shim.h /deps/jerboa-qt/ # jerboa-shell keeps these support libraries as jerbuild input files. # Transpile only the libraries imported by support/static-precompile-deps.ss. @@ -278,19 +272,19 @@ RUN mkdir -p /tmp/jsh-jerbuild-src/compat /tmp/jsh-jerbuild-src/jsh && \ --script /deps/jsh/support/jerbuild.ss /tmp/jsh-jerbuild-src /deps/jsh/src --force && \ rm -rf /tmp/jsh-jerbuild-src -# Pre-compile all Chez library dependencies. +# Pre-compile all Jerboa library dependencies. # These .so files are baked into the image so jemacs builds only # need to compile jemacs-specific modules. COPY support/static-precompile-deps.ss /tmp/static-precompile-deps.ss RUN /opt/chez/bin/scheme \ - --libdirs /deps/jerboa/lib:/deps/jsh/src:/deps/jsh/vendor/jerboa-coreutils/lib:/deps/jsh/vendor/jerboa-awk/lib:/deps/jsh/vendor/jerboa-sed/lib:/deps/chez-pcre2:/deps/chez-scintilla/lib:/deps/chez-qt/lib \ + --libdirs /deps/jerboa/lib:/deps/jsh/src:/deps/jsh/vendor/jerboa-coreutils/lib:/deps/jsh/vendor/jerboa-awk/lib:/deps/jsh/vendor/jerboa-sed/lib:/deps/jerboa-pcre2:/deps/jerboa-scintilla/lib:/deps/jerboa-qt/lib \ --compile-imported-libraries \ --script /tmp/static-precompile-deps.ss # Build static pcre2 shim object RUN PCRE2_CFLAGS=$(pkg-config --cflags libpcre2-8 2>/dev/null || echo "") && \ - gcc -c -O2 -o /deps/chez-pcre2/pcre2_shim.o \ - /deps/chez-pcre2/jerboa_pcre2_shim.c $PCRE2_CFLAGS -Wall + gcc -c -O2 -o /deps/jerboa-pcre2/pcre2_shim.o \ + /deps/jerboa-pcre2/jerboa_pcre2_shim.c $PCRE2_CFLAGS -Wall # Build static jsh FFI shim object RUN gcc -c -O2 -o /deps/jsh/jsh_ffi_shim.o /deps/jsh/ffi-shim.c -Wall @@ -299,8 +293,8 @@ RUN gcc -c -O2 -o /deps/jsh/jsh_ffi_shim.o /deps/jsh/ffi-shim.c -Wall RUN QT_CFLAGS=$(pkg-config --cflags Qt6Widgets 2>/dev/null || \ echo "-I/opt/qt6-static/include -I/opt/qt6-static/include/QtCore \ -I/opt/qt6-static/include/QtGui -I/opt/qt6-static/include/QtWidgets") && \ - gcc -c -O2 -fPIC -o /deps/chez-qt/qt_chez_shim.o \ - /deps/chez-qt/qt_chez_shim.c \ + gcc -c -O2 -fPIC -o /deps/jerboa-qt/qt_chez_shim.o \ + /deps/jerboa-qt/qt_chez_shim.c \ -I/deps/qt-shim $QT_CFLAGS -Wall # Build static libqt_shim.a from qt_shim.cpp --- a/Makefile +++ b/Makefile @@ -1267,15 +1267,26 @@ linux-static-tui-podman: vendor-deps ensure-podman-deps # Static TUI via the native Linux musl toolchain. # ============================================================================= -MUSL_CHEZ_DIR = $(shell ls -d /build/chez-musl/lib/csv*/ta6le 2>/dev/null | head -1) -MUSL_SCHEME = /usr/local/bin/scheme +MUSL_CHEZ_ROOT ?= $(shell for d in /build/chez-musl "$(HOME)/chez-musl"; do \ + if [ -x "$$d/bin/scheme" ]; then printf '%s\n' "$$d"; break; fi; \ + done) +MUSL_SCHEME ?= $(if $(MUSL_CHEZ_ROOT),$(MUSL_CHEZ_ROOT)/bin/scheme,/usr/local/bin/scheme) +MUSL_CHEZ_DIR ?= $(shell scheme_root=$$(dirname "$$(dirname "$(MUSL_SCHEME)")"); \ + for d in "$$scheme_root" "$(MUSL_CHEZ_ROOT)" /build/chez-musl "$(HOME)/chez-musl"; do \ + if [ -n "$$d" ] && [ -d "$$d" ]; then ls -d "$$d"/lib/csv*/ta6le 2>/dev/null && break; fi; \ + done | head -1) MUSL_DEPS ?= $(VENDOR) MUSL_JERBOA ?= $(MUSL_DEPS)/jerboa MUSL_PCRE2 ?= $(MUSL_DEPS)/jerboa-pcre2 MUSL_SCINTILLA ?= $(MUSL_DEPS)/jerboa-scintilla MUSL_JSH_ROOT ?= $(MUSL_DEPS)/jerboa-shell MUSL_JSH ?= $(MUSL_JSH_ROOT)/src -MUSL_SCI_VENDOR ?= /build/sci-vendor +MUSL_SCI_VENDOR ?= $(SCINTILLA_VENDOR) +QT_STATIC_PREFIX ?= /opt/qt6-static +QT_STATIC_SHIM_DIR ?= /opt/qt-shim +TREE_SITTER_STATIC_INCLUDE ?= /opt/tree-sitter-include +TREE_SITTER_STATIC_LIB ?= /opt/tree-sitter-lib +TREE_SITTER_STATIC_GRAMMARS ?= /opt/tree-sitter-grammars linux-tui: linux-tui-local @@ -1283,6 +1294,7 @@ linux-tui: linux-tui-local # Dependency sources use the same vendor/ clones as local builds. linux-tui-local: vendor-deps @echo "=== Building jemacs static TUI on this Linux host ===" + $(MAKE) scintilla-vendor-deps rm -f src/.jerbuild-hashes find lib -name '*.so' -o -name '*.wpo' | xargs rm -f 2>/dev/null; true find src/jerboa-emacs -name '*.ss' | sed 's|src/|lib/|; s|\.ss$$|.sls|' | xargs rm -f 2>/dev/null; true @@ -1356,20 +1368,18 @@ linux-tui-local: vendor-deps linux-qt: check-static-qt-local-deps linux-qt-local -# Native Linux musl Qt build prerequisites. -# Qt6 static libs are at /opt/qt6-static. -# Tree-sitter is at /opt/tree-sitter-*. -# Pre-compiled libqt_shim.a is at /opt/qt-shim/. +# Native Linux musl Qt build prerequisites. Static Qt, tree-sitter, and +# qt-shim locations are overridable with the QT_STATIC_* and TREE_SITTER_* +# variables above. check-static-qt-local-deps: @test "$$(uname -s)" = Linux || { echo "ERROR: static-qt must run on a Linux target host."; exit 1; } @test -x "$(MUSL_SCHEME)" || { echo "ERROR: missing $(MUSL_SCHEME) for static-qt."; exit 1; } - @test -n "$(MUSL_CHEZ_DIR)" || { echo "ERROR: missing musl Chez directory under /build/chez-musl/lib/csv*/ta6le."; exit 1; } - @test -d /opt/qt6-static || { echo "ERROR: missing /opt/qt6-static for static-qt."; exit 1; } - @test -d /opt/qt-shim || { echo "ERROR: missing /opt/qt-shim for static-qt."; exit 1; } - @test -d /opt/tree-sitter-include || { echo "ERROR: missing /opt/tree-sitter-include for static-qt."; exit 1; } - @test -d /opt/tree-sitter-lib || { echo "ERROR: missing /opt/tree-sitter-lib for static-qt."; exit 1; } - @test -d /opt/tree-sitter-grammars || { echo "ERROR: missing /opt/tree-sitter-grammars for static-qt."; exit 1; } - @test -d "$(MUSL_SCI_VENDOR)" || { echo "ERROR: missing $(MUSL_SCI_VENDOR) for static-qt."; exit 1; } + @test -n "$(MUSL_CHEZ_DIR)" || { echo "ERROR: missing musl Chez directory for $(MUSL_SCHEME)."; exit 1; } + @test -d "$(QT_STATIC_PREFIX)" || { echo "ERROR: missing $(QT_STATIC_PREFIX) for static-qt; set QT_STATIC_PREFIX=..."; exit 1; } + @test -d "$(QT_STATIC_SHIM_DIR)" || { echo "ERROR: missing $(QT_STATIC_SHIM_DIR) for static-qt; set QT_STATIC_SHIM_DIR=..."; exit 1; } + @test -d "$(TREE_SITTER_STATIC_INCLUDE)" || { echo "ERROR: missing $(TREE_SITTER_STATIC_INCLUDE) for static-qt; set TREE_SITTER_STATIC_INCLUDE=..."; exit 1; } + @test -d "$(TREE_SITTER_STATIC_LIB)" || { echo "ERROR: missing $(TREE_SITTER_STATIC_LIB) for static-qt; set TREE_SITTER_STATIC_LIB=..."; exit 1; } + @test -d "$(TREE_SITTER_STATIC_GRAMMARS)" || { echo "ERROR: missing $(TREE_SITTER_STATIC_GRAMMARS) for static-qt; set TREE_SITTER_STATIC_GRAMMARS=..."; exit 1; } linux-qt-local: vendor-deps @echo "=== Building jemacs-qt static on this Linux host ===" @@ -1462,7 +1472,7 @@ linux-qt-local: vendor-deps fi # Build tree-sitter C shim objects mkdir -p /tmp/jemacs-build - gcc -c -O2 -I/opt/tree-sitter-include -o /tmp/jemacs-build/treesitter_shim.o \ + gcc -c -O2 -I$(TREE_SITTER_STATIC_INCLUDE) -o /tmp/jemacs-build/treesitter_shim.o \ support/treesitter_shim.c -Wall gcc -c -O2 -o /tmp/jemacs-build/treesitter_queries.o \ support/treesitter_queries.c -Wall @@ -1475,15 +1485,15 @@ linux-qt-local: vendor-deps JERBOA_PCRE2_DIR=$(MUSL_PCRE2) \ JERBOA_SCINTILLA_DIR=$(MUSL_SCINTILLA)/src \ JERBOA_QT_DIR=/tmp/jemacs-build/jerboa-qt \ - JERBOA_QT_SHIM_DIR=/opt/qt-shim \ + JERBOA_QT_SHIM_DIR=$(QT_STATIC_SHIM_DIR) \ JSH_COREUTILS_LIB=support/vendor-overrides/libjsh_coreutils_stub.a \ $(AWS_LOCAL_STATIC_ENV) \ - TREE_SITTER_INCLUDE=/opt/tree-sitter-include \ - TREE_SITTER_LIB=/opt/tree-sitter-lib \ - TREE_SITTER_GRAMMARS=/opt/tree-sitter-grammars \ + TREE_SITTER_INCLUDE=$(TREE_SITTER_STATIC_INCLUDE) \ + TREE_SITTER_LIB=$(TREE_SITTER_STATIC_LIB) \ + TREE_SITTER_GRAMMARS=$(TREE_SITTER_STATIC_GRAMMARS) \ TREE_SITTER_SHIM_OBJ=/tmp/jemacs-build/treesitter_shim.o \ TREE_SITTER_QUERIES_OBJ=/tmp/jemacs-build/treesitter_queries.o \ - PKG_CONFIG_PATH=/opt/qt6-static/lib/pkgconfig \ + PKG_CONFIG_PATH=$(QT_STATIC_PREFIX)/lib/pkgconfig \ $(MUSL_SCHEME) \ --libdirs lib:$(MUSL_JERBOA)/lib:$(MUSL_JSH):$(COREUTILS):$(JSH_AWK):$(JSH_SED):$(JERBOA_SSH):$(JERBOA_SQLITE):$(JERBOA_CRYPTO):$(JERBOA_FUSE):$(MUSL_PCRE2):$(MUSL_SCINTILLA)/src:/tmp/jemacs-build/jerboa-qt$(AWS_LOCAL_STATIC_LIBDIRS) \ --script build-binary-qt.ss --- a/src/jerboa-emacs/pregexp-compat.ss +++ b/src/jerboa-emacs/pregexp-compat.ss @@ -1,12 +1,12 @@ ;;; -*- Gerbil -*- -;;; Pregexp compatibility layer backed by chez-pcre2 (PCRE2 with JIT). +;;; Pregexp compatibility layer backed by jerboa-pcre2 (PCRE2 with JIT). ;;; ;;; Exports the same API as :std/pregexp so callers don't need to change: ;;; pregexp, pregexp-match, pregexp-match-positions, ;;; pregexp-replace, pregexp-replace*, pregexp-quote, pregexp-split. ;;; ;;; The JIT match bug (PCRE2_ZERO_TERMINATED passed to pcre2_jit_match_8, -;;; which requires an actual byte length) was fixed in chez-pcre by +;;; which requires an actual byte length) was fixed in jerboa-pcre2 by ;;; replacing it with strlen(subject). ;;; ;;; Backreference translation: :std/pregexp uses \N in replacement strings