From c135647d9c7c9be0354d670bab8fc1f631fa5a9c Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Tue, 14 Jul 2020 13:33:35 -0400 Subject: [PATCH] Support -l for raco make. (#2091) * Support `raco make -l ` by analogy to `racket -l `. --- pkgs/compiler-lib/compiler/commands/make.rkt | 25 ++++++++++++++++---- pkgs/compiler-test/tests/compiler/make.rkt | 4 +++- pkgs/racket-doc/scribblings/raco/make.scrbl | 5 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/pkgs/compiler-lib/compiler/commands/make.rkt b/pkgs/compiler-lib/compiler/commands/make.rkt index f9b7f3a611..af2af53f50 100644 --- a/pkgs/compiler-lib/compiler/commands/make.rkt +++ b/pkgs/compiler-lib/compiler/commands/make.rkt @@ -21,11 +21,16 @@ (define assume-primitives (make-parameter #t)) (define worker-count (make-parameter 1)) +(define coll-paths (make-parameter null)) + (define mzc-symbol (string->symbol (short-program+command-name))) -(define source-files +(define source-file-paths (command-line #:program (short-program+command-name) + #:multi + [("-l") path "Compile interpreted as a collection-based module path" + (coll-paths (cons path (coll-paths)))] #:once-each [("-j") n "Compile with up to tasks in parallel" (let ([num (string->number n)]) @@ -48,7 +53,18 @@ [("--vv") "Very verbose mode" (verbose #t) (very-verbose #t)] - #:args (file . another-file) (cons file another-file))) + #:args files + (when (and (null? files) + (null? (coll-paths))) + (raise-user-error (format "~a: expects at least one file or module path" + (short-program+command-name)))) + files)) + +(define source-files + (append source-file-paths + (for/list ([lib-path (in-list (coll-paths))]) + (resolved-module-path-name + ((current-module-name-resolver) `(lib ,lib-path) #f #f #f))))) (cond ;; Just compile one file: @@ -79,12 +95,13 @@ (when (verbose) (printf " making ~s\n" p)))]) (for ([file source-files]) + (define file-name (if (string? file) file (path->string file))) (unless (file-exists? file) - (error mzc-symbol "file does not exist: ~a" file)) + (error mzc-symbol "file does not exist: ~a" file-name)) (set! did-one? #f) (let ([name (extract-base-filename/ss file mzc-symbol)]) (when (verbose) - (printf "\"~a\":\n" file)) + (printf "\"~a\":\n" file-name)) (parameterize ([compile-context-preservation-enabled (disable-inlining)] [compile-enforce-module-constants diff --git a/pkgs/compiler-test/tests/compiler/make.rkt b/pkgs/compiler-test/tests/compiler/make.rkt index d17d16cbb8..ad481bbdac 100644 --- a/pkgs/compiler-test/tests/compiler/make.rkt +++ b/pkgs/compiler-test/tests/compiler/make.rkt @@ -17,4 +17,6 @@ (delete-directory/files tmpdir) (unless ok? - (error "`raco make` test failed"))) + (error "`raco make -j 2 tmp.rkt` test failed")) + (unless (system* exec-path "-l" "raco" "make" "-l" "racket/base") + (error "`raco make -l racket/base` test failed"))) diff --git a/pkgs/racket-doc/scribblings/raco/make.scrbl b/pkgs/racket-doc/scribblings/raco/make.scrbl index c5b4bde61a..a295e56e38 100644 --- a/pkgs/racket-doc/scribblings/raco/make.scrbl +++ b/pkgs/racket-doc/scribblings/raco/make.scrbl @@ -36,7 +36,10 @@ The @exec{raco make} command accepts a few flags: @itemlist[ - @item{@Flag{j} @nonterm{n} --- Compiles argument modules in parallel, + @item{@Flag{l} @nonterm{path} --- Compiles @nonterm{path} interpreted + as a collection-based module path, as for @racket[require].} + +@item{@Flag{j} @nonterm{n} --- Compiles argument modules in parallel, using up to @nonterm{n} parallel tasks.} @item{@DFlag{disable-inline} --- Disables function inlining while