summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_app_discover.erl24
-rw-r--r--src/rebar_app_info.erl19
-rw-r--r--src/rebar_app_utils.erl9
-rw-r--r--src/rebar_config.erl3
-rw-r--r--src/rebar_otp_app.erl17
5 files changed, 59 insertions, 13 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 95b3273..a350235 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -102,13 +102,17 @@ app_dirs(LibDir) ->
"*.app.src"]),
Path2 = filename:join([LibDir,
+ "src",
+ "*.app.src.script"]),
+
+ Path3 = filename:join([LibDir,
"ebin",
"*.app"]),
lists:usort(lists:foldl(fun(Path, Acc) ->
Files = filelib:wildcard(ec_cnv:to_list(Path)),
[app_dir(File) || File <- Files] ++ Acc
- end, [], [Path1, Path2])).
+ end, [], [Path1, Path2, Path3])).
find_unbuilt_apps(LibDirs) ->
find_apps(LibDirs, invalid).
@@ -127,7 +131,8 @@ find_apps(LibDirs, Validate) ->
find_app(AppDir, Validate) ->
AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])),
AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
- AppInfo = try_handle_app_file(AppFile, AppDir, AppSrcFile, Validate),
+ AppSrcScriptFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src.script"])),
+ AppInfo = try_handle_app_file(AppFile, AppDir, AppSrcFile, AppSrcScriptFile, Validate),
AppInfo.
app_dir(AppFile) ->
@@ -158,9 +163,11 @@ dedup([H|T]) -> [H|dedup(T)].
%% Read in and parse the .app file if it is availabe. Do the same for
%% the .app.src file if it exists.
-try_handle_app_file([], AppDir, AppSrcFile, Validate) ->
+try_handle_app_file([], AppDir, [], AppSrcScriptFile, Validate) ->
+ try_handle_app_src_file([], AppDir, AppSrcScriptFile, Validate);
+try_handle_app_file([], AppDir, AppSrcFile, _, Validate) ->
try_handle_app_src_file([], AppDir, AppSrcFile, Validate);
-try_handle_app_file([File], AppDir, AppSrcFile, Validate) ->
+try_handle_app_file([File], AppDir, AppSrcFile, _, Validate) ->
try create_app_info(AppDir, File) of
AppInfo ->
AppInfo1 = rebar_app_info:app_file(AppInfo, File),
@@ -195,7 +202,7 @@ try_handle_app_file([File], AppDir, AppSrcFile, Validate) ->
?DEBUG("Falling back to app.src file because .app failed: ~s", [Module:format_error(Reason)]),
try_handle_app_src_file(File, AppDir, AppSrcFile, Validate)
end;
-try_handle_app_file(Other, _AppDir, _AppSrcFile, _Validate) ->
+try_handle_app_file(Other, _AppDir, _AppSrcFile, _, _Validate) ->
throw({error, {multiple_app_files, Other}}).
%% Read in the .app.src file if we aren't looking for a valid (already built) app
@@ -210,7 +217,12 @@ try_handle_app_src_file(_, AppDir, [File], Validate) when Validate =:= invalid
{error, Reason} ->
throw({error, {invalid_app_file, File, Reason}});
_ ->
- {true, rebar_app_info:app_file_src(AppInfo, File)}
+ case filename:extension(File) of
+ ".script" ->
+ {true, rebar_app_info:app_file_src_script(AppInfo, File)};
+ _ ->
+ {true, rebar_app_info:app_file_src(AppInfo, File)}
+ end
end;
try_handle_app_src_file(_, _AppDir, Other, _Validate) ->
throw({error, {multiple_app_files, Other}}).
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl
index 6e35b8f..6962c5a 100644
--- a/src/rebar_app_info.erl
+++ b/src/rebar_app_info.erl
@@ -11,6 +11,8 @@
config/2,
app_file_src/1,
app_file_src/2,
+ app_file_src_script/1,
+ app_file_src_script/2,
app_file/1,
app_file/2,
app_details/1,
@@ -48,6 +50,7 @@
-record(app_info_t, {name :: binary(),
app_file_src :: file:filename_all() | undefined,
+ app_file_src_script:: file:filename_all() | undefined,
app_file :: file:filename_all() | undefined,
config :: rebar_state:t() | undefined,
original_vsn :: binary() | string() | undefined,
@@ -146,6 +149,22 @@ app_file_src(#app_info_t{app_file_src=AppFileSrc}) ->
app_file_src(AppInfo=#app_info_t{}, AppFileSrc) ->
AppInfo#app_info_t{app_file_src=ec_cnv:to_list(AppFileSrc)}.
+-spec app_file_src_script(t()) -> file:filename_all() | undefined.
+app_file_src_script(#app_info_t{app_file_src_script=undefined, dir=Dir, name=Name}) ->
+ AppFileSrcScript = filename:join([ec_cnv:to_list(Dir), "src", ec_cnv:to_list(Name)++".app.src.script"]),
+ case filelib:is_file(AppFileSrcScript) of
+ true ->
+ AppFileSrcScript;
+ false ->
+ undefined
+ end;
+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{}, AppFileSrcScript) ->
+ AppInfo#app_info_t{app_file_src_script=ec_cnv:to_list(AppFileSrcScript)}.
+
-spec app_file(t()) -> file:filename_all() | undefined.
app_file(#app_info_t{app_file=undefined, out_dir=Dir, name=Name}) ->
AppFile = filename:join([ec_cnv:to_list(Dir), "ebin", ec_cnv:to_list(Name)++".app"]),
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 3da00be..92c3ff8 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -58,7 +58,14 @@ is_app_src(Filename) ->
Filename =/= filename:rootname(Filename, ".app.src").
app_src_to_app(OutDir, Filename) ->
- AppFile = filename:join([OutDir, "ebin", filename:basename(Filename, ".app.src") ++ ".app"]),
+ AppFile =
+ case lists:suffix(".app.src", Filename) of
+ true ->
+ filename:join([OutDir, "ebin", filename:basename(Filename, ".app.src") ++ ".app"]);
+ false ->
+ filename:join([OutDir, "ebin", filename:basename(Filename,
+ ".app.src.script") ++ ".app"])
+ end,
filelib:ensure_dir(AppFile),
AppFile.
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 3e06c38..d2b4a12 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -63,7 +63,8 @@ consult_file_(File) when is_binary(File) ->
consult_file_(File) ->
case filename:extension(File) of
".script" ->
- consult_and_eval(remove_script_ext(File), File);
+ {ok, Terms} = consult_and_eval(remove_script_ext(File), File),
+ [Terms];
_ ->
Script = File ++ ".script",
case filelib:is_regular(Script) of
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 9f61e71..507da70 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -40,11 +40,17 @@ compile(State, App) ->
%% If we get an .app.src file, it needs to be pre-processed and
%% written out as a ebin/*.app file. That resulting file will then
%% be validated as usual.
- App1 = case rebar_app_info:app_file_src(App) of
+ App1 = case rebar_app_info:app_file_src_script(App) of
undefined ->
- App;
- AppFileSrc ->
- File = preprocess(State, App, AppFileSrc),
+ case rebar_app_info:app_file_src(App) of
+ undefined ->
+ App;
+ AppFileSrc ->
+ File = preprocess(State, App, AppFileSrc),
+ rebar_app_info:app_file(App, File)
+ end;
+ AppFileSrcScript ->
+ File = preprocess(State, App, AppFileSrcScript),
rebar_app_info:app_file(App, File)
end,
@@ -199,7 +205,8 @@ consult_app_file(Filename) ->
false ->
{error, enoent};
true ->
- case lists:suffix(".app.src", Filename) of
+ case lists:suffix(".app.src", Filename)
+ orelse lists:suffix(".app.src.script", Filename) of
false ->
file:consult(Filename);
true ->