Skip to content

Commit 9076a48

Browse files
authored
Merge pull request #2257 from tsloughter/relx-4
initial relx 4.0 support
2 parents b639fca + 5f03505 commit 9076a48

11 files changed

+171
-107
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ test_task:
22
use_compute_credits: true
33
container:
44
matrix:
5+
- image: erlang:23
56
- image: erlang:22
67
- image: erlang:21
78
- image: erlang:20
89
- image: erlang:19
9-
- image: erlang:18
1010
test_script: |
1111
./bootstrap
1212
./rebar3 ct

rebar.config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
{providers, "1.8.1"},
99
{getopt, "1.0.1"},
1010
{bbmustache, "1.8.0"},
11-
{relx, "3.33.0"},
11+
%% {relx, "3.33.0"},
12+
{relx, {git, "https://github.com/erlware/relx.git", {branch, "4.0.0"}}},
1213
{cf, "0.2.2"},
1314
{cth_readable, "1.4.8"},
1415
{eunit_formatters, "0.5.0"}]}.
@@ -29,6 +30,8 @@
2930
{escript_incl_extra, [{"relx/priv/templates/*", "_build/default/lib/"},
3031
{"rebar/priv/templates/*", "_build/default/lib/"}]}.
3132

33+
{overrides, [{add, relx, [{erl_opts, [{d, 'RLX_LOG', rebar_log}]}]}]}.
34+
3235
{erl_opts, [{platform_define, "^(19|2)", rand_only},
3336
{platform_define, "^18", no_maps_update_with},
3437
{platform_define, "^2", unicode_str},

rebar.lock

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"1.2.0",
1+
{"1.1.0",
22
[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.8.0">>},0},
33
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},0},
44
{<<"cf">>,{pkg,<<"cf">>,<<"0.2.2">>},0},
@@ -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">>,<<"3.33.0">>},0},
11+
{<<"relx">>,
12+
{git,"https://github.com/erlware/relx.git",
13+
{ref,"ad25111b7349c633fbec30f26c1ad03361d6b806"}},
14+
0},
1215
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.5">>},0}]}.
1316
[
1417
{pkg_hash,[
@@ -21,18 +24,5 @@
2124
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
2225
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
2326
{<<"providers">>, <<"70B4197869514344A8A60E2B2A4EF41CA03DEF43CFB1712ECF076A0F3C62F083">>},
24-
{<<"relx">>, <<"AFC019320BB69881718576B3E4E1EB548C1FA3270717BA66A78004C98A77CD17">>},
25-
{<<"ssl_verify_fun">>, <<"6EAF7AD16CB568BB01753DBBD7A95FF8B91C7979482B95F38443FE2C8852A79B">>}]},
26-
{pkg_hash_ext,[
27-
{<<"bbmustache">>, <<"190EA2206128BDFABF5D9200B8DF97F6511D9C62953655828E28C2BC79161252">>},
28-
{<<"certifi">>, <<"805ABD97539CAF89EC6D4732C91E62BA9DA0CDA51AC462380BBD28EE697A8C42">>},
29-
{<<"cf">>, <<"48283B3019BC7FAD56E7B23028A5DA4D3E6CD598A553AB2A99A2153BF5F19B21">>},
30-
{<<"cth_readable">>, <<"46C3BB14DF581DC7A9DC0CB9E8C755BFF596665FB9A23148DD76E3A200804E90">>},
31-
{<<"erlware_commons">>, <<"7AADA93F368D0A0430122E39931B7FB4AC9E94DBF043CDC980AD4330FD9CD166">>},
32-
{<<"eunit_formatters">>, <<"D6C8BA213424944E6E05BBC097C32001CDD0ABE3925D02454F229B20D68763C9">>},
33-
{<<"getopt">>, <<"53E1AB83B9CEB65C9672D3E7A35B8092E9BDC9B3EE80721471A161C10C59959C">>},
34-
{<<"parse_trans">>, <<"17EF63ABDE837AD30680EA7F857DD9E7CED9476CDD7B0394432AF4BFC241B960">>},
35-
{<<"providers">>, <<"E45745ADE9C476A9A469EA0840E418AB19360DC44F01A233304E118A44486BA0">>},
36-
{<<"relx">>, <<"6E0456139FC70BADE0C45FF8A8197C5E879A57FD792F771FC632B94C5AEC1EAC">>},
37-
{<<"ssl_verify_fun">>, <<"13104D7897E38ED7F044C4DE953A6C28597D1C952075EB2E328BC6D6F2BFC496">>}]}
27+
{<<"ssl_verify_fun">>, <<"6EAF7AD16CB568BB01753DBBD7A95FF8B91C7979482B95F38443FE2C8852A79B">>}]}
3828
].

