summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.erl
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-10-10 17:31:25 -0500
committerTristan Sloughter <t@crashfast.com>2014-10-10 17:31:25 -0500
commit90cfb2a794e16dbf583a3591f448ced4a32f579f (patch)
tree88fe55045741a9a137144423c40fb468233a4d83 /src/rebar_prv_compile.erl
parent587e57c03c21531dbffc0932a0a8bf9e46fa413c (diff)
support compile jobs option
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r--src/rebar_prv_compile.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 773e8a9..60314b3 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -19,10 +19,9 @@
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- Jobs = ?DEFAULT_JOBS,
JobsHelp = io_lib:format(
"Number of concurrent workers a command may use. Default: ~B",
- [Jobs]),
+ [?DEFAULT_JOBS]),
State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
{module, ?MODULE},
{bare, false},
@@ -37,16 +36,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
- ProjectApps = rebar_state:project_apps(State),
- Deps = rebar_state:get(State, deps_to_build, []),
+ {ok, State1} = handle_args(State),
+
+ ProjectApps = rebar_state:project_apps(State1),
+ Deps = rebar_state:get(State1, deps_to_build, []),
lists:foreach(fun(AppInfo) ->
C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
- S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(AppInfo)),
+ S = rebar_state:new(State1, C, rebar_app_info:dir(AppInfo)),
build(S, AppInfo)
end, Deps++ProjectApps),
- {ok, State}.
+ {ok, State1}.
build(State, AppInfo) ->
?INFO("Compiling ~s~n", [rebar_app_info:name(AppInfo)]),
@@ -57,3 +58,8 @@ build(State, AppInfo) ->
%% ===================================================================
%% Internal functions
%% ===================================================================
+
+handle_args(State) ->
+ {Args, _} = rebar_state:command_parsed_args(State),
+ Jobs = proplists:get_value(jobs, Args, ?DEFAULT_JOBS),
+ {ok, rebar_state:set(State, jobs, Jobs)}.