Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
added -e option to exclude modules
Browse files Browse the repository at this point in the history
  • Loading branch information
bdj committed Jul 14, 2010
1 parent b0ea422 commit 6304358
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
19 changes: 13 additions & 6 deletions batch/batch.ss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ Here's the idea:
"alpha.ss"
"module.ss"
compiler/decompile
compiler/zo-marshal)
compiler/zo-marshal
racket/set)

(define excluded-modules (make-parameter (set)))
(define file-to-batch
(command-line #:program "batch" #:args (filename) filename))
(command-line #:program "batch"
#:multi
[("-e" "--exclude-modules") mod
"Exclude a module from being batched"
(excluded-modules (set-add (excluded-modules) mod))]
#:args (filename) filename))

(define-values (base name dir?) (split-path file-to-batch))
(when (or (eq? base #f) dir?)
Expand All @@ -67,17 +74,17 @@ Here's the idea:
(delete-file compiled-zo-path))

(eprintf "Compiling module~n")
(void (system (format "mzc ~a" file-to-batch)))
(void (system (format "raco make ~a" file-to-batch)))


(define merged-source-path (path-add-suffix file-to-batch #".merged.ss"))
(define merged-source-path (path-add-suffix file-to-batch #".merged.rkt"))
(define-values (merged-source-base merged-source-name _1) (split-path merged-source-path))
(define merged-zo-path (build-compiled-path merged-source-base (path-add-suffix merged-source-name #".zo")))

;; Transformations
(eprintf "Removing dependencies~n")
(define-values (batch-nodep top-lang-info top-self-modidx)
(nodep-file file-to-batch))
(nodep-file file-to-batch (excluded-modules)))

(eprintf "Merging modules~n")
(define batch-merge
Expand Down Expand Up @@ -116,7 +123,7 @@ Here's the idea:
#:exists 'replace))

(eprintf "Running merged source~n")
#;(void (system (format "mzscheme ~a" merged-source-path)))
(void (system* (find-executable-path "racket") (path->string merged-source-path)))



4 changes: 4 additions & 0 deletions batch/merge.ss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
(values (add1 i)
(list* tl new-toplevels)
(list* (+ i toplevel-offset) remap))]
[(module-path-index? rw)
(values (add1 i)
(list* tl new-toplevels)
(list* (+ i toplevel-offset) remap))]
[(modvar-rewrite? rw)
(values i
new-toplevels
Expand Down
10 changes: 6 additions & 4 deletions batch/module.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
(require compiler/zo-parse
"util.ss")

(define (symbol->module-path-index s)
(module-path-index-join `(quote ,s) #f))
(define (->module-path-index s)
(if (module-path-index? s)
s
(module-path-index-join `(quote ,s) #f)))


(define (wrap-in-kernel-module name srcname lang-info self-modidx top)
Expand All @@ -12,12 +14,12 @@
(define-values (reqs new-forms)
(partition req? (splice-forms form)))
(define requires
(map (compose symbol->module-path-index syntax->datum req-reqs) reqs))
(map (compose ->module-path-index syntax->datum req-reqs) reqs))
(make-compilation-top
0
(make-prefix 0 (list #f) empty)
(make-mod name srcname
(module-path-index-join #f #f)
self-modidx
prefix
empty ; provides
(list (cons 0 requires))
Expand Down
35 changes: 26 additions & 9 deletions batch/nodep.ss
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
#lang scheme
(require compiler/zo-parse
"util.ss"
"mpi.ss")
"mpi.ss"
racket/set)

(define (nodep-file file-to-batch)
(define excluded-modules (make-parameter null))

(define (nodep-file file-to-batch excluded)
(excluded-modules excluded)
(match (get-nodep-module-code/path file-to-batch 0)
[(struct @phase (_ (struct module-code (modvar-rewrite lang-info ctop))))
(values ctop lang-info (modvar-rewrite-modidx modvar-rewrite))]))

(define (path->comp-top pth)
(call-with-input-file pth zo-parse))

(define (excluded? pth)
(set-member? (excluded-modules) (path->string pth)))

(define MODULE-IDX-MAP (make-hash))
(define (get-nodep-module-code/index mpi phase)
(define pth (mpi->path! mpi))
(if (symbol? pth) ; For internal things like #%paramz
(begin
(hash-set! MODULE-IDX-MAP pth pth)
pth)
(get-nodep-module-code/path pth phase)))
(cond
[(symbol? pth)
(hash-set! MODULE-IDX-MAP pth pth)
pth]
[(excluded? pth)
(hash-set! MODULE-IDX-MAP pth mpi)
mpi]
[else
(get-nodep-module-code/path pth phase)]))
(define (get-modvar-rewrite modidx)
(define pth (mpi->path* modidx))
(hash-ref MODULE-IDX-MAP pth
Expand Down Expand Up @@ -146,6 +157,12 @@
(begin
(hash-set! REQUIRED ct #t)
(list (make-req (datum->syntax #f ct) (make-toplevel 0 0 #f #f)))))]
[(module-path-index? ct)
(if (hash-has-key? REQUIRED ct)
empty
(begin
(hash-set! REQUIRED ct #t)
(list (make-req (datum->syntax #f ct) (make-toplevel 0 0 #f #f)))))]
[(not ct)
empty]
[(@phase? ct)
Expand All @@ -157,5 +174,5 @@
[struct modvar-rewrite
([modidx module-path-index?]
[provide->toplevel (symbol? exact-nonnegative-integer? . -> . exact-nonnegative-integer?)])]
[get-modvar-rewrite (module-path-index? . -> . (or/c symbol? modvar-rewrite?))]
[nodep-file (path-string? . -> . (values compilation-top? lang-info/c module-path-index?))])
[get-modvar-rewrite (module-path-index? . -> . (or/c symbol? modvar-rewrite? module-path-index?))]
[nodep-file (path-string? set? . -> . (values compilation-top? lang-info/c module-path-index?))])

0 comments on commit 6304358

Please sign in to comment.