[erlang-questions] Erlang "jar" file?
Thomas Lindgren
thomasl_erlang@REDACTED
Fri Nov 2 10:10:17 CET 2007
--- Benjamin Tolputt <bjt@REDACTED> wrote:
> And miss out on the improvements & support that
> comes with the latest
> version of Erlang? *laugh* Even if I could convince
> myself it was worth
> it (which, given the fact I evangelize the SMP &
> concurrency tie-in of
> Erlang alot, is a hard task), I doubt I could make
> it fly with
> management as soon as it comes out it is soon to be
> THREE major versions
> behind.
If all you need is a way to archive beam files into a
single file, then how about something like this:
-module(ear).
-compile(export_all).
%% as an example
make_ear(File) -> make_ear(File, code:all_loaded()).
%% create ear
make_ear(File, Mods) ->
Bin = term_to_binary([ beam(Mod) || Mod <- Mods ]),
file:write_file(File, Bin).
beam({M, preloaded}) -> [];
beam({M, F}) ->
{ok, B} = file:read_file(F),
{M, F, B}.
%% load ear
load_ear(File) ->
{ok, Bin} = file:read_file(File),
lists:foreach(
fun({M, F, B}) ->
io:format("Loading ~p -> ~p\n",
[M, code:load_binary(M, F, B)]);
([]) -> ok
end,
binary_to_term(Bin)).
Testing it with "erl -nostick" quickly and
successfully saved and loaded all the OTP modules
available on startup, as far as I could tell. The ear
file is 2.6 MB for 73 modules.
Best,
Thomas
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the erlang-questions
mailing list