diff --git a/collects/compiler/demodularizer/batch.rkt b/collects/compiler/demodularizer/batch.rkt index 9846a958b8..37645548b6 100644 --- a/collects/compiler/demodularizer/batch.rkt +++ b/collects/compiler/demodularizer/batch.rkt @@ -50,9 +50,10 @@ Here's the idea: "replace-modidx.rkt" compiler/decompile 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)) (when (or (eq? base #f) dir?) (error 'batch "Cannot run on directory")) @@ -62,7 +63,9 @@ Here's the idea: (log-info "Compiling module") (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 (define path-cache (make-hash)) @@ -105,9 +108,14 @@ Here's the idea: (zo-marshal-to batch-mod (current-output-port))) #:exists 'replace))) -(command-line #:program "batch" - #:multi - [("-e" "--exclude-modules") mod - "Exclude a module from being batched" - (current-excluded-modules (set-add (current-excluded-modules) mod))] - #:args (filename) (main filename)) + +(let () + (define output-file (make-parameter #f)) + (command-line #:program (short-program+command-name) + #:multi + [("-e" "--exclude-modules") path "Exclude from flattening" + (current-excluded-modules (set-add (current-excluded-modules) path))] + [("-o") dest-filename "Write output as " + (output-file (string->path dest-filename))] + #:args (filename) + (main filename (output-file)))) diff --git a/collects/tests/compiler/demodularizer/demod-test.rkt b/collects/tests/compiler/demodularizer/demod-test.rkt index ae13457942..5d88fbc82a 100644 --- a/collects/tests/compiler/demodularizer/demod-test.rkt +++ b/collects/tests/compiler/demodularizer/demod-test.rkt @@ -16,13 +16,16 @@ (define-values (modular-output modular-error) (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 (parameterize ([current-input-port (open-input-string "")]) - (system* (find-executable-path "raco") "demod" filename)) - - (define demod-filename - (path->string - (path-add-suffix filename #"_merged.zo"))) + (system* (find-executable-path "raco") "demod" "-o" demod-filename filename)) ; run whole program (define-values (whole-output whole-error)