Skip to content

Commit

Permalink
Support -l for raco make. (racket#2091)
Browse files Browse the repository at this point in the history
* Support `raco make -l <path>` by analogy to `racket -l <path>`.
  • Loading branch information
samth authored Jul 14, 2020
1 parent 3e08f50 commit c135647
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
25 changes: 21 additions & 4 deletions pkgs/compiler-lib/compiler/commands/make.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkgs/compiler-test/tests/compiler/make.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
5 changes: 4 additions & 1 deletion pkgs/racket-doc/scribblings/raco/make.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c135647

Please sign in to comment.