encap and build.r
[1/3] from: atruter:hih:au at: 30-Aug-2002 12:21
The following script tries to take the hassle out of building an optimised encap program. I had several goals / constraints in mind: 1. My applications typically have a master script that issues a "do %xxx.r" for each required "module". 2. I don't want to have to edit out these statements when running encap (otherwise the generated executable will fail trying to find the underlying source files). 3. I want to encap source that has all non-esential text (eg. comments, redundant whitespace, etc) removed. 4. While the build script and encap reside in the same directory, the file (and its modules, if any) probably reside in another directory. The following script was largely inspired / based on the work Carl did in build-pack.r <build.r> REBOL  ; Obtain files to build if none? attempt [build-file: request-file/only/title/filter "Select file to build" "Open" ["*.r"]] [ alert "Build file not specified." quit ] path: first split-path build-file header: first load/header build-file if none? header/Needs [header/Needs: copy ] insert tail header/Needs second split-path build-file ; Merge source code code: make string! 128000 foreach file header/Needs [ script: load/all path/:file insert tail code mold/only skip script 2 ; skip REBOL header ] src-size: length? code ; Generate compressed copy system/options/binary-base: 64 code: compress trim/lines code src-file: replace copy build-file %.r %.src save/header src-file compose [do decompress (code)] compose/deep [Encap: [no-network secure none title (header/Title)]] ; Encap compressed file exe-file: replace copy build-file %.r %.exe call reform ["rebolve1003.exe" src-file exe-file] alert reform ["Compressed" src-size "bytes to" length? code "bytes."] </build .r> The following scripts outline the practical implementation of this: <build-test.r> REBOL [ Title: "Build Test" Needs: [%a.r %b.r %c.r] ] if not none? attempt [system/script/header/Needs] [ foreach script system/script/header/Needs [do script] ] wait 2 </build-test.r> <a.r> REBOL  print "A" </a.r> <b.r> REBOL  print "B" </b.r> <c.r> REBOL  print "C" </c.r> Running build-test.r and build-test.exe should yield the exact same results. I have successfully used this on a fairly complex 148K app with no issues to date (all of two days that is ;) ). A good approach or not? (I was toying with the idea of further reducing the source size by tokensing user-defined words, but the cost / benefit didn't seem justified). Regards, Ashley *****************Privacy, Confidentiality & Liability Notice ************ This email is intended for the named recipient only. The information contained in this message may be confidential, or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it. If you have received this email in error, please contact the sender immediately. Please delete this message from your computer. You must scan this email and any attached files for viruses. The company accepts no liability for any loss, damage or consequence, whether caused by our own negligence or not, resulting directly or indirectly from the use of any attached files. Any views expressed in this Communication are those of the individual sender, except where the sender specifically states them to be the views of the Company. **************************************************************************
[2/3] from: jjmmes:yah:oo:es at: 30-Aug-2002 11:38
> A good approach or not? (I was toying with the idea > of further reducing the > source size by tokensing user-defined words, but the > cost / benefit didn't > seem justified).
Great approach, I think. The more tools we have the less errors we'll do (as long as the tools are truly reliable). I'll use your tool ! A related idea is to have a Rebol diff function that cleans and properly formats two scripts (with Carl's or Volker script) and then checks for the differences (the diff script in the library only tests at the line level). Tokenising further wouldn't be good to inspect diffs
[3/3] from: carl::s::rebol::com at: 30-Aug-2002 0:22
Ashley, We have a handy program that we use for building REBOL distributions. It's a sort of REBOL preprocessor. In addition to include files, it also allows you to write macro functions in REBOL. For instance, if you want to auto update your version number, it can do that. I'll take a few minutes out tomorrow to doc it, then post it here. I think we'll also include it in future releases of Encap, because it's a perfect match for that product. We use it all the time. -Carl At 8/30/02 12:21 PM +1000, you wrote: