diff options
author | Håkan Mattsson <[email protected]> | 2010-03-01 16:22:39 +0100 |
---|---|---|
committer | Håkan Mattsson <[email protected]> | 2010-03-16 14:28:25 +0100 |
commit | 31b790bdf8442a7eee22bfad0887d42278ffc18b (patch) | |
tree | 6714faf9750846e60c5c955e1e44fd8d17359b48 /system/README | |
parent | a20eb61c2fdd027a89acd249eea4f452e4accfb8 (diff) | |
download | otp-31b790bdf8442a7eee22bfad0887d42278ffc18b.tar.gz otp-31b790bdf8442a7eee22bfad0887d42278ffc18b.tar.bz2 otp-31b790bdf8442a7eee22bfad0887d42278ffc18b.zip |
Add functions to create and extract escripts
Both reltool and rebar needs to parse escripts. They are currently
using an undocumented function called escript:foldl/3. It folds a
function over all files in the body of an escript. If the body
contains source code the function compiles it and the gives debug
compiled beam code to the fold fun. If the body is an archive the fun
is applied for all files in the archive.
Instead of making the undocumented function public, the new functions
escript:create/2 and escript:extract/2 has been introduced. Together
with the new zip:foldl/3 function they have the same functionality as
escript:foldl/3 in a more flexible and generic way.
escript:foldl/3 should be removed as soon as reltool and rebar has
been adopted to use the new functions. The simplest way for reltool
and rebar to do this is to just copy the code from
escript_SUITE:escript_foldl/3, which happens to provide a future
compatible implementation of an emulated escript:foldl/3 function.
I was quite hesitant when I introduced the compile_source option. It
feels that it does not belong there but the alternative felt worse.
The rationale for the compile_source option is that it is a bit
cumbersome to compile the source code, as the source in most cases is
partial. In order to do compile the source you need to know about some
internals in escript. Without compile_source I think that these
internals should be documented. Further you need to duplicate parts of
the code.
Without the compile_source option you need to first parse the source
to forms, using an undocumented function in epp with an extended
format of predefined macros which also is undocumented. Then you need
to investigate the forms to see if you need to add an export form for
main. When that is done you can run the rest of the compiler passes as
usual. It is not so much code (60 lines or so) to write, but I do not
want to urge people to write it. I actually wrote the code (see
escript_SUITE:escript_foldl/3) before I decided to introduce the
compile_source option.
Diffstat (limited to 'system/README')
0 files changed, 0 insertions, 0 deletions