From 6356112cbbb32b09dd2f94ea856c3cbd32b1c085 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 21 Sep 2014 09:19:38 -0500 Subject: more dialyzer fun. no likey opaque types --- src/rebar_prv_compile.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index d89a4b0..11ee97a 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -27,7 +27,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error(). +-spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> ProjectApps = rebar_state:project_apps(State), Deps = rebar_state:get(State, deps_to_build, []), -- cgit v1.1 From e9a3396e56679a11ac1caa3b47f1f196f0307d72 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 27 Sep 2014 14:12:11 -0500 Subject: return error messages from providers --- src/rebar_prv_compile.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 11ee97a..8ec0560 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -27,7 +27,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()}. +-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, []), -- cgit v1.1 From b37a5ae611aaf6b84a046fbe716f40c2aa8c75d8 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 3 Oct 2014 06:33:33 -0500 Subject: move providers to separate app --- src/rebar_prv_compile.erl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 8ec0560..fdeafdd 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -1,6 +1,6 @@ -module(rebar_prv_compile). --behaviour(rebar_provider). +-behaviour(provider). -export([init/1, do/1, @@ -17,14 +17,14 @@ -spec init(rebar_state:t()) -> {ok, rebar_state:t()}. init(State) -> - State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER, - provider_impl = ?MODULE, - bare = false, - deps = ?DEPS, - example = "rebar compile", - short_desc = "Compile apps .app.src and .erl files.", - desc = "", - opts = []}), + State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, + {module, ?MODULE}, + {bare, false}, + {deps, ?DEPS}, + {example, "rebar compile"}, + {short_desc, "Compile apps .app.src and .erl files."}, + {desc, ""}, + {opts, []}])), {ok, State1}. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -- cgit v1.1 From b20680304d02a10babff15ff69a78a816077fa3c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 11:47:41 -0500 Subject: split options up by task --- src/rebar_prv_compile.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index fdeafdd..773e8a9 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -11,12 +11,18 @@ -define(PROVIDER, compile). -define(DEPS, [lock]). +-define(DEFAULT_JOBS, 3). + %% =================================================================== %% Public API %% =================================================================== -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]), State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, {module, ?MODULE}, {bare, false}, @@ -24,7 +30,9 @@ init(State) -> {example, "rebar compile"}, {short_desc, "Compile apps .app.src and .erl files."}, {desc, ""}, - {opts, []}])), + {opts, [ + {jobs, $j, "jobs", integer, JobsHelp} + ]}])), {ok, State1}. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -- cgit v1.1 From 90cfb2a794e16dbf583a3591f448ced4a32f579f Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 17:31:25 -0500 Subject: support compile jobs option --- src/rebar_prv_compile.erl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/rebar_prv_compile.erl') 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)}. -- cgit v1.1 From 6e4b68e28eacefcf42d96dd1492e12b96c1bfdda Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 19:34:10 -0500 Subject: fix compile task help msg --- src/rebar_prv_compile.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 60314b3..e8a7154 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -20,7 +20,7 @@ -spec init(rebar_state:t()) -> {ok, rebar_state:t()}. init(State) -> JobsHelp = io_lib:format( - "Number of concurrent workers a command may use. Default: ~B", + "Number of concurrent workers the compiler may use. Default: ~B", [?DEFAULT_JOBS]), State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, {module, ?MODULE}, -- cgit v1.1 From 141d34a5d01216b7e918b07c22ee998766217b6d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 16 Oct 2014 11:15:37 -0500 Subject: remove unused utils functions --- src/rebar_prv_compile.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index e8a7154..fe0e197 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -42,8 +42,9 @@ do(State) -> 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(State1, C, rebar_app_info:dir(AppInfo)), + AppDir = rebar_app_info:dir(AppInfo), + C = rebar_config:consult(AppDir), + S = rebar_state:new(State1, C, AppDir), build(S, AppInfo) end, Deps++ProjectApps), -- cgit v1.1 From 1dce2d36cc75263db279abd7f282772ce0f0f3e6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Wed, 22 Oct 2014 12:03:49 -0500 Subject: add format_error/2 provider callback to providers --- src/rebar_prv_compile.erl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index fe0e197..30611cd 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -4,6 +4,7 @@ -export([init/1, do/1, + format_error/2, build/2]). -include("rebar.hrl"). @@ -50,6 +51,10 @@ do(State) -> {ok, State1}. +-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}. +format_error(Reason, State) -> + {io_lib:format("~p", [Reason]), State}. + build(State, AppInfo) -> ?INFO("Compiling ~s~n", [rebar_app_info:name(AppInfo)]), rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo))), -- cgit v1.1