[erlang-questions] escript standard archive layout

Tobias Schlager Tobias.Schlager@REDACTED
Mon Aug 24 11:52:23 CEST 2015


Hi,

AFAIK, the layout you propose under 1. is correct. Additionally, the code server is also able to handle something like this (application name and version):

bob-1.0.0/ebin/bob.beam
bob-1.0.0/ebin/bob.app.src
mary-2.0.0/ebin/mary.app.src
mary-2.0.0/ebin/mary.beam

Packaging priv directories doesn't make much sense, since there's no automagic way to get the files' content at runtime. Even if you package priv directories in a standard location (in your case bob/priv/secret.code), the code server will return a non-existent path for code:priv_dir(bob) and you can't access the files with the file module. You'll have to use the erl_prim_loader module to extract file contents (other than .beam) from .ez archives (this also applies for embedded archives). I worked around this limitation when writing the rebar_escript_plugin [1] to create standalone escripts. Look at the rebar_escript_plugin_runner module to see erl_prim_loader in action.

Regards
Tobias

[1] https://github.com/schlagert/rebar_escript_plugin

________________________________
Von: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED]" im Auftrag von "Felix Gallo [felixgallo@REDACTED]
Gesendet: Sonntag, 23. August 2015 02:15
An: erlang-questions@REDACTED
Betreff: [erlang-questions] escript standard archive layout

I've recently had the opportunity to dive into escripts a little.  Fascinating.

I haven't been able to glean a few things from the documentation, however, and if anyone has experience with escripts, I'd love to hear their thoughts.

1.  It looks like, if your OTP application named 'bob' with one dependency 'mary' looks like this:

src/bob.erl
ebin/bob.beam
ebin/bob.app.src
deps/mary/src/mary.erl
deps/mary/ebin/mary.beam
deps/mary/ebin/mary.app.src
priv/secret.code

that the code module wants to get an {archive, ZippedBinary} block that unzips to

bob/ebin/bob.beam
bob/ebin/bob.app.src
mary/ebin/mary.app.src
mary/ebin/mary.beam
priv/secret.code

is that, for want of a formal document, the accepted right way of forming an archive block, all else being equal?

2.  Is there an escript 2nd-line (%%!) best practice/optimal options for most standard escripts that some old timer can recommend?

F.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150824/3138409c/attachment.htm>


More information about the erlang-questions mailing list