Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes related to .app files #1640

Merged
merged 4 commits into from
Oct 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rebar.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{application, rebar,
[{description, "Rebar: Erlang Build Tool"},
{vsn, "3.4.4"},
{vsn, "git"},
{modules, []},
{registered, []},
{applications, [kernel,
Expand Down
15 changes: 11 additions & 4 deletions src/rebar_app_info.erl
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,22 @@ app_file(AppInfo=#app_info_t{}, AppFile) ->
app_details(AppInfo=#app_info_t{app_details=[]}) ->
case app_file(AppInfo) of
undefined ->
rebar_file_utils:try_consult(app_file_src(AppInfo));
case rebar_config:consult_app_file(app_file_src(AppInfo)) of
[] -> [];
[{application, _Name, AppDetails}] -> AppDetails
end;
AppFile ->
try
rebar_file_utils:try_consult(AppFile)
try rebar_file_utils:try_consult(AppFile) of
[] -> [];
[{application, _Name, AppDetails}] -> AppDetails
catch
throw:{error, {Module, Reason}} ->
?DEBUG("Warning, falling back to .app.src because of: ~ts",
[Module:format_error(Reason)]),
rebar_file_utils:try_consult(app_file_src(AppInfo))
case rebar_config:consult_app_file(app_file_src(AppInfo)) of
[] -> [];
[{application, _Name, AppDetails}] -> AppDetails
end
end
end;
app_details(#app_info_t{app_details=AppDetails}) ->
Expand Down
14 changes: 13 additions & 1 deletion src/rebar_otp_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ preprocess(State, AppInfo, AppSrcFile) ->
%% without a 'registered' value.
A3 = ensure_registered(A2),

%% some tools complain if a description is not present.
A4 = ensure_description(A3),

%% Build the final spec as a string
Spec = io_lib:format("~p.\n", [{application, AppName, A3}]),
Spec = io_lib:format("~p.\n", [{application, AppName, A4}]),

%% Setup file .app filename and write new contents
EbinDir = rebar_app_info:ebin_dir(AppInfo),
Expand Down Expand Up @@ -195,6 +198,15 @@ ensure_registered(AppData) ->
AppData
end.

ensure_description(AppData) ->
case lists:keyfind(description, 1, AppData) of
false ->
%% Required for releases to work.
[{description, ""} | AppData];
{description, _} ->
AppData
end.

%% In the case of *.app.src we want to give the user the ability to
%% dynamically script the application resource file (think dynamic version
%% string, etc.), in a way similar to what can be done with the rebar
Expand Down
3 changes: 3 additions & 0 deletions test/rebar_pkg_alias_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,16 @@ mock_config(Name, Config) ->
{ChkFake, Etag} = create_lib(Name, Config, "fakelib"),
{ChkTop, _} = create_lib(Name, Config, "topdep"),
{ChkTrans, _} = create_lib(Name, Config, "transitive_app", "transitive"),
ct:pal("{~p, _}",[ChkTop]),
ct:pal("{~p, _}",[ChkTrans]),
Priv = ?config(priv_dir, Config),
TmpDir = filename:join([Priv, "tmp", atom_to_list(Name)]),
%% Add an alias for goodpkg -> fakelib by hand
AppDir = filename:join([Priv, "fakelib"]),
CacheRoot = filename:join([Priv, "cache", atom_to_list(Name)]),
CacheDir = filename:join([CacheRoot, "hex", "com", "test", "packages"]),
rebar_test_utils:create_app(AppDir, "fakelib", "1.0.0", [kernel, stdlib]),
ct:pal("{~p, ~p}",[ChkFake, Etag]),
{ChkFake, Etag} = rebar_test_utils:package_app(AppDir, CacheDir, "goodpkg-1.0.0"),

Tid = ets:new(registry_table, [public]),
Expand Down