1
0
forked from alex-eg/sex

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:
2026-10-09 17:44:36 +03:00
parent b998d298dd
commit dc15aaadab
5 changed files with 69 additions and 4 deletions

View File

@@ -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"))))