change `raco demod' test to write to temporary drectory
Also add `-o' option to `raco demod'.
This commit is contained in:
parent
7e7c45f100
commit
577f38f649
|
@ -50,9 +50,10 @@ Here's the idea:
|
||||||
"replace-modidx.rkt"
|
"replace-modidx.rkt"
|
||||||
compiler/decompile
|
compiler/decompile
|
||||||
compiler/zo-marshal
|
compiler/zo-marshal
|
||||||
racket/set)
|
racket/set
|
||||||
|
raco/command-name)
|
||||||
|
|
||||||
(define (main file-to-batch)
|
(define (main file-to-batch output-file)
|
||||||
(define-values (base name dir?) (split-path file-to-batch))
|
(define-values (base name dir?) (split-path file-to-batch))
|
||||||
(when (or (eq? base #f) dir?)
|
(when (or (eq? base #f) dir?)
|
||||||
(error 'batch "Cannot run on directory"))
|
(error 'batch "Cannot run on directory"))
|
||||||
|
@ -62,7 +63,9 @@ Here's the idea:
|
||||||
(log-info "Compiling module")
|
(log-info "Compiling module")
|
||||||
(void (system* (find-executable-path "raco") "make" file-to-batch))
|
(void (system* (find-executable-path "raco") "make" file-to-batch))
|
||||||
|
|
||||||
(define merged-zo-path (path-add-suffix file-to-batch #"_merged.zo"))
|
(define merged-zo-path
|
||||||
|
(or output-file
|
||||||
|
(path-add-suffix file-to-batch #"_merged.zo")))
|
||||||
|
|
||||||
;; Transformations
|
;; Transformations
|
||||||
(define path-cache (make-hash))
|
(define path-cache (make-hash))
|
||||||
|
@ -105,9 +108,14 @@ Here's the idea:
|
||||||
(zo-marshal-to batch-mod (current-output-port)))
|
(zo-marshal-to batch-mod (current-output-port)))
|
||||||
#:exists 'replace)))
|
#:exists 'replace)))
|
||||||
|
|
||||||
(command-line #:program "batch"
|
|
||||||
#:multi
|
(let ()
|
||||||
[("-e" "--exclude-modules") mod
|
(define output-file (make-parameter #f))
|
||||||
"Exclude a module from being batched"
|
(command-line #:program (short-program+command-name)
|
||||||
(current-excluded-modules (set-add (current-excluded-modules) mod))]
|
#:multi
|
||||||
#:args (filename) (main filename))
|
[("-e" "--exclude-modules") path "Exclude <path> from flattening"
|
||||||
|
(current-excluded-modules (set-add (current-excluded-modules) path))]
|
||||||
|
[("-o") dest-filename "Write output as <dest-filename>"
|
||||||
|
(output-file (string->path dest-filename))]
|
||||||
|
#:args (filename)
|
||||||
|
(main filename (output-file))))
|
||||||
|
|
|
@ -16,13 +16,16 @@
|
||||||
(define-values (modular-output modular-error)
|
(define-values (modular-output modular-error)
|
||||||
(capture-output (find-executable-path "racket") filename))
|
(capture-output (find-executable-path "racket") filename))
|
||||||
|
|
||||||
|
(define demod-filename
|
||||||
|
(let-values ([(base filename dir?) (split-path filename)])
|
||||||
|
(path->string
|
||||||
|
(build-path
|
||||||
|
(find-system-path 'temp-dir)
|
||||||
|
(path-add-suffix filename #"_merged.zo")))))
|
||||||
|
|
||||||
; demodularize
|
; demodularize
|
||||||
(parameterize ([current-input-port (open-input-string "")])
|
(parameterize ([current-input-port (open-input-string "")])
|
||||||
(system* (find-executable-path "raco") "demod" filename))
|
(system* (find-executable-path "raco") "demod" "-o" demod-filename filename))
|
||||||
|
|
||||||
(define demod-filename
|
|
||||||
(path->string
|
|
||||||
(path-add-suffix filename #"_merged.zo")))
|
|
||||||
|
|
||||||
; run whole program
|
; run whole program
|
||||||
(define-values (whole-output whole-error)
|
(define-values (whole-output whole-error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user