aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_state.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rcl_state.erl')
-rw-r--r--src/rcl_state.erl52
1 files changed, 16 insertions, 36 deletions
diff --git a/src/rcl_state.erl b/src/rcl_state.erl
index eb70ecc..842b635 100644
--- a/src/rcl_state.erl
+++ b/src/rcl_state.erl
@@ -30,8 +30,8 @@
overrides/1,
overrides/2,
goals/1,
- config_files/1,
- config_files/2,
+ config_file/1,
+ config_file/2,
providers/1,
providers/2,
sys_config/1,
@@ -64,7 +64,7 @@
caller :: caller(),
output_dir :: file:name(),
lib_dirs=[] :: [file:name()],
- config_files=[] :: [file:filename()],
+ config_file=[] :: file:filename(),
goals=[] :: [rcl_depsolver:constraint()],
providers = [] :: [rcl_provider:t()],
available_apps = [] :: [rcl_app_info:t()],
@@ -93,13 +93,13 @@
%%============================================================================
%% @doc Create a new 'log level' for the system
-spec new(proplists:proplist(), [file:filename()] | file:filename()) -> t().
-new(PropList, Targets) when erlang:is_list(PropList) ->
+new(PropList, Target) when erlang:is_list(PropList) ->
{ok, Root} = file:get_cwd(),
State0 =
#state_t{log = proplists:get_value(log, PropList, rcl_log:new(error)),
output_dir=proplists:get_value(output_dir, PropList, ""),
- lib_dirs=get_lib_dirs(proplists:get_value(lib_dirs, PropList, [])),
- config_files=process_config_files(Targets),
+ lib_dirs=proplists:get_value(lib_dirs, PropList, ""),
+ config_file=Target,
goals=proplists:get_value(goals, PropList, []),
providers = [],
releases=ec_dictionary:new(ec_dict),
@@ -108,7 +108,9 @@ new(PropList, Targets) when erlang:is_list(PropList) ->
root_dir = proplists:get_value(root_dir, PropList, Root),
default_release={proplists:get_value(relname, PropList, undefined),
proplists:get_value(relvsn, PropList, undefined)}},
- create_logic_providers(State0).
+ rcl_state:put(create_logic_providers(State0),
+ disable_default_libs,
+ proplists:get_value(disable_default_libs, PropList, false)).
%% @doc the application overrides for the system
-spec overrides(t()) -> [{AppName::atom(), Directory::file:filename()}].
@@ -137,13 +139,13 @@ lib_dirs(#state_t{lib_dirs=LibDir}) ->
goals(#state_t{goals=TS}) ->
TS.
--spec config_files(t()) -> [file:filename()].
-config_files(#state_t{config_files=ConfigFiles}) ->
+-spec config_file(t()) -> file:filename().
+config_file(#state_t{config_file=ConfigFiles}) ->
ConfigFiles.
--spec config_files(t(), [file:filename()]) -> t().
-config_files(State, ConfigFiles) ->
- State#state_t{config_files=ConfigFiles}.
+-spec config_file(t(), file:filename()) -> t().
+config_file(State, ConfigFiles) ->
+ State#state_t{config_file=ConfigFiles}.
-spec providers(t()) -> [rcl_provider:t()].
providers(#state_t{providers=Providers}) ->
@@ -243,15 +245,14 @@ format(Mod) ->
-spec format(t(), non_neg_integer()) -> iolist().
format(#state_t{log=LogState, output_dir=OutDir, lib_dirs=LibDirs,
caller=Caller, config_values=Values0,
- goals=Goals, config_files=ConfigFiles,
+ goals=Goals, config_file=ConfigFile,
providers=Providers},
Indent) ->
Values1 = ec_dictionary:to_list(Values0),
[rcl_util:indent(Indent),
<<"state(">>, erlang:atom_to_list(Caller), <<"):\n">>,
rcl_util:indent(Indent + 1), <<"log: ">>, rcl_log:format(LogState), <<",\n">>,
- rcl_util:indent(Indent + 1), "config files: \n",
- [[rcl_util:indent(Indent + 2), ConfigFile, ",\n"] || ConfigFile <- ConfigFiles],
+ rcl_util:indent(Indent + 1), "config file: ", ConfigFile, "\n",
rcl_util:indent(Indent + 1), "goals: \n",
[[rcl_util:indent(Indent + 2), rcl_depsolver:format_constraint(Goal), ",\n"] || Goal <- Goals],
rcl_util:indent(Indent + 1), "output_dir: ", OutDir, "\n",
@@ -265,15 +266,6 @@ format(#state_t{log=LogState, output_dir=OutDir, lib_dirs=LibDirs,
%%%===================================================================
%%% Internal Functions
%%%===================================================================
--spec get_lib_dirs([file:name()]) -> [file:name()].
-get_lib_dirs(CmdDirs) ->
- case os:getenv("ERL_LIBS") of
- false ->
- CmdDirs;
- EnvString ->
- [Lib || Lib <- re:split(EnvString, ":|;"),
- filelib:is_dir(Lib)] ++ CmdDirs
- end.
-spec create_logic_providers(t()) -> t().
create_logic_providers(State0) ->
@@ -285,18 +277,6 @@ create_logic_providers(State0) ->
State5#state_t{providers=[ConfigProvider, DiscoveryProvider,
ReleaseProvider, OverlayProvider, AssemblerProvider]}.
-
-%% @doc config files can come in as either a single file name or as a list of
-%% files. We what to support both where possible.
-process_config_files(File = [Char | _])
- when erlang:is_integer(Char) ->
- [File];
-process_config_files(Files = [File | _])
- when erlang:is_list(File) ->
- Files;
-process_config_files([]) ->
- [].
-
%%%===================================================================
%%% Test Functions
%%%===================================================================