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:
@@ -78,13 +78,24 @@
|
||||
(file-readable? module-path)
|
||||
module-path))))
|
||||
|
||||
;;; Every module file read for this unit, first read first: what its
|
||||
;;; output depends on, besides the unit itself
|
||||
(define +module-dependencies+ (list))
|
||||
|
||||
(define (module-dependencies) (reverse +module-dependencies+))
|
||||
|
||||
(define (read-module path)
|
||||
(unless (member path +module-dependencies+)
|
||||
(set! +module-dependencies+ (cons path +module-dependencies+)))
|
||||
(read-from-file path))
|
||||
|
||||
(define (read-public-interface module-path)
|
||||
;; pub fns are reduced to prototypes, other pub forms are just pasted.
|
||||
;; Declaration order is kept: a module that declares a type and then a
|
||||
;; pub fn taking it has to paste them that way round, or the prototype
|
||||
;; names a type C has not seen. The declarations of the types its
|
||||
;; importers see only behind a pointer go first.
|
||||
(let ((raw-forms (read-from-file module-path)))
|
||||
(let ((raw-forms (read-module module-path)))
|
||||
(append (check-public-interface raw-forms)
|
||||
(interface-forms raw-forms))))
|
||||
|
||||
@@ -275,7 +286,7 @@
|
||||
(let ((path (locate-module (symbol->string (car modules)))))
|
||||
(if (or (not path) (member path seen))
|
||||
(read (cdr modules) seen acc)
|
||||
(let ((forms (interface-forms (read-from-file path))))
|
||||
(let ((forms (interface-forms (read-module path))))
|
||||
(read (append (cdr modules) (imported-modules forms #f))
|
||||
(cons path seen)
|
||||
(append acc (declared-types forms)))))))))
|
||||
|
||||
Reference in New Issue
Block a user