summaryrefslogtreecommitdiff
path: root/src/rebar_escripter.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_escripter.erl')
-rw-r--r--src/rebar_escripter.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/rebar_escripter.erl b/src/rebar_escripter.erl
index f7f45ba..b51a2a5 100644
--- a/src/rebar_escripter.erl
+++ b/src/rebar_escripter.erl
@@ -51,9 +51,14 @@ escriptize(Config, AppFile) ->
InclBeams = get_app_beams(
rebar_config:get_local(Config, escript_incl_apps, []), []),
+ %% Look for a list extra files to include in the output file.
+ %% For internal rebar-private use only. Do not use outside rebar.
+ InclExtra = get_extra(Config),
+
%% 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 = load_files("*", "ebin") ++ InclBeams,
+ Files = load_files("*", "ebin") ++ InclBeams ++ InclExtra,
+
case zip:create("mem", Files, [memory]) of
{ok, {"mem", ZipBin}} ->
%% Archive was successfully created. Prefix that binary with our
@@ -69,17 +74,17 @@ escriptize(Config, AppFile) ->
{error, WriteError} ->
?ERROR("Failed to write ~p script: ~p\n",
[AppName, WriteError]),
- ?FAIL
+ ?ABORT
end;
{error, ZipError} ->
?ERROR("Failed to construct ~p escript: ~p\n",
[AppName, ZipError]),
- ?FAIL
+ ?ABORT
end,
%% Finally, update executable perms for our script
{ok, #file_info{mode = Mode}} = file:read_file_info(Filename),
- ok = file:change_mode(Filename, Mode bor 8#00100),
+ ok = file:change_mode(Filename, Mode bor 8#00111),
ok.
clean(Config, AppFile) ->
@@ -91,7 +96,6 @@ clean(Config, AppFile) ->
Filename = rebar_config:get_local(Config, escript_name, AppName),
rebar_file_utils:delete_each([Filename]).
-
%% ===================================================================
%% Internal functions
%% ===================================================================
@@ -110,6 +114,12 @@ get_app_beams([App | Rest], Acc) ->
get_app_beams(Rest, Acc2 ++ Acc)
end.
+get_extra(Config) ->
+ Extra = rebar_config:get_local(Config, escript_incl_extra, []),
+ lists:foldl(fun({Wildcard, Dir}, Files) ->
+ load_files(Wildcard, Dir) ++ Files
+ end, [], Extra).
+
load_files(Wildcard, Dir) ->
[read_file(Filename, Dir) || Filename <- filelib:wildcard(Wildcard, Dir)].