mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Fix detection and processing of .app.src.script
Loading .app, .app.src or .app.src.script returns now the value as per the documentation (was wrapped in a list in some cases). More places in the code detect .app.src.script and handle it.
This commit is contained in:
parent
b44b4f4199
commit
7d55c9986f
2 changed files with 23 additions and 9 deletions
1
THANKS
1
THANKS
|
@ -129,3 +129,4 @@ Andras Horvath
|
||||||
Drew Varner
|
Drew Varner
|
||||||
Roberto Aloi
|
Roberto Aloi
|
||||||
Luis Rascao
|
Luis Rascao
|
||||||
|
Vlad Dumitrescu
|
||||||
|
|
|
@ -73,10 +73,17 @@ is_app_dir(Dir) ->
|
||||||
is_app_src(Filename) ->
|
is_app_src(Filename) ->
|
||||||
%% If removing the extension .app.src yields a shorter name,
|
%% If removing the extension .app.src yields a shorter name,
|
||||||
%% this is an .app.src file.
|
%% this is an .app.src file.
|
||||||
Filename =/= filename:rootname(Filename, ".app.src").
|
Filename =/= filename:rootname(Filename, ".app.src") orelse
|
||||||
|
Filename =/= filename:rootname(Filename, ".app.src.script").
|
||||||
|
|
||||||
app_src_to_app(Filename) ->
|
app_src_to_app(Filename) ->
|
||||||
filename:join("ebin", filename:basename(Filename, ".app.src") ++ ".app").
|
Filebase = case filename:rootname(Filename, ".app.src") of
|
||||||
|
Filename ->
|
||||||
|
filename:basename(Filename, ".app.src.script");
|
||||||
|
_ ->
|
||||||
|
filename:basename(Filename, ".app.src")
|
||||||
|
end,
|
||||||
|
filename:join("ebin", Filebase ++ ".app").
|
||||||
|
|
||||||
app_name(Config, AppFile) ->
|
app_name(Config, AppFile) ->
|
||||||
case load_app_file(Config, AppFile) of
|
case load_app_file(Config, AppFile) of
|
||||||
|
@ -140,13 +147,13 @@ load_app_file(Config, Filename) ->
|
||||||
case rebar_config:get_xconf(Config, {appfile, AppFile}, undefined) of
|
case rebar_config:get_xconf(Config, {appfile, AppFile}, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case consult_app_file(Filename) of
|
case consult_app_file(Filename) of
|
||||||
{ok, [{application, AppName, AppData}]} ->
|
{ok, {application, AppName, AppData}} ->
|
||||||
Config1 = rebar_config:set_xconf(Config,
|
Config1 = rebar_config:set_xconf(Config,
|
||||||
{appfile, AppFile},
|
{appfile, AppFile},
|
||||||
{AppName, AppData}),
|
{AppName, AppData}),
|
||||||
{ok, Config1, AppName, AppData};
|
{ok, Config1, AppName, AppData};
|
||||||
{error, _} = Error ->
|
{error, _} = Error ->
|
||||||
Error;
|
{error, {error, Error}};
|
||||||
Other ->
|
Other ->
|
||||||
{error, {unexpected_terms, Other}}
|
{error, {unexpected_terms, Other}}
|
||||||
end;
|
end;
|
||||||
|
@ -160,11 +167,17 @@ load_app_file(Config, Filename) ->
|
||||||
%% config. However, in the case of *.app, rebar should not manipulate
|
%% config. However, in the case of *.app, rebar should not manipulate
|
||||||
%% that file. This enforces that dichotomy between app and app.src.
|
%% that file. This enforces that dichotomy between app and app.src.
|
||||||
consult_app_file(Filename) ->
|
consult_app_file(Filename) ->
|
||||||
case lists:suffix(".app.src", Filename) of
|
Result = case lists:suffix(".app", Filename) of
|
||||||
false ->
|
|
||||||
file:consult(Filename);
|
|
||||||
true ->
|
true ->
|
||||||
|
file:consult(Filename);
|
||||||
|
false ->
|
||||||
rebar_config:consult_file(Filename)
|
rebar_config:consult_file(Filename)
|
||||||
|
end,
|
||||||
|
case Result of
|
||||||
|
{ok, [Term]} ->
|
||||||
|
{ok, Term};
|
||||||
|
_ ->
|
||||||
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_value(Key, AppInfo, AppFile) ->
|
get_value(Key, AppInfo, AppFile) ->
|
||||||
|
|
Loading…
Reference in a new issue