Skip to content

Commit 4367c85

Browse files
committed
Enrich combine utility.
1 parent fb21f7c commit 4367c85

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

langs/outlaw/combine.rkt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33

44
;; This is a utility for smashing together racket files into a single
55
;; monolithic program.
6+
67
;; For example:
7-
;; racket -t combine.rkt -m compile-stdin.rkt > outlaw.rkt
8+
9+
;; racket -t combine.rkt -m compile-stdin.rkt stdlib.rkt > outlaw.rkt
10+
811
;; creates a file with all the source code needed for the Outlaw
9-
;; compiler. You still have to:
10-
;; a) comment out the standard library
11-
;; b) remove all of the requires and provides to make a valid Racket program
12+
;; compiler.
13+
14+
;; It will append the source code of all the files fn requires
15+
;; and comment out their requires and provides, excluding
16+
;; any files given in the ignores list.
1217

13-
;; String -> Void
18+
;; String String ... -> Void
1419
;; Combine all the files fn depends upon, print to stdout
15-
;; as one monolithic program
16-
(define (main fn)
20+
;; as one monolithic program, excluding ignores.
21+
(define (main fn . ignores)
1722
(printf "#lang racket\n")
18-
(let ((fs (all-files fn)))
23+
(let ((fs (remove* ignores (all-files fn))))
1924
(for-each (lambda (f)
2025
(displayln (string-append ";; " f)))
2126
fs)
@@ -47,6 +52,8 @@
4752
(begin (newline)
4853
(close-input-port p))
4954
(begin
55+
(when (regexp-match? #rx"^\\(require|^\\(provide" l)
56+
(display "#;"))
5057
(displayln l)
5158
(loop)))))
5259
(loop)))

0 commit comments

Comments
 (0)