From 78ec90ae6084f44b5379bd4e9eebb79746f4a595 Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 30 Dec 2012 19:15:01 -0500 Subject: support only one config file in the system --- src/rcl_state.erl | 48 +++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) (limited to 'src/rcl_state.erl') diff --git a/src/rcl_state.erl b/src/rcl_state.erl index eb70ecc..28effbd 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), @@ -137,13 +137,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 +243,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 +264,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 +275,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 %%%=================================================================== -- cgit v1.2.3