raco setup: fix dependency checking for more nested directories

I'm not sure why a problem with the "package closure" operation
didn't create problems earlier for `raco setup' --- or maybe it
did, but they're difficult to see.

Also, reduce redundancy in reporting of reasons for dependency
mismatches (but keep multiple reports of the same missing
dependency but for different reasons).
This commit is contained in:
Matthew Flatt 2013-06-29 18:38:17 -06:00
parent 19dc3a00ff
commit 1423be581d
2 changed files with 32 additions and 25 deletions

View File

@ -184,6 +184,7 @@
;; ---------------------------------------- ;; ----------------------------------------
;; Check use of `mod' (in `mode') from `pkg' by file `f': ;; Check use of `mod' (in `mode') from `pkg' by file `f':
(define reported (make-hash))
(define (check mod mode pkg f) (define (check mod mode pkg f)
(define src-pkg (or (hash-ref mod-pkg mod #f) (define src-pkg (or (hash-ref mod-pkg mod #f)
'core)) 'core))
@ -202,6 +203,9 @@
'run)) 'run))
mode)) mode))
(hash)) (hash))
(define key (list pkg src-pkg (path-replace-suffix f #"") mod))
(unless (hash-ref reported key #f)
(hash-set! reported key #t)
(setup-fprintf (current-error-port) #f (setup-fprintf (current-error-port) #f
(string-append (string-append
"found undeclared dependency:\n" "found undeclared dependency:\n"
@ -214,7 +218,7 @@
pkg pkg
src-pkg src-pkg
f f
mod)))) mod)))))
;; For each collection, set up package info: ;; For each collection, set up package info:
(for ([path (in-list paths)]) (for ([path (in-list paths)])
@ -243,13 +247,6 @@
(regexp-match? #rx#"_scrbl[.]dep$" (path-element->bytes f))) (regexp-match? #rx#"_scrbl[.]dep$" (path-element->bytes f)))
'build 'build
'run)) 'run))
;; Treat everything in ".dep" as 'build mode...
(for ([dep (in-list deps)])
(when (and (pair? dep)
(eq? 'collects (car dep)))
(define path-strs (map bytes->string/utf-8 (cdr dep)))
(define mod `(lib ,(string-join path-strs "/")))
(check mod 'build pkg f)))
;; Look at the actual module for 'run mode (dropping ;; Look at the actual module for 'run mode (dropping
;; submodules like `test'): ;; submodules like `test'):
(when (eq? mode 'run) (when (eq? mode 'run)
@ -286,7 +283,14 @@
(for-each loop (for-each loop
(append (append
(module-compiled-submodules mod-code #t) (module-compiled-submodules mod-code #t)
(module-compiled-submodules mod-code #f)))))))))))) (module-compiled-submodules mod-code #f)))))))
;; Treat everything in ".dep" as 'build mode...
(for ([dep (in-list deps)])
(when (and (pair? dep)
(eq? 'collects (car dep)))
(define path-strs (map bytes->string/utf-8 (cdr dep)))
(define mod `(lib ,(string-join path-strs "/")))
(check mod 'build pkg f))))))))
;; Report result summary and (optionally) repair: ;; Report result summary and (optionally) repair:
(unless (zero? (hash-count missing)) (unless (zero? (hash-count missing))

View File

@ -472,10 +472,13 @@
(for ([cc (in-list collections-to-compile)]) (for ([cc (in-list collections-to-compile)])
(hash-set! ht cc #t)) (hash-set! ht cc #t))
(define (lookup-children-ccs! cc children) (define (lookup-children-ccs! cc children)
(for ([child (in-list children)]) (apply
(for ([cc (in-list (collection->ccs (append (cc-collection cc) (list child))))]) append
(hash-set! ht cc #t))) (for/list ([child (in-list children)])
null) (for/list ([cc (in-list (collection->ccs (append (cc-collection cc) (list child))))]
#:unless (hash-ref ht cc #f))
(hash-set! ht cc #t)
cc))))
(collection-closure collections-to-compile lookup-children-ccs!) (collection-closure collections-to-compile lookup-children-ccs!)
(for/list ([v (in-hash-keys ht)]) v)) (for/list ([v (in-hash-keys ht)]) v))