write a make rule for the modules a unit reads
An import pastes another file's forms into the output, so a Makefile had to make every object depend on every .sex. --depfile names the modules read, including those read only for an import's interface, with an empty rule for each, as cc -MD -MP does. Fixes #40.
This commit is contained in:
@@ -65,3 +65,19 @@
|
||||
(test "any other output is left alone"
|
||||
'("-o" "out" "-")
|
||||
(spell-stdout-output '("-o" "out" "-"))))
|
||||
|
||||
;;; --depfile: an import pastes another file's forms into the output, so
|
||||
;;; the output depends on that file as a C object does on a header
|
||||
(test-group "dependency rule"
|
||||
(test "the target, the source and the modules, then a rule per module"
|
||||
"app.o: app.sex /m/greet.sex /m/ledger.sex\n\n/m/greet.sex:\n\n/m/ledger.sex:\n"
|
||||
(dependency-rule "app.o" "app.sex" '("/m/greet.sex" "/m/ledger.sex")))
|
||||
(test "no modules, no rules of their own"
|
||||
"app.o: app.sex\n"
|
||||
(dependency-rule "app.o" "app.sex" '()))
|
||||
(test "a space is escaped, the way make reads it"
|
||||
"a\\ b.o: a\\ b.sex\n"
|
||||
(dependency-rule "a b.o" "a b.sex" '()))
|
||||
(test "stdin is no file to depend on"
|
||||
"app.o: /m/greet.sex\n\n/m/greet.sex:\n"
|
||||
(dependency-rule "app.o" #f '("/m/greet.sex"))))
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
# to a prototype and to an extern both have to look past. And a type the
|
||||
# app cannot see -- private to greet, or from a module greet imports
|
||||
# without `pub' -- crosses behind a pointer, declared and no more.
|
||||
#
|
||||
# The app's dependency rule names both modules: greet, which it imports,
|
||||
# and ledger, which only greet does but which decides what the app is
|
||||
# told of it.
|
||||
|
||||
SEXC ?= ../../sexc
|
||||
|
||||
@@ -28,7 +32,10 @@ EXPECTED = hello, world\nhello, sex\n2 greetings\ntext times \ntext times \nmood
|
||||
check:
|
||||
@$(SEXC) ledger.sex -c -o ledger.o
|
||||
@$(SEXC) greet.sex -c -o greet.o
|
||||
@$(SEXC) greet-app.sex -o greet-app -- greet.o ledger.o
|
||||
@$(SEXC) greet-app.sex -o greet-app --depfile=greet-app.d -- greet.o ledger.o
|
||||
@if ! head -1 greet-app.d | grep -q '^greet-app: greet-app.sex .*/greet.sex .*/ledger.sex$$'; then \
|
||||
echo "modules FAILED, the dependency rule is:"; cat greet-app.d; $(MAKE) clean; exit 1; \
|
||||
fi
|
||||
@if [ "`./greet-app`" = "`printf '$(EXPECTED)\n'`" ]; then \
|
||||
echo "modules ok"; \
|
||||
else \
|
||||
@@ -37,6 +44,6 @@ check:
|
||||
@$(MAKE) --no-print-directory clean
|
||||
|
||||
clean:
|
||||
@rm -f greet.o ledger.o greet-app
|
||||
@rm -f greet.o ledger.o greet-app greet-app.d
|
||||
|
||||
.PHONY: check clean
|
||||
|
||||
Reference in New Issue
Block a user