Skip to content

Commit d7ee6ff

Browse files
authored
Merge pull request #2333 from tsloughter/relx-upgrade-xref
upgrades relx which now checks for undefined functions of project apps
2 parents 68dc4d2 + f6422f9 commit d7ee6ff

File tree

6 files changed

+53
-18
lines changed

6 files changed

+53
-18
lines changed

priv/templates/relx_rebar.config

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,28 @@
66
[@@name@@,
77
sasl]},
88

9+
{mode, dev},
10+
11+
%% automatically picked up if the files
12+
%% exist but can be set manually, which
13+
%% is required if the names aren't exactly
14+
%% sys.config and vm.args
915
{sys_config, "./config/sys.config"},
10-
{vm_args, "./config/vm.args"},
16+
{vm_args, "./config/vm.args"}
1117

12-
{dev_mode, true},
13-
{include_erts, false},
18+
%% the .src form of the configuration files do
19+
%% not require setting RELX_REPLACE_OS_VARS
20+
%% {sys_config_src, "./config/sys.config.src"},
21+
%% {vm_args_src, "./config/vm.args.src"}
22+
]}.
1423

15-
{extended_start_script, true}]
16-
}.
24+
{profiles, [{prod, [{relx,
25+
[%% prod is the default mode when prod
26+
%% profile is used, so does not have
27+
%% to be explicitly included like this
28+
{mode, prod}
1729

18-
{profiles, [{prod, [{relx, [{dev_mode, false},
19-
{include_erts, true}]}]
20-
}]
21-
}.
30+
%% use minimal mode to exclude ERTS
31+
%% {mode, minimal}
32+
]
33+
}]}]}.

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{providers, "1.8.1"},
99
{getopt, "1.0.1"},
1010
{bbmustache, "1.10.0"},
11-
{relx, "4.0.0-rc2"},
11+
{relx, {git, "https://github.com/erlware/relx.git", {branch, "master"}}},
1212
{cf, "0.3.1"},
1313
{cth_readable, "1.4.8"},
1414
{eunit_formatters, "0.5.0"}]}.

rebar.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0},
99
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},0},
1010
{<<"providers">>,{pkg,<<"providers">>,<<"1.8.1">>},0},
11-
{<<"relx">>,{pkg,<<"relx">>,<<"4.0.0-rc2">>},0},
11+
{<<"relx">>,
12+
{git,"https://github.com/erlware/relx.git",
13+
{ref,"96182ede21c7bbe23c2708514b4a42de0d974d5f"}},
14+
0},
1215
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},0}]}.
1316
[
1417
{pkg_hash,[
@@ -21,7 +24,6 @@
2124
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
2225
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
2326
{<<"providers">>, <<"70B4197869514344A8A60E2B2A4EF41CA03DEF43CFB1712ECF076A0F3C62F083">>},
24-
{<<"relx">>, <<"6031ED37FB496435FA992E52E540C22020B6678C9FA541CD748F987AD9D732D7">>},
2527
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>}]},
2628
{pkg_hash_ext,[
2729
{<<"bbmustache">>, <<"43EFFA3FD4BB9523157AF5A9E2276C493495B8459FC8737144AA186CB13CE2EE">>},
@@ -33,6 +35,5 @@
3335
{<<"getopt">>, <<"53E1AB83B9CEB65C9672D3E7A35B8092E9BDC9B3EE80721471A161C10C59959C">>},
3436
{<<"parse_trans">>, <<"17EF63ABDE837AD30680EA7F857DD9E7CED9476CDD7B0394432AF4BFC241B960">>},
3537
{<<"providers">>, <<"E45745ADE9C476A9A469EA0840E418AB19360DC44F01A233304E118A44486BA0">>},
36-
{<<"relx">>, <<"7DF43DC485821DC5B7EBC4C43487A06F68769F1406C12D6EC47FC6A3889F23D4">>},
3738
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>}]}
3839
].

src/rebar_app_info.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,20 @@ new(Parent, AppName, Vsn, Dir, Deps) ->
176176
ebin_dir=filename:join(rebar_utils:to_list(Dir), "ebin"),
177177
deps=Deps}}.
178178

179+
-spec app_to_map(t()) -> #{name := atom(),
180+
vsn := string(),
181+
applications := [atom()],
182+
included_applications := [atom()],
183+
dir := file:name(),
184+
out_dir := file:name(),
185+
ebin_dir := file:name(),
186+
link := boolean()}.
179187
app_to_map(#app_info_t{name=Name,
180188
vsn=Vsn,
181189
applications=Applications,
182190
included_applications=IncludedApplications,
183191
out_dir=OutDir,
184192
ebin_dir=EbinDir}) ->
185-
%% TODO: call rlx_app_info to create map
186193
#{name => ec_cnv:to_atom(Name),
187194
vsn => Vsn,
188195
applications => Applications,

src/rebar_prv_lock.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ do(State) ->
4343
%% so that they do not appear in the rebar_utils:info_useless/1 warning.
4444
OldLockNames = [element(1,L) || L <- OldLocks] -- Checkouts,
4545
NewLockNames = [element(1,L) || L <- Locks],
46+
47+
%% TODO: don't output this message if the dep is now a checkout
4648
rebar_utils:info_useless(OldLockNames, NewLockNames),
4749
info_checkout_deps(Checkouts),
4850

src/rebar_relx.erl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,26 @@ merge_overlays(Config) ->
155155
%% This means the project apps and dependencies but not OTP libraries.
156156
-spec all_apps(rebar_state:t()) -> #{atom() => rlx_app_info:t()}.
157157
all_apps(State) ->
158-
lists:foldl(fun(AppInfo, Acc) ->
159-
Acc#{binary_to_atom(rebar_app_info:name(AppInfo), utf8)
160-
=> rebar_app_info:app_to_map(AppInfo)}
161-
end, #{}, rebar_state:project_apps(State) ++ rebar_state:all_deps(State)).
158+
maps:merge(app_infos_to_relx(rebar_state:project_apps(State), project),
159+
app_infos_to_relx(rebar_state:all_deps(State), dep)).
162160

163161
%%
164162

163+
-spec app_infos_to_relx([rlx_app_info:t()], rlx_app_info:app_type()) -> #{atom() => rlx_app_info:t()}.
164+
app_infos_to_relx(AppInfos, AppType) ->
165+
lists:foldl(fun(AppInfo, Acc) ->
166+
Acc#{binary_to_atom(rebar_app_info:name(AppInfo), utf8)
167+
=> app_info_to_relx(rebar_app_info:app_to_map(AppInfo), AppType)}
168+
end, #{}, AppInfos).
169+
170+
app_info_to_relx(#{name := Name,
171+
vsn := Vsn,
172+
applications := Applications,
173+
included_applications := IncludedApplications,
174+
dir := Dir,
175+
link := false}, AppType) ->
176+
rlx_app_info:new(Name, Vsn, Dir, Applications, IncludedApplications, AppType).
177+
165178
-spec opt_spec_list() -> [getopt:option_spec()].
166179
opt_spec_list() ->
167180
[{all, undefined, "all", boolean,

0 commit comments

Comments
 (0)