| 1 | REBOL [
|
|---|
| 2 | Title: "Create RebGUI distribution"
|
|---|
| 3 | Owner: "Ashley G. Trüter"
|
|---|
| 4 | Purpose: "Merge RebGUI source files into a single file and remove unnecessary white-space."
|
|---|
| 5 | History: {
|
|---|
| 6 | 30 Added build# to header
|
|---|
| 7 | 33 Cleaned up display and auto obtain build# from ctx-rebgui/build
|
|---|
| 8 | 65 Cleaned up comments
|
|---|
| 9 | 66 Removed need to load %rebgui-ctx.r
|
|---|
| 10 | 68 Added quiet mode when called from another script
|
|---|
| 11 | 72 Added quiet option if called from another script, eg. do/args %create-distribution.r 'quiet
|
|---|
| 12 | 73 Replaced trim/lines with replace/all "^/^/" "^/" so 'source works
|
|---|
| 13 | }
|
|---|
| 14 | ]
|
|---|
| 15 |
|
|---|
| 16 | build: to integer! trim/all skip copy/part find read %rebgui-ctx.r "build:" 12 6
|
|---|
| 17 |
|
|---|
| 18 | code: make string! 150000
|
|---|
| 19 | insert code rejoin ["REBOL [version: " build "]"]
|
|---|
| 20 | insert tail code mold/only/flat load %rebgui-ctx.r
|
|---|
| 21 |
|
|---|
| 22 | files: 1
|
|---|
| 23 | bytes: size? %rebgui-ctx.r
|
|---|
| 24 |
|
|---|
| 25 | string: find code "#include"
|
|---|
| 26 |
|
|---|
| 27 | while [not none? string] [
|
|---|
| 28 | ; find start and end of #include
|
|---|
| 29 | p1: index? string
|
|---|
| 30 | p2: index? find string ".r"
|
|---|
| 31 | ; extract source file name
|
|---|
| 32 | f: second to block! copy/part at code p1 2 + p2 - p1
|
|---|
| 33 | unless system/script/args [
|
|---|
| 34 | if find f "/" [prin "^-"]
|
|---|
| 35 | print f
|
|---|
| 36 | ]
|
|---|
| 37 | ; increment file and byte count
|
|---|
| 38 | files: files + 1
|
|---|
| 39 | bytes: bytes + size? f
|
|---|
| 40 | ; replace #include with referenced source file
|
|---|
| 41 | remove/part at code p1 2 + p2 - p1
|
|---|
| 42 | insert at code p1 mold/only/flat load f
|
|---|
| 43 | ; find next #include
|
|---|
| 44 | string: find code "#include"
|
|---|
| 45 | ]
|
|---|
| 46 |
|
|---|
| 47 | ; remove extra newlines
|
|---|
| 48 | replace/all code "^/^/" "^/"
|
|---|
| 49 | ; tip compression
|
|---|
| 50 | replace/all code "^^-^^-^^-" ""
|
|---|
| 51 | replace/all code "^^-^^-" ""
|
|---|
| 52 | replace/all code "tip: {^/" "tip:{"
|
|---|
| 53 | replace/all code "^/^^-} " "}"
|
|---|
| 54 | ; compact block delimiters
|
|---|
| 55 | replace/all code "[ " "["
|
|---|
| 56 | replace/all code " ]" "]"
|
|---|
| 57 | replace/all code " [" "["
|
|---|
| 58 | replace/all code "] " "]"
|
|---|
| 59 | ; compact expression delimiters
|
|---|
| 60 | replace/all code "( " "("
|
|---|
| 61 | replace/all code " )" ")"
|
|---|
| 62 |
|
|---|
| 63 | write %rebgui.r code
|
|---|
| 64 |
|
|---|
| 65 | unless system/script/args [
|
|---|
| 66 | print rejoin [
|
|---|
| 67 | "^/Build# ==> " build " !!! Specified in %rebgui-ctx.r (ctx-rebgui/build) !!!"
|
|---|
| 68 | "^/Files ===> " files
|
|---|
| 69 | "^/Source ==> " bytes " bytes"
|
|---|
| 70 | "^/Target ==> " n: size? %rebgui.r " bytes"
|
|---|
| 71 | "^/Saving ==> " to integer! 1 - (n / bytes) * 100 "%"
|
|---|
| 72 | ]
|
|---|
| 73 | halt
|
|---|
| 74 | ] |
|---|