summaryrefslogtreecommitdiff
path: root/src/rebar_app_discover.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_app_discover.erl')
-rw-r--r--src/rebar_app_discover.erl40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index c90a8df..ae4916e 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -13,7 +13,8 @@ do(State, LibDirs) ->
Apps = find_apps(Dirs, all),
ProjectDeps = rebar_state:deps_names(State),
lists:foldl(fun(AppInfo, StateAcc) ->
- rebar_state:project_apps(StateAcc, rebar_app_info:deps(AppInfo, ProjectDeps))
+ ProjectDeps1 = lists:delete(rebar_app_info:name(AppInfo), ProjectDeps),
+ rebar_state:project_apps(StateAcc, rebar_app_info:deps(AppInfo, ProjectDeps1))
end, State, Apps).
-spec all_app_dirs(list(file:name())) -> list(file:name()).
@@ -47,14 +48,17 @@ app_dirs(LibDir) ->
find_unbuilt_apps(LibDirs) ->
find_apps(LibDirs, invalid).
+-spec find_apps([file:filename_all()]) -> [rebar_app_info:t()].
find_apps(LibDirs) ->
find_apps(LibDirs, valid).
+-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)).
+-spec find_app(file:filename_all(), valid | invalid | all) -> {true, rebar_app_info:t()} | false.
find_app(AppDir, Validate) ->
AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])),
AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
@@ -104,12 +108,17 @@ find_app(AppDir, Validate) ->
app_dir(AppFile) ->
filename:join(rebar_utils:droplast(filename:split(filename:dirname(AppFile)))).
+-spec create_app_info(file:name(), file:name()) -> rebar_app_info:t() | error.
create_app_info(AppDir, AppFile) ->
case file:consult(AppFile) of
{ok, [{application, AppName, AppDetails}]} ->
AppVsn = proplists:get_value(vsn, AppDetails),
+ %AppDeps = proplists:get_value(applications, AppDetails, []),
+ C = rebar_config:consult(AppDir),
+ S = rebar_state:new(rebar_state:new(), C, AppDir),
+ AppDeps = rebar_state:deps_names(S),
AbsCwd = filename:absname(rebar_utils:get_cwd()),
- {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir),
+ {ok, AppInfo} = rebar_app_info:new(AppName, AppVsn, AppDir, AppDeps),
RebarConfig = filename:join(AppDir, "rebar.config"),
AppState = case filelib:is_file(RebarConfig) of
true ->
@@ -121,22 +130,28 @@ create_app_info(AppDir, AppFile) ->
AppState1 = rebar_state:set(AppState, base_dir, AbsCwd),
AppInfo1 = rebar_app_info:config(
rebar_app_info:app_details(AppInfo, AppDetails), AppState1),
- rebar_app_info:dir(AppInfo1, AppDir)
+ rebar_app_info:dir(AppInfo1, AppDir);
+ _ ->
+ error
end.
-spec validate_application_info(rebar_app_info:t()) -> boolean().
validate_application_info(AppInfo) ->
EbinDir = rebar_app_info:ebin_dir(AppInfo),
- AppFile = rebar_app_info:app_file(AppInfo),
- AppDetail = rebar_app_info:app_details(AppInfo),
- case get_modules_list(AppFile, AppDetail) of
- {ok, List} ->
- has_all_beams(EbinDir, List);
- _Error ->
- false
+ case rebar_app_info:app_file(AppInfo) of
+ undefined ->
+ false;
+ AppFile ->
+ AppDetail = rebar_app_info:app_details(AppInfo),
+ case get_modules_list(AppFile, AppDetail) of
+ {ok, List} ->
+ has_all_beams(EbinDir, List);
+ _Error ->
+ false
+ end
end.
--spec get_modules_list(file:name(), proplists:proplist()) ->
+-spec get_modules_list(file:filename_all(), proplists:proplist()) ->
{ok, list()} |
{warning, Reason::term()} |
{error, Reason::term()}.
@@ -148,8 +163,7 @@ get_modules_list(AppFile, AppDetail) ->
{ok, ModulesList}
end.
--spec has_all_beams(file:name(), list()) ->
- ok | {error, Reason::term()}.
+-spec has_all_beams(file:filename_all(), list()) -> boolean().
has_all_beams(EbinDir, [Module | ModuleList]) ->
BeamFile = filename:join([EbinDir,
ec_cnv:to_list(Module) ++ ".beam"]),