Browse Source

Merge pull request #822 from tsloughter/upgrade_app_src

handle case that upgraded app no longer has .app.src file
pull/824/head
Fred Hebert 9 years ago
parent
commit
5159939b0b
3 changed files with 13 additions and 13 deletions
  1. +2
    -1
      src/rebar_app_discover.erl
  2. +4
    -0
      src/rebar_app_info.erl
  3. +7
    -12
      src/rebar_otp_app.erl

+ 2
- 1
src/rebar_app_discover.erl View File

@ -229,7 +229,8 @@ try_handle_app_file(AppInfo0, [File], AppDir, AppSrcFile, _, Validate) ->
[F] ->
rebar_app_info:app_file_src(AppInfo1, F);
[] ->
AppInfo1;
%% Set to undefined in case AppInfo previous had a .app.src
rebar_app_info:app_file_src(AppInfo1, undefined);
Other when is_list(Other) ->
throw({error, {multiple_app_files, Other}})
end,

+ 4
- 0
src/rebar_app_info.erl View File

@ -232,6 +232,8 @@ app_file_src(#app_info_t{app_file_src=AppFileSrc}) ->
ec_cnv:to_list(AppFileSrc).
-spec app_file_src(t(), file:filename_all()) -> t().
app_file_src(AppInfo=#app_info_t{}, undefined) ->
AppInfo#app_info_t{app_file_src=undefined};
app_file_src(AppInfo=#app_info_t{}, AppFileSrc) ->
AppInfo#app_info_t{app_file_src=ec_cnv:to_list(AppFileSrc)}.
@ -248,6 +250,8 @@ app_file_src_script(#app_info_t{app_file_src_script=AppFileSrcScript}) ->
ec_cnv:to_list(AppFileSrcScript).
-spec app_file_src_script(t(), file:filename_all()) -> t().
app_file_src_script(AppInfo=#app_info_t{}, undefined) ->
AppInfo#app_info_t{app_file_src_script=undefined};
app_file_src_script(AppInfo=#app_info_t{}, AppFileSrcScript) ->
AppInfo#app_info_t{app_file_src_script=ec_cnv:to_list(AppFileSrcScript)}.

+ 7
- 12
src/rebar_otp_app.erl View File

@ -60,7 +60,7 @@ compile(State, App) ->
format_error({missing_app_file, Filename}) ->
io_lib:format("App file is missing: ~s", [Filename]);
format_error({file_read, File, Reason}) ->
io_lib:format("Failed to read app file ~s for processing: ~p", [File, file:format_error(Reason)]);
io_lib:format("Failed to read required file ~s for processing: ~s", [File, file:format_error(Reason)]);
format_error({invalid_name, File, AppName}) ->
io_lib:format("Invalid ~s: name of application (~p) must match filename.", [File, AppName]).
@ -110,7 +110,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
A1 = apply_app_vars(AppVars, AppData),
%% AppSrcFile may contain instructions for generating a vsn number
Vsn = app_vsn(AppSrcFile, State),
Vsn = app_vsn(AppData, AppSrcFile, State),
A2 = lists:keystore(vsn, 1, A1, {vsn, Vsn}),
%% systools:make_relup/4 fails with {missing_param, registered}
@ -128,7 +128,7 @@ preprocess(State, AppInfo, AppSrcFile) ->
AppFile;
{error, Reason} ->
?PRV_ERROR({file_read, AppSrcFile, Reason})
throw(?PRV_ERROR({file_read, AppSrcFile, Reason}))
end.
load_app_vars(State) ->
@ -214,15 +214,10 @@ consult_app_file(Filename) ->
end
end.
app_vsn(AppFile, State) ->
case consult_app_file(AppFile) of
{ok, [{application, _AppName, AppData}]} ->
AppDir = filename:dirname(filename:dirname(AppFile)),
Resources = rebar_state:resources(State),
rebar_utils:vcs_vsn(get_value(vsn, AppData, AppFile), AppDir, Resources);
{error, Reason} ->
throw(?PRV_ERROR({file_read, AppFile, Reason}))
end.
app_vsn(AppData, AppFile, State) ->
AppDir = filename:dirname(filename:dirname(AppFile)),
Resources = rebar_state:resources(State),
rebar_utils:vcs_vsn(get_value(vsn, AppData, AppFile), AppDir, Resources).
get_value(Key, AppInfo, AppFile) ->
case proplists:get_value(Key, AppInfo) of

Loading…
Cancel
Save