forked from saphirion/RebGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-rebgui.r
60 lines (52 loc) · 1.42 KB
/
create-rebgui.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
REBOL [
Title: "Create RebGUI distribution"
Owner: "Ashley G. Trüter"
Version: 2.0.0
Date: 7-May-2006
Purpose: "Merge RebGUI source files into a single file and remove unnecessary white-space."
History: {
1.0.0 Initial version based on prebol.r and prerebol.r from SDK.
2.0.0 Removed SDK dependencies.
}
Note: {Changed by Ladislav to use INCLUDE}
]
code: make string! 150000
; insert code "REBOL []"
insert tail code mold/only/flat/all include/only %rebgui-ctx.r
files: 1
bytes: size? %rebgui-ctx.r
string: find code "#include"
while [not none? string] [
; find start and end of #include
p1: index? string
p2: index? find string ".r"
; extract source file name
f: second to block! copy/part at code p1 2 + p2 - p1
print f
; increment file and byte count
files: files + 1
bytes: bytes + size? f
; replace #include with referenced source file
remove/part at code p1 2 + p2 - p1
insert at code p1 mold/only/flat load f
; find next #include
string: find code "#include"
]
; remove newlines and surplus spaces
trim/lines code
; compact block delimiters
replace/all code "[ " "["
replace/all code " ]" "]"
replace/all code " [" "["
replace/all code "] " "]"
; compact expression delimiters
replace/all code "( " "("
replace/all code " )" ")"
write %rebgui.r code
print rejoin [
"^/Files===> " files
"^/Bytes===> " bytes
"^/Into====> " n: size? %rebgui.r " bytes"
"^/Saving==> " to integer! 1 - (n / bytes) * 100 "%"
]
halt