mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Rework how the escript is built so that we can inclue templates
This commit is contained in:
parent
1454b4faa6
commit
1ea7065b83
1 changed files with 15 additions and 7 deletions
16
bootstrap
16
bootstrap
|
@ -39,10 +39,12 @@ main(Args) ->
|
|||
%% Run rebar to do proper .app validation and such
|
||||
rebar:main(["compile"] ++ Args),
|
||||
|
||||
%% Construct the archive of everything in ebin/ dir -- put it on the
|
||||
%% top-level of the zip file so that code loading works properly.
|
||||
Files = filelib:wildcard("*", "ebin"),
|
||||
case zip:create("mem", Files, [{cwd, "ebin"}, memory]) of
|
||||
%% Read the contents of the files in ebin and templates; note that we place
|
||||
%% all the beam files at the top level of the code archive so that code loading
|
||||
%% works properly.
|
||||
Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
|
||||
|
||||
case zip:create("mem", Files, [memory]) of
|
||||
{ok, {"mem", ZipBin}} ->
|
||||
%% Archive was successfully created. Prefix that binary with our
|
||||
%% header and write to "rebar" file
|
||||
|
@ -73,3 +75,9 @@ build_time() ->
|
|||
lists:flatten(io_lib:format("~4..0w~2..0w~2..0w_~2..0w~2..0w~2..0w", [Y, M, D, H, Min, S])).
|
||||
|
||||
|
||||
load_files(Wildcard, Dir) ->
|
||||
[read_file(Filename, Dir) || Filename <- filelib:wildcard(Wildcard, Dir)].
|
||||
|
||||
read_file(Filename, Dir) ->
|
||||
{ok, Bin} = file:read_file(filename:join(Dir, Filename)),
|
||||
{Filename, Bin}.
|
||||
|
|
Loading…
Reference in a new issue