aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rcl_app_info.erl2
-rw-r--r--src/rcl_cmd_args.erl80
-rw-r--r--src/rcl_goal_utils.erl2
-rw-r--r--src/rcl_log.erl2
-rw-r--r--src/rcl_provider.erl16
-rw-r--r--src/rcl_prv_assembler.erl2
-rw-r--r--src/rcl_prv_config.erl16
-rw-r--r--src/rcl_prv_discover.erl2
-rw-r--r--src/rcl_prv_overlay.erl2
-rw-r--r--src/rcl_prv_release.erl2
-rw-r--r--src/rcl_release.erl2
-rw-r--r--src/rcl_state.erl14
-rw-r--r--src/rcl_topo.erl17
-rw-r--r--src/rcl_util.erl2
-rw-r--r--src/relcool.erl10
15 files changed, 119 insertions, 52 deletions
diff --git a/src/rcl_app_info.erl b/src/rcl_app_info.erl
index b73d609..f2afa0b 100644
--- a/src/rcl_app_info.erl
+++ b/src/rcl_app_info.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_cmd_args.erl b/src/rcl_cmd_args.erl
index 6340201..973abe3 100644
--- a/src/rcl_cmd_args.erl
+++ b/src/rcl_cmd_args.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
@@ -38,18 +38,17 @@ args2state({ok, {Opts, Target}})
when erlang:length(Target) == 0; erlang:length(Target) == 1 ->
RelName = proplists:get_value(relname, Opts, undefined),
RelVsn = proplists:get_value(relvsn, Opts, undefined),
- case create_log(Opts,
- [{relname, RelName},
- {relvsn, RelVsn}]) of
- Error = {error, _} ->
- Error;
- {ok, CommandLineConfig} ->
- case validate_configs(Target) of
+ case convert_target(Target) of
+ {ok, AtomizedTarget} ->
+ case create_log(Opts, [{relname, RelName},
+ {relvsn, RelVsn}]) of
Error = {error, _} ->
Error;
- {ok, Configs} ->
- {ok, rcl_state:new(CommandLineConfig, Configs)}
- end
+ {ok, CommandLineConfig} ->
+ handle_config(Opts, AtomizedTarget, CommandLineConfig)
+ end;
+ Error ->
+ Error
end;
args2state({ok, {_Opts, Targets}}) ->
?RCL_ERROR({invalid_targets, Targets}).
@@ -84,32 +83,47 @@ format_error({not_directory, Dir}) ->
io_lib:format("Library directory does not exist: ~s", [Dir]);
format_error({invalid_log_level, LogLevel}) ->
io_lib:format("Invalid log level specified -V ~p, log level must be in the"
- " range 0..2", [LogLevel]).
+ " range 0..2", [LogLevel]);
+format_error({invalid_target, Target}) ->
+ io_lib:format("Invalid action specified: ~s", [Target]).
+
%%%===================================================================
%%% Internal Functions
%%%===================================================================
--spec validate_configs([file:filename()]) ->
- {ok, [file:filename()]} | relcool:error().
-validate_configs(Configs) ->
- Result =
- lists:foldl(fun(_Config, Err = {error, _}) ->
- Err;
- (Config, Acc) ->
- case filelib:is_regular(Config) of
- true ->
- [filename:absname(Config) | Acc];
- false ->
- ?RCL_ERROR({invalid_config_file, Config})
- end
- end, [], Configs),
- case Result of
- {error, _} ->
- Result;
- _ ->
- %% Order may be important so lets make sure they remain in the same
- %% order they came in as
- {ok, lists:reverse(Result)}
+-spec handle_config([getopt:option()], atom(), proplists:proplist()) ->
+ {ok, {rcl_state:t(), [string()]}} |
+ relcool:error().
+handle_config(Opts, Target, CommandLineConfig) ->
+ case validate_config(proplists:get_value(config, Opts, [])) of
+ Error = {error, _} ->
+ Error;
+ {ok, Config} ->
+ {ok, rcl_state:new([{config, Config} | CommandLineConfig], Target)}
+ end.
+
+-spec convert_target([string()]) -> {ok, release | relup} | relcool:error().
+convert_target([]) ->
+ {ok, release};
+convert_target(["release"]) ->
+ {ok, release};
+convert_target(["relup"]) ->
+ {ok, relup};
+convert_target(Target) ->
+ ?RCL_ERROR({invalid_target, Target}).
+
+-spec validate_config(file:filename() | undefined) ->
+ {ok, file:filename() | undefined} | relcool:error().
+validate_config(undefined) ->
+ {ok, undefined};
+validate_config("") ->
+ {ok, undefined};
+validate_config(Config) ->
+ case filelib:is_regular(Config) of
+ true ->
+ filename:absname(Config);
+ false ->
+ ?RCL_ERROR({invalid_config_file, Config})
end.
-spec create_log([getopt:option()], rcl_state:cmd_args()) ->
diff --git a/src/rcl_goal_utils.erl b/src/rcl_goal_utils.erl
index 3627b9c..6065e5c 100644
--- a/src/rcl_goal_utils.erl
+++ b/src/rcl_goal_utils.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_log.erl b/src/rcl_log.erl
index a24b1c0..71c0b5d 100644
--- a/src/rcl_log.erl
+++ b/src/rcl_log.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_provider.erl b/src/rcl_provider.erl
index c3ef434..750b96e 100644
--- a/src/rcl_provider.erl
+++ b/src/rcl_provider.erl
@@ -1,3 +1,19 @@
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
+%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
+%%%
+%%% This file is provided to you under the Apache License,
+%%% Version 2.0 (the "License"); you may not use this file
+%%% except in compliance with the License. You may obtain
+%%% a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing,
+%%% software distributed under the License is distributed on an
+%%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%%% KIND, either express or implied. See the License for the
+%%% specific language governing permissions and limitations
+%%% under the License.
%%%-------------------------------------------------------------------
%%% @author Eric Merritt <[email protected]>
%%% @copyright 2011 Erlware, LLC.
diff --git a/src/rcl_prv_assembler.erl b/src/rcl_prv_assembler.erl
index 61f6dad..5488617 100644
--- a/src/rcl_prv_assembler.erl
+++ b/src/rcl_prv_assembler.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_prv_config.erl b/src/rcl_prv_config.erl
index f87c467..5d51300 100644
--- a/src/rcl_prv_config.erl
+++ b/src/rcl_prv_config.erl
@@ -1,3 +1,19 @@
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
+%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
+%%%
+%%% This file is provided to you under the Apache License,
+%%% Version 2.0 (the "License"); you may not use this file
+%%% except in compliance with the License. You may obtain
+%%% a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing,
+%%% software distributed under the License is distributed on an
+%%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%%% KIND, either express or implied. See the License for the
+%%% specific language governing permissions and limitations
+%%% under the License.
%%%-------------------------------------------------------------------
%%% @author Eric Merritt <[email protected]>
%%% @copyright 2011 Erlware, LLC.
diff --git a/src/rcl_prv_discover.erl b/src/rcl_prv_discover.erl
index 4e7ce72..595902a 100644
--- a/src/rcl_prv_discover.erl
+++ b/src/rcl_prv_discover.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_prv_overlay.erl b/src/rcl_prv_overlay.erl
index 94b5f3d..40471ea 100644
--- a/src/rcl_prv_overlay.erl
+++ b/src/rcl_prv_overlay.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_prv_release.erl b/src/rcl_prv_release.erl
index 8a86e02..a98048f 100644
--- a/src/rcl_prv_release.erl
+++ b/src/rcl_prv_release.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_release.erl b/src/rcl_release.erl
index aa5de72..560a555 100644
--- a/src/rcl_release.erl
+++ b/src/rcl_release.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/rcl_state.erl b/src/rcl_state.erl
index 842b635..ecf3115 100644
--- a/src/rcl_state.erl
+++ b/src/rcl_state.erl
@@ -1,4 +1,4 @@
-%%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
@@ -62,6 +62,7 @@
-record(state_t, {log :: rcl_log:t(),
root_dir :: file:name(),
caller :: caller(),
+ action :: atom(),
output_dir :: file:name(),
lib_dirs=[] :: [file:name()],
config_file=[] :: file:filename(),
@@ -92,14 +93,17 @@
%% API
%%============================================================================
%% @doc Create a new 'log level' for the system
--spec new(proplists:proplist(), [file:filename()] | file:filename()) -> t().
-new(PropList, Target) when erlang:is_list(PropList) ->
+-spec new(proplists:proplist(), atom()) -> t().
+new(PropList, Target)
+ when erlang:is_list(PropList),
+ erlang:is_atom(Target) ->
{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=proplists:get_value(lib_dirs, PropList, ""),
- config_file=Target,
+ config_file=proplists:get_value(config, PropList, ""),
+ action = Target,
goals=proplists:get_value(goals, PropList, []),
providers = [],
releases=ec_dictionary:new(ec_dict),
@@ -286,7 +290,7 @@ create_logic_providers(State0) ->
new_test() ->
LogState = rcl_log:new(error),
- RCLState = new([{log, LogState}], []),
+ RCLState = new([{log, LogState}], release),
?assertMatch(LogState, log(RCLState)).
-endif.
diff --git a/src/rcl_topo.erl b/src/rcl_topo.erl
index ec67b56..462b7c5 100644
--- a/src/rcl_topo.erl
+++ b/src/rcl_topo.erl
@@ -1,4 +1,19 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
+%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
+%%%
+%%% This file is provided to you under the Apache License,
+%%% Version 2.0 (the "License"); you may not use this file
+%%% except in compliance with the License. You may obtain
+%%% a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing,
+%%% software distributed under the License is distributed on an
+%%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%%% KIND, either express or implied. See the License for the
+%%% specific language governing permissions and limitations
+%%% under the License.
%%%-------------------------------------------------------------------
%%% @author Joe Armstrong
%%% @author Eric Merritt
diff --git a/src/rcl_util.erl b/src/rcl_util.erl
index f89ba73..06d957d 100644
--- a/src/rcl_util.erl
+++ b/src/rcl_util.erl
@@ -1,4 +1,4 @@
-%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
diff --git a/src/relcool.erl b/src/relcool.erl
index 974b19f..83886c5 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -1,4 +1,4 @@
-%%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
%%%
%%% This file is provided to you under the Apache License,
@@ -48,7 +48,7 @@ main(Args) ->
{ok, State} ->
run_relcool_process(rcl_state:caller(State, command_line));
Error={error, _} ->
- report_error(rcl_state:caller(rcl_state:new([], []),
+ report_error(rcl_state:caller(rcl_state:new([], undefined),
command_line), Error)
end.
@@ -106,8 +106,9 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Con
{output_dir, OutputDir},
{lib_dirs, LibDirs},
{root_dir, RootDir},
- {log, rcl_log:new(LogLevel)}],
- Config),
+ {log, rcl_log:new(LogLevel)},
+ {config, Config}],
+ release),
run_relcool_process(rcl_state:caller(State, api)).
@@ -127,6 +128,7 @@ opt_spec_list() ->
"Disable the default system added lib dirs (means you must add them all manually"},
{log_level, $V, "verbose", {integer, 1},
"Verbosity level, maybe between 0 and 2"},
+ {config, $c, "config", string, "The path to a config file"},
{root_dir, $r, "root", string, "The project root directory"}].
-spec format_error(Reason::term()) -> iolist().