Running multiple beam files from an escript

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Running multiple beam files from an escript

Awsaf Rahman
Hi all, 

I wrote a few microbenchmarks in Erlang to measure execution time. I have never used escripts but want to know how they work. Is it possible to run multiple beam files from an escript? For example, some condition decides which Beam file would be invoked?

Regards
Awsaf

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Running multiple beam files from an escript

Roger Lipscombe-2
"rebar3 escriptize" -- http://www.rebar3.org/docs/commands#section-escriptize -- lets you combine multiple .erl files into a single escript. You can do the same with Elixir; see https://www.thegreatcodeadventure.com/executable-elixir-working-with-escripts/

Both of these take advantage of the fact that Erlang knows how to load BEAM files from a .ZIP file, and that .ZIP files can have "garbage" on the front. Said "garbage" being an entry point escript that invokes the main module from the ZIP.

I experimented with it here: https://github.com/rlipscombe/escriptize -- but it's not maintained, so don't bother using it unless you need to support dependencies with NIFs/ports in them.

On 13 September 2018 at 22:47, Awsaf Rahman <[hidden email]> wrote:
Hi all, 

I wrote a few microbenchmarks in Erlang to measure execution time. I have never used escripts but want to know how they work. Is it possible to run multiple beam files from an escript? For example, some condition decides which Beam file would be invoked?

Regards
Awsaf

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Running multiple beam files from an escript

Mikael Pettersson-5
Yes, escripts can include ZIP archives of beam and other files.  I
experimented a bit with that a while ago, resulting in "eld" (an
Erlang linker) https://github.com/mikpe/eld (emphasis on experiment.

Some of the build tools out there already support this feature, you
should probably stick with those.

On Fri, Sep 14, 2018 at 9:13 AM, Roger Lipscombe <[hidden email]> wrote:

> "rebar3 escriptize" --
> http://www.rebar3.org/docs/commands#section-escriptize -- lets you combine
> multiple .erl files into a single escript. You can do the same with Elixir;
> see
> https://www.thegreatcodeadventure.com/executable-elixir-working-with-escripts/
>
> Both of these take advantage of the fact that Erlang knows how to load BEAM
> files from a .ZIP file, and that .ZIP files can have "garbage" on the front.
> Said "garbage" being an entry point escript that invokes the main module
> from the ZIP.
>
> I experimented with it here: https://github.com/rlipscombe/escriptize -- but
> it's not maintained, so don't bother using it unless you need to support
> dependencies with NIFs/ports in them.
>
> On 13 September 2018 at 22:47, Awsaf Rahman <[hidden email]>
> wrote:
>>
>> Hi all,
>>
>> I wrote a few microbenchmarks in Erlang to measure execution time. I have
>> never used escripts but want to know how they work. Is it possible to run
>> multiple beam files from an escript? For example, some condition decides
>> which Beam file would be invoked?
>>
>> Regards
>> Awsaf
>>
>> _______________________________________________
>> erlang-questions mailing list
>> [hidden email]
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions