summaryrefslogtreecommitdiffstats
path: root/ship
diff options
context:
space:
mode:
Diffstat (limited to 'ship')
-rwxr-xr-xship/build50
1 files changed, 21 insertions, 29 deletions
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<<EOF
$1a\\
@@ -43,24 +33,18 @@ EOF
## usage: build_compile SRCFILE DSTFILE
build_compile() {
- srcfile="$(cat "$1")"
- debug_script srcfile 'SRCFILE'
-
- build_directives="$(make_build_directives "$0")"
- debug_script build_directives '$0'
-
- build_x_directive_loader="$(make_build_x_directive_loader "$0")"
- debug_script build_x_directive_loader '$0'
+ defvar srcfile "$(cat "$1")" 'SRCFILE'
+ defvar build_directives "$(make_build_directives "$0")" '$0'
+ defvar build_x_directive_loader "$(make_build_x_directive_loader "$0")" '$0'
eval "$build_x_directive_loader"
- input_parser="$(make_input_parser "$0")"
- sentinel="$(make_needs_compilation_sentinel $build_directives)"
+ defvar input_parser "$(make_input_parser "$0")"
+ defvar sentinel "$(make_needs_compilation_sentinel $build_directives)"
while needs_compilation "$srcfile" "$sentinel"; do
- script="$(make_sedscript_maker_shellscript "$srcfile" "$input_parser")"
- srcfile="$(echo "$srcfile" | sed -n "$script")"
- debug_script srcfile 'sed sedscript srcfile'
+ defvar script "$(make_sedscript_maker_shellscript "$srcfile" "$input_parser")"
+ defvar srcfile "$(echo "$srcfile" | sed -n "$script")" 'sed script srcfile'
done
echo "$srcfile" > "$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 "$@"