From 92d13c989464ddc96d43571c9ceca39fa0905920 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Thu, 23 Jul 2026 15:31:18 +0000 Subject: [PATCH] build: enforce LF on build inputs via .gitattributes; drop sed CR-stripping npm/build.sh stripped CRs from configure and every scripts/ file before each WASM build. Its purpose was purely to survive a Windows checkout with core.autocrlf=true (which rewrites LF->CRLF, and bash/make then reject CRLF) -- not reproducible packaging. No tracked build input is CRLF today (`git ls-files --eol` shows only the incidental appimage/rsc/magic.svg), so it never fired on a normal checkout, and it mutated the source tree to do it. Add .gitattributes `eol=lf` for configure, scripts/**, *.sh, *.mak, *.mak.in and Makefile.in. Attributes override core.autocrlf, so git always checks these out as LF regardless of platform -- the authoritative fix -- and the source tree is never rewritten by the build. Remove sed_strip_cr and its call sites. Verified: git check-attr reports eol=lf for configure/scripts/*/*.sh/rules.mak/ Makefile.in; build.sh parses cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitattributes | 11 +++++++++++ npm/build.sh | 16 ++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitattributes b/.gitattributes index f7cb0796..894c5420 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,3 +6,14 @@ Makefile filter=header *.gds diff=gds + +# Keep build/shell scripts and makefiles LF even when checked out on Windows +# (git core.autocrlf=true), or the shell and make reject CRLF. .gitattributes +# overrides core.autocrlf, so this is the authoritative fix and the WASM build +# (npm/build.sh) no longer needs to strip CRs from the source tree. +/configure text eol=lf +/scripts/** text eol=lf +*.sh text eol=lf +*.mak text eol=lf +*.mak.in text eol=lf +Makefile.in text eol=lf diff --git a/npm/build.sh b/npm/build.sh index 72bcc770..1c387cc4 100755 --- a/npm/build.sh +++ b/npm/build.sh @@ -84,16 +84,6 @@ ncpu() { fi } -# Portable in-place sed (BSD sed on macOS disagrees with GNU on -i). -# Uses redirect-back instead of mv so the file's mode bits are preserved -# (configure must stay executable across build.sh invocations). -sed_strip_cr() { - local file=$1 tmp - tmp=$(mktemp) - # Only write back when a CR was actually stripped, so a clean LF checkout is - # left untouched (no mtime bump that could perturb a coexisting native build). - sed 's/\r//' "$file" > "$tmp" && { cmp -s "$tmp" "$file" || cat "$tmp" > "$file"; } && rm "$tmp" -} if [ $OPT_RELEASE -eq 1 ]; then EXTRA_CFLAGS="-O2" @@ -171,10 +161,8 @@ build_variant() { rm -rf "$build_dir" mkdir -p "$build_dir" - # Strip Windows CRLF line endings on the configure inputs (in the source tree, - # read by configure; no-op on Linux-native files). - sed_strip_cr "$REPO_ROOT/configure" - find "$REPO_ROOT/scripts/" -type f -print0 | while IFS= read -r -d '' f; do sed_strip_cr "$f"; done + # configure and scripts/ are kept LF by .gitattributes (eol=lf), so no CRLF + # stripping is needed here even on a Windows checkout with core.autocrlf=true. cd "$build_dir"