src/rebar_app_discover.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,16 @@ create_app_info(AppInfo, AppDir, AppFile) ->
362362
rebar_app_info:original_vsn(
363363
rebar_app_info:dir(AppInfo, AppDir), AppVsn), AppName),
364364
AppInfo2 = rebar_app_info:applications(
365-
rebar_app_info:app_details(AppInfo1, AppDetails),
366-
IncludedApplications++Applications),
367-
Valid = case rebar_app_utils:validate_application_info(AppInfo2) =:= true
368-
andalso rebar_app_info:has_all_artifacts(AppInfo2) =:= true of
365+
rebar_app_info:app_details(AppInfo1, AppDetails), Applications),
366+
AppInfo3 = rebar_app_info:included_applications(AppInfo2, IncludedApplications),
367+
Valid = case rebar_app_utils:validate_application_info(AppInfo3) =:= true
368+
andalso rebar_app_info:has_all_artifacts(AppInfo3) =:= true of
369369
true ->
370370
true;
371371
_ ->
372372
false
373373
end,
374-
rebar_app_info:dir(rebar_app_info:valid(AppInfo2, Valid), AppDir);
374+
rebar_app_info:dir(rebar_app_info:valid(AppInfo3, Valid), AppDir);
375375
_Invalid ->
376376
throw({error, {?MODULE, {cannot_read_app_file, AppFile}}})
377377
catch

src/rebar_app_info.erl

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
new/3,
77
new/4,
88
new/5,
9+
app_to_map/1,
910
update_opts/3,
1011
update_opts/2,
1112
update_opts_deps/2,
@@ -27,6 +28,8 @@
2728
priv_dir/1,
2829
applications/1,
2930
applications/2,
31+
included_applications/1,
32+
included_applications/2,
3033
profiles/1,
3134
profiles/2,
3235
deps/1,
@@ -76,28 +79,29 @@
7679

7780
-type project_type() :: rebar3 | mix | undefined.
7881

79-
-record(app_info_t, {name :: binary() | undefined,
80-
app_file_src :: file:filename_all() | undefined,
81-
app_file_src_script:: file:filename_all() | undefined,
82-
app_file :: file:filename_all() | undefined,
83-
original_vsn :: binary() | undefined,
84-
parent=root :: binary() | root,
85-
app_details=[] :: list(),
86-
applications=[] :: list(),
87-
deps=[] :: list(),
88-
profiles=[default] :: [atom()],
89-
default=dict:new() :: rebar_dict(),
90-
opts=dict:new() :: rebar_dict(),
91-
dep_level=0 :: integer(),
92-
dir :: file:name(),
93-
out_dir :: file:name(),
94-
ebin_dir :: file:name(),
95-
source :: string() | tuple() | checkout | undefined,
96-
is_lock=false :: boolean(),
97-
is_checkout=false :: boolean(),
98-
valid :: boolean() | undefined,
99-
project_type :: project_type(),
100-
is_available=false :: boolean()}).
82+
-record(app_info_t, {name :: binary() | undefined,
83+
app_file_src :: file:filename_all() | undefined,
84+
app_file_src_script :: file:filename_all() | undefined,
85+
app_file :: file:filename_all() | undefined,
86+
original_vsn :: binary() | undefined,
87+
parent=root :: binary() | root,
88+
app_details=[] :: list(),
89+
applications=[] :: list(),
90+
included_applications=[] :: [atom()],
91+
deps=[] :: list(),
92+
profiles=[default] :: [atom()],
93+
default=dict:new() :: rebar_dict(),
94+
opts=dict:new() :: rebar_dict(),
95+
dep_level=0 :: integer(),
96+
dir :: file:name(),
97+
out_dir :: file:name(),
98+
ebin_dir :: file:name(),
99+
source :: string() | tuple() | checkout | undefined,
100+
is_lock=false :: boolean(),
101+
is_checkout=false :: boolean(),
102+
valid :: boolean() | undefined,
103+
project_type :: project_type(),
104+
is_available=false :: boolean()}).
101105

