From 1423be581dccc572628b7edd43c57aa9f917bc4e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 29 Jun 2013 18:38:17 -0600 Subject: [PATCH] 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). --- .../lib/collects/setup/private/pkg-deps.rkt | 46 ++++++++++--------- racket/lib/collects/setup/setup-unit.rkt | 11 +++-- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/racket/lib/collects/setup/private/pkg-deps.rkt b/racket/lib/collects/setup/private/pkg-deps.rkt index 118b4c0552..9b35f22336 100644 --- a/racket/lib/collects/setup/private/pkg-deps.rkt +++ b/racket/lib/collects/setup/private/pkg-deps.rkt @@ -184,6 +184,7 @@ ;; ---------------------------------------- ;; Check use of `mod' (in `mode') from `pkg' by file `f': + (define reported (make-hash)) (define (check mod mode pkg f) (define src-pkg (or (hash-ref mod-pkg mod #f) 'core)) @@ -202,19 +203,22 @@ 'run)) mode)) (hash)) - (setup-fprintf (current-error-port) #f - (string-append - "found undeclared dependency:\n" - " mode: ~s\n" - " for package: ~s\n" - " on package: ~s\n" - " dependent source: ~a\n" - " used module: ~s") - mode - pkg - src-pkg - f - mod)))) + (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 + (string-append + "found undeclared dependency:\n" + " mode: ~s\n" + " for package: ~s\n" + " on package: ~s\n" + " dependent source: ~a\n" + " used module: ~s") + mode + pkg + src-pkg + f + mod))))) ;; For each collection, set up package info: (for ([path (in-list paths)]) @@ -243,13 +247,6 @@ (regexp-match? #rx#"_scrbl[.]dep$" (path-element->bytes f))) 'build '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 ;; submodules like `test'): (when (eq? mode 'run) @@ -286,7 +283,14 @@ (for-each loop (append (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: (unless (zero? (hash-count missing)) diff --git a/racket/lib/collects/setup/setup-unit.rkt b/racket/lib/collects/setup/setup-unit.rkt index 6aff97a3c3..cca26cd781 100644 --- a/racket/lib/collects/setup/setup-unit.rkt +++ b/racket/lib/collects/setup/setup-unit.rkt @@ -472,10 +472,13 @@ (for ([cc (in-list collections-to-compile)]) (hash-set! ht cc #t)) (define (lookup-children-ccs! cc children) - (for ([child (in-list children)]) - (for ([cc (in-list (collection->ccs (append (cc-collection cc) (list child))))]) - (hash-set! ht cc #t))) - null) + (apply + append + (for/list ([child (in-list children)]) + (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!) (for/list ([v (in-hash-keys ht)]) v))