From 0dcb4ddd2e1dd53ce03a3216c71b17554732e6ab Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 12 Nov 2013 15:30:56 +0100 Subject: ship build: #@include a file only once --- ship/build | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'ship/build') diff --git a/ship/build b/ship/build index 7755253d..62be4e8f 100755 --- a/ship/build +++ b/ship/build @@ -20,14 +20,24 @@ build() { esac } +### +### macros +### + ## usage: #@include \([0-9A-Za-z]\+\) -> build_include \1 \2 -build_include() { cat< build_info \1 @@ -39,6 +49,10 @@ $1a\\ EOF } +### +### main subroutines +### + ## usage: build_compile SRCFILE DSTFILE build_compile() { @@ -57,12 +71,16 @@ t;s:^ *\\([0-9]\\+\\) .*:echo \\1p: SRCFILE="$1" setf src '$(cat "$%s")' SRCFILE + buildcache_initialize "$2" + while echo "$src" | grep -q "$unexpanded_macros_pattern"; do setf sedgen '$(echo "$%s" | nl -b a -s \ | sed "$%s")' src input_parser setf sedscript '$(eval "$%s")' sedgen setf src '$(echo "$%s" | sed -n "$%s")' src sedscript done + buildcache_finalize + echo "$src" > "$2" chmod +x "$2" } @@ -85,6 +103,10 @@ build_deps() { done | sort | uniq } +### +### misc utilities +### + ## usage: build_resolve LIBNAME build_resolve() { echo "$BUILD_PATH" | tr : \\n | @@ -121,5 +143,37 @@ setf() { fi >&2 } -## main +### +### buildcache utilities +### + +## usage: buildcache_initialize DESTFILE +buildcache_initialize() { + buildcache="$1.buildcache" + cat /dev/null > "$buildcache" +} + +## usage: buildcache_finalize +buildcache_finalize() { + if test "${debug-false}" != true; then + rm "$buildcache" + fi +} + +## usage: buildcache_has BRE +# Check if buildcache contains a line matching BRE. +buildcache_has() { + grep -q "^$1" "$buildcache" +} + +## usage: buildcache_add LINE +# Add LINE to buildcache. +buildcache_add() { + echo "$1" >> "$buildcache" +} + +### +### main invocation +### + build "$@" -- cgit v1.2.3