summaryrefslogtreecommitdiffstats
path: root/ship
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-06 05:39:04 +0100
committertv <tv@nomic.retiolum>2013-11-06 05:39:04 +0100
commit4c300189fb47ac203b67904535006cab4c60a7bc (patch)
treea7ea46e74aa90b435ede4b0e679c4faa08138006 /ship
parent0db968b3ca9d7efbf49730226f00a3912f4bca17 (diff)
ship build: purge make_sedscript_maker_shellscript
Diffstat (limited to 'ship')
-rwxr-xr-xship/build47
1 files changed, 20 insertions, 27 deletions
diff --git a/ship/build b/ship/build
index aa8806ca..3fd1469a 100755
--- a/ship/build
+++ b/ship/build
@@ -33,21 +33,23 @@ EOF
## usage: build_compile SRCFILE DSTFILE
build_compile() {
- 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'
+ setf build_directives '$(make_build_directives "$%s")' 0
+ setf build_x_directive_loader '$(make_build_x_directive_loader "$%s")' 0
eval "$build_x_directive_loader"
- defvar input_parser "$(make_input_parser "$0")"
- defvar sentinel "$(make_needs_compilation_sentinel $build_directives)"
+ setf input_parser '$(make_input_parser "$%s")' 0
+ setf sentinel '$(make_needs_compilation_sentinel $%s)' build_directives
- while needs_compilation "$srcfile" "$sentinel"; do
- defvar script "$(make_sedscript_maker_shellscript "$srcfile" "$input_parser")"
- defvar srcfile "$(echo "$srcfile" | sed -n "$script")" 'sed script srcfile'
+ SRCFILE="$1" setf src '$(cat "$%s")' SRCFILE
+
+ while needs_compilation "$src" "$sentinel"; 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
- echo "$srcfile" > "$2"
+ echo "$src" > "$2"
chmod +x "$2"
}
@@ -57,16 +59,6 @@ needs_compilation() {
echo "$1" | grep -q "$2"
}
-## usage: make_sedscript_maker_shellscript SRCFILE INPUT_PARSER
-# Print a shellscript that creates a sedscript that resolves all the build
-# directives in SRCFILE.
-make_sedscript_maker_shellscript() {
- 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"
-}
-
## usage: build_deps SRCFILE...
# Print all the dependencies of SRCFILE... (in alphabetic order) to stdout.
build_deps() {
@@ -132,15 +124,16 @@ make_needs_compilation_sentinel() {
)\\)$"
}
-## usage: defvar NAME VALUE [DESCRIPTION]
-defvar() {
- eval "$1=\"\$2\""
+## usage: setf NAME FMT [ARG...]
+setf() {
+ value_script="$(shift; printf "$@")"
+
+ eval "$1=$value_script"
+
if test "${debug-false}" = true; then
- printf '====== %s%s\n%s\n' \
- "$1" \
- "${3+" ($3)"}" \
- "$(eval echo \"\$$1\" | nl -b a)" >&2
- fi
+ eval 'echo "$1=\"$value_script\""'
+ eval 'echo "'"\$$1"'"' | nl -b a
+ fi >&2
}
## main