|
|
@ -7,8 +7,10 @@ |
|
|
|
find_unbuilt_apps/1, |
|
|
|
find_apps/1, |
|
|
|
find_apps/2, |
|
|
|
find_apps/3, |
|
|
|
find_app/2, |
|
|
|
find_app/3]). |
|
|
|
find_app/3, |
|
|
|
find_app/4]). |
|
|
|
|
|
|
|
-include("rebar.hrl"). |
|
|
|
-include_lib("providers/include/providers.hrl"). |
|
|
@ -20,7 +22,9 @@ |
|
|
|
do(State, LibDirs) -> |
|
|
|
BaseDir = rebar_state:dir(State), |
|
|
|
Dirs = [filename:join(BaseDir, LibDir) || LibDir <- LibDirs], |
|
|
|
Apps = find_apps(Dirs, all), |
|
|
|
RebarOpts = rebar_state:opts(State), |
|
|
|
SrcDirs = rebar_dir:src_dirs(RebarOpts, ["src"]), |
|
|
|
Apps = find_apps(Dirs, SrcDirs, all), |
|
|
|
ProjectDeps = rebar_state:deps_names(State), |
|
|
|
DepsDir = rebar_dir:deps_dir(State), |
|
|
|
CurrentProfiles = rebar_state:current_profiles(State), |
|
|
@ -179,32 +183,25 @@ reset_hooks(Opts) -> |
|
|
|
rebar_opts:set(OptsAcc, Key, []) |
|
|
|
end, Opts, [post_hooks, pre_hooks, provider_hooks, artifacts]). |
|
|
|
|
|
|
|
%% @doc find the directories for all apps |
|
|
|
-spec all_app_dirs([file:name()]) -> [file:name()]. |
|
|
|
all_app_dirs(LibDirs) -> |
|
|
|
lists:flatmap(fun(LibDir) -> |
|
|
|
app_dirs(LibDir) |
|
|
|
end, LibDirs). |
|
|
|
%% @doc find the directories for all apps based on their source dirs |
|
|
|
-spec all_app_dirs([file:name()], [file:name()]) -> [file:name()]. |
|
|
|
all_app_dirs(LibDirs, SrcDirs) -> |
|
|
|
lists:flatmap(fun(LibDir) -> app_dirs(LibDir, SrcDirs) end, LibDirs). |
|
|
|
|
|
|
|
%% @doc find the directories based on the library directories |
|
|
|
-spec app_dirs([file:name()]) -> [file:name()]. |
|
|
|
app_dirs(LibDir) -> |
|
|
|
Path1 = filename:join([LibDir, |
|
|
|
"src", |
|
|
|
"*.app.src"]), |
|
|
|
|
|
|
|
Path2 = filename:join([LibDir, |
|
|
|
"src", |
|
|
|
"*.app.src.script"]), |
|
|
|
|
|
|
|
Path3 = filename:join([LibDir, |
|
|
|
"ebin", |
|
|
|
"*.app"]), |
|
|
|
-spec app_dirs([file:name()], [file:name()]) -> [file:name()]. |
|
|
|
app_dirs(LibDir, SrcDirs) -> |
|
|
|
Paths = lists:append([ |
|
|
|
[filename:join([LibDir, SrcDir, "*.app.src"]), |
|
|
|
filename:join([LibDir, SrcDir, "*.app.src.script"])] |
|
|
|
|| SrcDir <- SrcDirs |
|
|
|
]), |
|
|
|
EbinPath = 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, Path3])). |
|
|
|
end, [], [EbinPath | Paths])). |
|
|
|
|
|
|
|
%% @doc find all apps that haven't been built in a list of directories |
|
|
|
-spec find_unbuilt_apps([file:filename_all()]) -> [rebar_app_info:t()]. |
|
|
@ -215,23 +212,33 @@ find_unbuilt_apps(LibDirs) -> |
|
|
|
%% Returns all the related app info records. |
|
|
|
-spec find_apps([file:filename_all()]) -> [rebar_app_info:t()]. |
|
|
|
find_apps(LibDirs) -> |
|
|
|
find_apps(LibDirs, valid). |
|
|
|
find_apps(LibDirs, ["src"], valid). |
|
|
|
|
|
|
|
%% @doc for each directory passed, find all apps according |
|
|
|
%% to the validity rule passed in. Returns all the related |
|
|
|
%% app info records. |
|
|
|
-spec find_apps([file:filename_all()], valid | invalid | all) -> [rebar_app_info:t()]. |
|
|
|
find_apps(LibDirs, Validate) -> |
|
|
|
rebar_utils:filtermap(fun(AppDir) -> |
|
|
|
find_app(AppDir, Validate) |
|
|
|
end, all_app_dirs(LibDirs)). |
|
|
|
find_apps(LibDirs, ["src"], Validate). |
|
|
|
|
|
|
|
%% @doc for each directory passed, with the configured source directories, |
|
|
|
%% find all apps according to the validity rule passed in. |
|
|
|
%% Returns all the related app info records. |
|
|
|
-spec find_apps([file:filename_all()], [file:filename_all()], valid | invalid | all) -> [rebar_app_info:t()]. |
|
|
|
find_apps(LibDirs, SrcDirs, Validate) -> |
|
|
|
rebar_utils:filtermap( |
|
|
|
fun(AppDir) -> |
|
|
|
find_app(rebar_app_info:new(), AppDir, SrcDirs, Validate) |
|
|
|
end, |
|
|
|
all_app_dirs(LibDirs, SrcDirs) |
|
|
|
). |
|
|
|
|
|
|
|
%% @doc check that a given app in a directory is there, and whether it's |
|
|
|
%% valid or not based on the second argument. Returns the related |
|
|
|
%% app info record. |
|
|
|
-spec find_app(file:filename_all(), valid | invalid | all) -> {true, rebar_app_info:t()} | false. |
|
|
|
find_app(AppDir, Validate) -> |
|
|
|
find_app(rebar_app_info:new(), AppDir, Validate). |
|
|
|
find_app(rebar_app_info:new(), AppDir, ["src"], Validate). |
|
|
|
|
|
|
|
%% @doc check that a given app in a directory is there, and whether it's |
|
|
|
%% valid or not based on the second argument. Returns the related |
|
|
@ -239,9 +246,25 @@ find_app(AppDir, Validate) -> |
|
|
|
-spec find_app(rebar_app_info:t(), file:filename_all(), valid | invalid | all) -> |
|
|
|
{true, rebar_app_info:t()} | false. |
|
|
|
find_app(AppInfo, AppDir, Validate) -> |
|
|
|
find_app(AppInfo, AppDir, ["src"], Validate). |
|
|
|
|
|
|
|
%% @doc check that a given app in a directory is there, and whether it's |
|
|
|
%% valid or not based on the second argument. The third argument includes |
|
|
|
%% the directories where source files can be located. Returns the related |
|
|
|
%% app info record. |
|
|
|
-spec find_app(rebar_app_info:t(), file:filename_all(), |
|
|
|
[file:filename_all()], valid | invalid | all) -> |
|
|
|
{true, rebar_app_info:t()} | false. |
|
|
|
find_app(AppInfo, AppDir, SrcDirs, Validate) -> |
|
|
|
AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])), |
|
|
|
AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])), |
|
|
|
AppSrcScriptFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src.script"])), |
|
|
|
AppSrcFile = lists:append( |
|
|
|
[filelib:wildcard(filename:join([AppDir, SrcDir, "*.app.src"])) |
|
|
|
|| SrcDir <- SrcDirs] |
|
|
|
), |
|
|
|
AppSrcScriptFile = lists:append( |
|
|
|
[filelib:wildcard(filename:join([AppDir, SrcDir, "*.app.src.script"])) |
|
|
|
|| SrcDir <- SrcDirs] |
|
|
|
), |
|
|
|
try_handle_app_file(AppInfo, AppFile, AppDir, AppSrcFile, AppSrcScriptFile, Validate). |
|
|
|
|
|
|
|
%% @doc find the directory that an appfile has |
|
|
|