From 0db968b3ca9d7efbf49730226f00a3912f4bca17 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 6 Nov 2013 04:01:41 +0100 Subject: ship build: add defvar --- ship/build | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'ship/build') diff --git a/ship/build b/ship/build index ad902231..aa8806ca 100755 --- a/ship/build +++ b/ship/build @@ -12,16 +12,6 @@ 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 -} - ## usage: #@include \([0-9A-Za-z]\+\) -> build_include \1 \2 build_include() { cat< "$2" @@ -77,12 +61,9 @@ needs_compilation() { # Print a shellscript that creates a sedscript that resolves all the build # directives in SRCFILE. make_sedscript_maker_shellscript() { - sedscript_generator="$(echo "$1" | nl -b a -s ' ' | sed "$2")" - debug_script sedscript_generator 'sed input_parser srcfile' - - sedscript="$(eval "$sedscript_generator")" - debug_script sedscript 'eval sedscript_generator' - + defvar sedscript_generator "$(echo "$1" | nl -b a -s ' ' | sed "$2")" \ + 'sed input_parser srcfile' + defvar sedscript "$(eval "$sedscript_generator")" 'eval sedscript_generator' echo "$sedscript" } @@ -151,5 +132,16 @@ make_needs_compilation_sentinel() { )\\)$" } +## usage: defvar NAME VALUE [DESCRIPTION] +defvar() { + eval "$1=\"\$2\"" + if test "${debug-false}" = true; then + printf '====== %s%s\n%s\n' \ + "$1" \ + "${3+" ($3)"}" \ + "$(eval echo \"\$$1\" | nl -b a)" >&2 + fi +} + ## main build "$@" -- cgit v1.2.3