소스 검색

Escriptize based on configured apps only

Prior to this patch, the escriptize command flat out selected all
declared dependencies.

This patch instead looks at the app files and only includes the
dependencies of the top level app and the extra ones, avoiding to
package more apps than required.

This required a version bump on cth_readable as it mistakenly included
'syntax_lib' instead of 'syntax_tools' as a dependency.
pull/1249/head
Fred Hebert 9 년 전
부모
커밋
6bc8ccefd3
3개의 변경된 파일22개의 추가작업 그리고 8개의 파일을 삭제
  1. +1
    -1
      rebar.config
  2. +2
    -2
      rebar.lock
  3. +19
    -5
      src/rebar_prv_escriptize.erl

+ 1
- 1
rebar.config 파일 보기

@ -9,7 +9,7 @@
{bbmustache, "1.0.4"},
{relx, "3.19.0"},
{cf, "0.2.1"},
{cth_readable, "1.2.2"},
{cth_readable, "1.2.3"},
{eunit_formatters, "0.3.1"}]}.
{escript_name, rebar3}.

+ 2
- 2
rebar.lock 파일 보기

@ -2,7 +2,7 @@
[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.0.4">>},0},
{<<"certifi">>,{pkg,<<"certifi">>,<<"0.4.0">>},0},
{<<"cf">>,{pkg,<<"cf">>,<<"0.2.1">>},0},
{<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.2.2">>},0},
{<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.2.3">>},0},
{<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"0.21.0">>},0},
{<<"eunit_formatters">>,{pkg,<<"eunit_formatters">>,<<"0.3.1">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"0.8.2">>},0},
@ -14,7 +14,7 @@
{<<"bbmustache">>, <<"7BA94F971C5AFD7B6617918A4BB74705E36CAB36EB84B19B6A1B7EE06427AA38">>},
{<<"certifi">>, <<"A7966EFB868B179023618D29A407548F70C52466BF1849B9E8EBD0E34B7EA11F">>},
{<<"cf">>, <<"69D0B1349FD4D7D4DC55B7F407D29D7A840BF9A1EF5AF529F1EBE0CE153FC2AB">>},
{<<"cth_readable">>, <<"983913A8E8572310B7EAF5F2631148B7D70B3C090D2120DCFE777A93AA4165FB">>},
{<<"cth_readable">>, <<"293120673DFF82F0768612C5282E35C40CACC1B6F94FE99077438FD3749D0E27">>},
{<<"erlware_commons">>, <<"A04433071AD7D112EDEFC75AC77719DD3E6753E697AC09428FC83D7564B80B15">>},
{<<"eunit_formatters">>, <<"7A6FC351EB5B873E2356B8852EB751E20C13A72FBCA03393CF682B8483509573">>},
{<<"getopt">>, <<"B17556DB683000BA50370B16C0619DF1337E7AF7ECBF7D64FBF8D1D6BCE3109B">>},

+ 19
- 5
src/rebar_prv_escriptize.erl 파일 보기

@ -90,9 +90,9 @@ escriptize(State0, App) ->
%% Look for a list of other applications (dependencies) to include
%% in the output file. We then use the .app files for each of these
%% to pull in all the .beam files.
InclApps = lists:usort([ec_cnv:to_atom(AppName) | rebar_state:get(State, escript_incl_apps, [])
++ all_deps(State)]),
TopInclApps = lists:usort([ec_cnv:to_atom(AppName) | rebar_state:get(State, escript_incl_apps, [])]),
AllApps = rebar_state:all_deps(State)++rebar_state:project_apps(State),
InclApps = find_deps(TopInclApps, AllApps),
InclBeams = get_apps_beams(InclApps, AllApps),
%% Look for a list of extra files to include in the output file.
@ -219,9 +219,23 @@ usort(List) ->
get_nonempty(Files) ->
[{FName,FBin} || {FName,FBin} <- Files, FBin =/= <<>>].
all_deps(State) ->
[list_to_existing_atom(binary_to_list(rebar_app_info:name(App)))
|| App <- rebar_state:all_deps(State)].
find_deps(AppNames, AllApps) ->
BinAppNames = [ec_cnv:to_binary(Name) || Name <- AppNames],
[ec_cnv:to_atom(Name) ||
Name <- find_deps_of_deps(BinAppNames, AllApps, BinAppNames)].
%% Should look at the app files to find direct dependencies
find_deps_of_deps([], _, Acc) -> Acc;
find_deps_of_deps([Name|Names], Apps, Acc) ->
?DEBUG("processing ~p", [Name]),
{ok, App} = rebar_app_utils:find(Name, Apps),
DepNames = proplists:get_value(applications, rebar_app_info:app_details(App), []),
BinDepNames = [ec_cnv:to_binary(Dep) || Dep <- DepNames,
%% ignore system libs; shouldn't include them.
not lists:prefix(code:root_dir(), code:lib_dir(Dep))]
-- ([Name|Names]++Acc), % avoid already seen deps
?DEBUG("new deps of ~p found to be ~p", [Name, BinDepNames]),
find_deps_of_deps(BinDepNames ++ Names, Apps, BinDepNames ++ Acc).
def(Rm, State, Key, Default) ->
Value0 = rebar_state:get(State, Key, Default),

불러오는 중...
취소
저장