Artifact 27e46bcc23c65608eff1be3385931ad0e8e6493a31739d139cef376cc563363f:
- File
test/pic/amalgam.sh
— part of check-in
[9dabe49948]
at
2026-11-21 19:00:33
on branch amalgam
— Amalgamation: pic as one pic.c beside the vendored sources, built by one cc line
make amalgamation writes pic-amalgamation-VERSION/ and its tarball; make test-amal builds it from the README's own line and runs crash, print and tools against that binary, and is part of make test-pic. About 60 file-local names that collided in one translation unit take their file's prefix; test/pic/amalgam.sh fails on a new collision. (user: dmestas, size: 1887) [annotate] [blame] [check-ins using] [more...]
#!/bin/sh # The amalgamation's rule (docs/dev/amalgamation.md): pic's sources must merge into one # translation unit. Fails when # - a src/*.c or src/tui/*.c is missing from the list in the Makefile (PIC_SRC, passed as args); # - two files define the same static function or variable, typedef, struct, union or enum tag, # or enumerator (a file-local macro is no collision: the generator undefines it at the end of # its file); # - the merged pic.c does not compile under the project's full warning flags, which also catches # a local that shadows another file's static. # Usage: sh test/pic/amalgam.sh FILE.c... (WARN and CC from the environment, as in the Makefile) set -eu cd "$(dirname "$0")/../.." [ $# -gt 0 ] || { echo "usage: amalgam.sh FILE.c..." >&2; exit 2; } rc=0 for f in src/*.c src/tui/*.c; do case " $* " in *" $f "*) ;; *) echo "amalgam: $f is not in PIC_SRC, so it is not in pic.c"; rc=1 ;; esac done dups=$(awk -f test/pic/amalgam-names.awk "$@" | awk '{ n[$1]++; w[$1] = w[$1] " " $3 " (" $2 ")" } END { for (k in n) if (n[k] > 1) print k ":" w[k] }' | sort) if [ -n "$dups" ]; then echo "amalgam: defined in more than one file (rename with the file's prefix, see docs/dev/amalgamation.md):" echo "$dups" | sed 's/^/ /' rc=1 fi tmp=$(mktemp -d "${TMPDIR:-/tmp}/amalgam.XXXXXX") trap 'rm -rf "$tmp"' EXIT INT TERM sh tools/amalgamate.sh -l "$@" > "$tmp/pic.c" # shellcheck disable=SC2086 ${CC:-cc} ${WARN:--std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE -D_GNU_SOURCE -Wno-format-truncation} \ -isystem vendor/libfossil -isystem vendor/zlib -isystem vendor/bearssl/inc -DHAVE_LIBFOSSIL_CONFIG_H \ -fsyntax-only "$tmp/pic.c" || { echo "amalgam: pic.c does not compile"; rc=1; } [ "$rc" = 0 ] && echo "amalgam: ok" exit "$rc"