From 7d55c9986f6d0c76575083dae440f06a94c1afc1 Mon Sep 17 00:00:00 2001 From: Vlad Dumitrescu Date: Wed, 3 Dec 2014 18:39:17 +0100 Subject: [PATCH] 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. --- THANKS | 1 + src/rebar_app_utils.erl | 31 ++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/THANKS b/THANKS index b5d19be..943a0c3 100644 --- a/THANKS +++ b/THANKS @@ -129,3 +129,4 @@ Andras Horvath Drew Varner Roberto Aloi Luis Rascao +Vlad Dumitrescu diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 7a1654e..e0751e3 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -73,10 +73,17 @@ is_app_dir(Dir) -> is_app_src(Filename) -> %% If removing the extension .app.src yields a shorter name, %% 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) -> - 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) -> 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 undefined -> case consult_app_file(Filename) of - {ok, [{application, AppName, AppData}]} -> + {ok, {application, AppName, AppData}} -> Config1 = rebar_config:set_xconf(Config, {appfile, AppFile}, {AppName, AppData}), {ok, Config1, AppName, AppData}; {error, _} = Error -> - Error; + {error, {error, Error}}; Other -> {error, {unexpected_terms, Other}} end; @@ -160,11 +167,17 @@ load_app_file(Config, Filename) -> %% config. However, in the case of *.app, rebar should not manipulate %% that file. This enforces that dichotomy between app and app.src. consult_app_file(Filename) -> - case lists:suffix(".app.src", Filename) of - false -> - file:consult(Filename); - true -> - rebar_config:consult_file(Filename) + Result = case lists:suffix(".app", Filename) of + true -> + file:consult(Filename); + false -> + rebar_config:consult_file(Filename) + end, + case Result of + {ok, [Term]} -> + {ok, Term}; + _ -> + Result end. get_value(Key, AppInfo, AppFile) ->