102106
%%============================================================================
103107
%% types
@@ -159,6 +163,22 @@ new(Parent, AppName, Vsn, Dir, Deps) ->
159163
ebin_dir=filename:join(rebar_utils:to_list(Dir), "ebin"),
160164
deps=Deps}}.
161165

166+
app_to_map(#app_info_t{name=Name,
167+
original_vsn=Vsn,
168+
applications=Applications,
169+
included_applications=IncludedApplications,
170+
out_dir=OutDir,
171+
ebin_dir=EbinDir}) ->
172+
%% TODO: call rlx_app_info to create map
173+
#{name => ec_cnv:to_atom(Name),
174+
vsn => Vsn,
175+
applications => Applications,
176+
included_applications => IncludedApplications,
177+
dir => OutDir,
178+
out_dir => OutDir,
179+
ebin_dir => EbinDir,
180+
link => false}.
181+
162182
%% @doc update the opts based on the contents of a config
163183
%% file for the app
164184
-spec update_opts(t(), rebar_dict(), [any()]) -> t().
@@ -406,6 +426,17 @@ applications(#app_info_t{applications=Applications}) ->
406426
applications(AppInfo=#app_info_t{}, Applications) ->
407427
AppInfo#app_info_t{applications=Applications}.
408428

429+
%% @doc returns the list of included_applications the app depends on.
430+
-spec included_applications(t()) -> list().
431+
included_applications(#app_info_t{included_applications=Applications}) ->
432+
Applications.
433+
434+
%% @doc sets the list of applications the app depends on.
435+
%% Should be obtained from the app file.
436+
-spec included_applications(t(), list()) -> t().
437+
included_applications(AppInfo=#app_info_t{}, Applications) ->
438+
AppInfo#app_info_t{included_applications=Applications}.
439+
409440
%% @doc returns the list of active profiles
410441
-spec profiles(t()) -> list().
411442
profiles(#app_info_t{profiles=Profiles}) ->

src/rebar_prv_release.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
do/1,
1010
format_error/1]).
1111

12+
-include_lib("providers/include/providers.hrl").
1213
-include("rebar.hrl").
1314

1415
-define(PROVIDER, release).
@@ -27,12 +28,12 @@ init(State) ->
2728
{example, "rebar3 release"},
2829
{short_desc, "Build release of project."},
2930
{desc, "Build release of project."},
30-
{opts, relx:opt_spec_list()}])),
31+
{opts, rebar_relx:opt_spec_list()}])),
3132
{ok, State1}.
3233

3334
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
3435
do(State) ->
35-
rebar_relx:do(rlx_prv_release, "release", ?PROVIDER, State).
36+
rebar_relx:do(?PROVIDER, State).
3637

3738
-spec format_error(any()) -> iolist().
3839
format_error(Reason) ->

src/rebar_prv_relup.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ init(State) ->
2727
{example, "rebar3 relup"},
2828
{short_desc, "Create relup of releases."},
2929
{desc, "Create relup of releases."},
30-
{opts, relx:opt_spec_list()}]),
30+
{opts, rebar_relx:opt_spec_list()}]),
3131
State1 = rebar_state:add_provider(State, Provider),
3232
{ok, State1}.
3333

3434
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
3535
do(State) ->
36-
rebar_relx:do(rlx_prv_release, "relup", ?PROVIDER, State).
36+
rebar_relx:do(?PROVIDER, State).
3737

3838
-spec format_error(any()) -> iolist().
3939
format_error(Reason) ->

src/rebar_prv_tar.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ init(State) ->
2727
{example, "rebar3 tar"},
2828
{short_desc, "Tar archive of release built of project."},
2929
{desc, "Tar archive of release built of project."},
30-
{opts, relx:opt_spec_list()}])),
30+
{opts, rebar_relx:opt_spec_list()}])),
3131
{ok, State1}.
3232

3333
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
3434
do(State) ->
35-
rebar_relx:do(rlx_prv_release, "tar", ?PROVIDER, State).
35+
rebar_relx:do(?PROVIDER, State).
3636

3737
-spec format_error(any()) -> iolist().
3838
format_error(Reason) ->

0 commit comments

Comments
 (0)