aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_prv_discover.erl
diff options
context:
space:
mode:
authorEric B Merritt <[email protected]>2013-04-09 16:40:29 -0700
committerEric B Merritt <[email protected]>2013-04-09 16:40:50 -0700
commit4e863bd88520be1a786026eeb861cb70d00e7b01 (patch)
tree5fd62ac16db0044a0f8bac4914e39be76ced2447 /src/rcl_prv_discover.erl
parent9cc71b80c4387579469042b93f3240a0fd7c41c2 (diff)
downloadrelx-4e863bd88520be1a786026eeb861cb70d00e7b01.tar.gz
relx-4e863bd88520be1a786026eeb861cb70d00e7b01.tar.bz2
relx-4e863bd88520be1a786026eeb861cb70d00e7b01.zip
fixes #29 - look for common sub dirs for discovery
With this change relcool looks for the common sub directories to add to the search. Those directories are now, relative to the project dir, `apps`, `lib`, `ebin`, and the release output dir. These automatic subdirs can be disabled by setting `disable_project_subdirs` to `true` in the config. The release output dir is also added to the discovery process. This can be disabled by setting `disable_discover_release_output` to true.
Diffstat (limited to 'src/rcl_prv_discover.erl')
-rw-r--r--src/rcl_prv_discover.erl51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/rcl_prv_discover.erl b/src/rcl_prv_discover.erl
index 10fb28b..fa810a6 100644
--- a/src/rcl_prv_discover.erl
+++ b/src/rcl_prv_discover.erl
@@ -79,29 +79,54 @@ get_lib_dirs(State) ->
true ->
LibDirs0;
false ->
- add_current_dir(State, LibDirs0)
+ lists:flatten([LibDirs0,
+ add_common_project_dirs(State),
+ add_system_lib_dir(State),
+ add_release_output_dir(State)])
end.
--spec add_current_dir(rcl_state:t(), [file:name()]) -> [file:name()].
-add_current_dir(State, LibDirs) ->
+-spec add_common_project_dirs(rcl_state:t()) -> [file:name()].
+add_common_project_dirs(State) ->
%% Check to see if there is a rebar.config. If so then look for a deps
%% dir. If both are there then we add that to the lib dirs.
- Root = rcl_state:root_dir(State),
- add_system_lib_dir(State, [filename:absname(Root) | LibDirs]).
+ case rcl_state:get(State, disable_project_subdirs, false) of
+ true ->
+ [];
+ false ->
+ Root = rcl_state:root_dir(State),
+ Apps = filename:join(Root, "apps"),
+ Lib = filename:join(Root, "lib"),
+ Deps = filename:join(Root, "deps"),
+ lists:foldl(fun(Dir, LibDirs) ->
+ case ec_file:exists(Dir) of
+ true ->
+ [erlang:iolist_to_binary(Dir) | LibDirs];
+ false ->
+ LibDirs
+ end
+ end, [], [Deps, Lib, Apps])
+ end.
--spec add_system_lib_dir(rcl_state:t(), [file:name()]) -> [file:name()].
-add_system_lib_dir(State, LibDirs) ->
+-spec add_system_lib_dir(rcl_state:t()) -> [file:name()].
+add_system_lib_dir(State) ->
ExcludeSystem = rcl_state:get(State, discover_exclude_system, false),
-
case ExcludeSystem of
true ->
- LibDirs;
+ [];
+ false ->
+ erlang:iolist_to_binary(code:lib_dir())
+ end.
+
+add_release_output_dir(State) ->
+ case rcl_state:get(State, disable_discover_release_output, false) of
+ true ->
+ [];
false ->
- SystemLibDir0 = code:lib_dir(),
- case filelib:is_dir(SystemLibDir0) of
+ Output = erlang:iolist_to_binary(rcl_state:output_dir(State)),
+ case ec_file:exists(erlang:binary_to_list(Output)) of
true ->
- [SystemLibDir0 | LibDirs];
+ Output;
false ->
- LibDirs
+ []
end
end.