compiler/cm-accomplice: adjust protocol for extra options

Instead of introducing a subtype of `file-dependency` to imply one new
option, add a subtype that has an options table for easier
extensibility. (Thanks to Sam for pointing out that I shouldn't make
this mistake again.)
This commit is contained in:
Matthew Flatt 2015-01-09 09:32:04 -07:00
parent 805cd95049
commit ece9126656
3 changed files with 11 additions and 7 deletions

View File

@ -560,16 +560,16 @@ logger named @racket['cm-accomplice]. The message data is a
the first field's value is @racket[file] and the second field's value the first field's value is @racket[file] and the second field's value
is @racket[#f] (to indicate a non-module dependency). If the is @racket[#f] (to indicate a non-module dependency). If the
@racket[indirect?] argument is true, the data is more specifically an @racket[indirect?] argument is true, the data is more specifically an
instance of a @racketidfont{file-dependency/indirect} prefab structure instance of a @racketidfont{file-dependency/options} prefab structure
type that is a subtype of @racketidfont{file-dependency} with no new type that is a subtype of @racketidfont{file-dependency} with one extra
fields. field: a hash table mapping @racket['indirect] to @racket[#t].
A compilation manager implemented by @racketmodname[compiler/cm] looks A compilation manager implemented by @racketmodname[compiler/cm] looks
for such messages to register an external dependency. In response, the for such messages to register an external dependency. In response, the
compilation manager records (in a @filepath{.dep} file) the path as compilation manager records (in a @filepath{.dep} file) the path as
contributing to the implementation of the module currently being contributing to the implementation of the module currently being
compiled. Afterward, if the registered file is modified, the compiled. Afterward, if the registered file is modified, the
compilation manager will know to recompile the module. An ``indirect'' compilation manager will know to recompile the module. An indirect
dependency has no effect on recompilation, but it can signal to other dependency has no effect on recompilation, but it can signal to other
tools, such as a package-dependency checker, that the dependency is tools, such as a package-dependency checker, that the dependency is
indirect (and should not imply a direct package dependency). indirect (and should not imply a direct package dependency).

View File

@ -16,5 +16,6 @@
'cm-accomplice 'cm-accomplice
(format "file dependency: ~s" f) (format "file dependency: ~s" f)
(if indirect? (if indirect?
`#s((file-dependency/indirect file-dependency 2) ,f ,module?) `#s((file-dependency/options file-dependency 2) ,f ,module?
#hasheq((indirect . #t)))
`#s(file-dependency ,f ,module?)))) `#s(file-dependency ,f ,module?))))

View File

@ -317,7 +317,7 @@
(define-struct ext-reader-guard (proc top) (define-struct ext-reader-guard (proc top)
#:property prop:procedure (struct-field-index proc)) #:property prop:procedure (struct-field-index proc))
(define-struct file-dependency (path module?) #:prefab) (define-struct file-dependency (path module?) #:prefab)
(define-struct (file-dependency/indirect file-dependency) () #:prefab) (define-struct (file-dependency/options file-dependency) (table) #:prefab)
(define (compile-zo* mode roots path src-sha1 read-src-syntax zo-name up-to-date collection-cache) (define (compile-zo* mode roots path src-sha1 read-src-syntax zo-name up-to-date collection-cache)
;; The `path' argument has been converted to .rkt or .ss form, ;; The `path' argument has been converted to .rkt or .ss form,
@ -398,7 +398,10 @@
(path? (file-dependency-path (vector-ref l 2)))) (path? (file-dependency-path (vector-ref l 2))))
(external-dep! (file-dependency-path (vector-ref l 2)) (external-dep! (file-dependency-path (vector-ref l 2))
(file-dependency-module? (vector-ref l 2)) (file-dependency-module? (vector-ref l 2))
(file-dependency/indirect? (vector-ref l 2)))) (and (file-dependency/options? (vector-ref l 2))
(hash-ref (file-dependency/options-table (vector-ref l 2))
'indirect
#f))))
(loop)))) (loop))))
;; Write the code and dependencies: ;; Write the code and dependencies: