From 00c0f7dee4811a4df04a5f89e68fd7cada541765 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 6 Nov 2013 00:44:26 +0100 Subject: ship build: export debug=true for debug output --- ship/build | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'ship/build') diff --git a/ship/build b/ship/build index 916953cc..31f45061 100755 --- a/ship/build +++ b/ship/build @@ -2,8 +2,8 @@ set -euf ## SYNOPSIS -# build compile SRCFILE DSTFILE -# build deps SRCFILE +# [debug=true] build compile SRCFILE DSTFILE +# [debug=true] build deps SRCFILE build() { case "$1" in compile) build_compile "$2" "$3";; @@ -12,6 +12,16 @@ build() { esac } +# usage: debug_script VARNAME [DESCRIPTION] +debug_script() { + if test "${debug-false}" = true; then + printf '====== %s%s\n%s\n' \ + "$1" \ + "${2+" ($2)"}" \ + "$(eval echo \"\$$1\" | nl -b a)" >&2 + fi +} + ## build directives build_info_directive='#@info' build_include_directive='#@include \([0-9A-Za-z]\+\)' @@ -21,6 +31,7 @@ s:^ *\([0-9]\+\) "$build_info_directive"$:build_info \1: s:^ *\([0-9]\+\) "$build_include_directive"$:build_include \1 \2: t s:^ *\([0-9]\+\) .*:echo \1p:" +debug_script input_parser ## usage: build_include LINENO LIBNAME build_include() { cat< "$2" @@ -66,7 +79,11 @@ needs_compilation() { # directives in SRCFILE. make_sedscript_maker_shellscript() { sedscript_generator="$(echo "$1" | nl -b a -s ' ' | sed "$input_parser")" + debug_script sedscript_generator 'sed input_parser srcfile' + sedscript="$(eval "$sedscript_generator")" + debug_script sedscript 'eval sedscript_generator' + echo "$sedscript" } -- cgit v1.2.3