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) <noreply@anthropic.com>
This commit is contained in:
parent
25fa181200
commit
92d13c9894
|
|
@ -6,3 +6,14 @@
|
||||||
Makefile filter=header
|
Makefile filter=header
|
||||||
|
|
||||||
*.gds diff=gds
|
*.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
|
||||||
|
|
|
||||||
16
npm/build.sh
16
npm/build.sh
|
|
@ -84,16 +84,6 @@ ncpu() {
|
||||||
fi
|
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
|
if [ $OPT_RELEASE -eq 1 ]; then
|
||||||
EXTRA_CFLAGS="-O2"
|
EXTRA_CFLAGS="-O2"
|
||||||
|
|
@ -171,10 +161,8 @@ build_variant() {
|
||||||
rm -rf "$build_dir"
|
rm -rf "$build_dir"
|
||||||
mkdir -p "$build_dir"
|
mkdir -p "$build_dir"
|
||||||
|
|
||||||
# Strip Windows CRLF line endings on the configure inputs (in the source tree,
|
# configure and scripts/ are kept LF by .gitattributes (eol=lf), so no CRLF
|
||||||
# read by configure; no-op on Linux-native files).
|
# stripping is needed here even on a Windows checkout with core.autocrlf=true.
|
||||||
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
|
|
||||||
|
|
||||||
cd "$build_dir"
|
cd "$build_dir"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue