Support -l for raco make. (#2091)

* Support `raco make -l <path>` by analogy to `racket -l <path>`.
This commit is contained in:
Sam Tobin-Hochstadt 2020-07-14 13:33:35 -04:00 committed by GitHub
parent 3e08f50944
commit c135647d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -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 <path> interpreted as a collection-based module path"
(coll-paths (cons path (coll-paths)))]
#:once-each
[("-j") n "Compile with up to <n> 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

View File

@ -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")))

View File

@ -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