Skip to content

Commit

Permalink
Merge pull request #2237 from ferd/allow-bare-compile-outdir
Browse files Browse the repository at this point in the history
Allow specifying the outdir in bare compiler
  • Loading branch information
tsloughter committed Feb 28, 2020
1 parent 0ba1f04 commit 5f3aec7
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/rebar_prv_bare_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,30 @@

-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
State1 =
rebar_state:add_provider(State,
providers:create([{name, ?PROVIDER},
{module, ?MODULE},
{namespace, ?NAMESPACE},
{bare, false},
{deps, ?DEPS},
{example, ""},
{short_desc, ""},
{desc, ""},
{opts, [{paths, $p, "paths", string, "Wildcard paths of ebin directories to add to code path, separated by a colon"},
{separator, $s, "separator", string, "In case of multiple return paths, the separator character to use to join them."}]}])),
State1 = rebar_state:add_provider(
State,
providers:create([
{name, ?PROVIDER},
{module, ?MODULE},
{namespace, ?NAMESPACE},
{bare, false},
{deps, ?DEPS},
{example, ""},
{short_desc, ""},
{desc, ""},
{opts, [
{paths, $p, "paths", string,
"Wildcard paths of ebin directories to add to code path, "
"separated by a colon"},
{separator, $s, "separator", string,
"In case of multiple return paths, the separator character "
"to use to join them."},
{outdir, $o, "outdir", string,
"Path where build artifacts are located. Defaults to the "
"current directory."}
]}
])
),
{ok, State1}.

-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
Expand All @@ -41,11 +53,12 @@ do(State) ->
{RawOpts, _} = rebar_state:command_parsed_args(State),
Paths = proplists:get_value(paths, RawOpts),
Sep = proplists:get_value(separator, RawOpts, " "),
OutDir = proplists:get_value(outdir, RawOpts, rebar_dir:get_cwd()),
[ code:add_pathsa(filelib:wildcard(PathWildcard))
|| PathWildcard <- rebar_string:lexemes(Paths, Sep) ],

[AppInfo] = rebar_state:project_apps(State),
AppInfo1 = rebar_app_info:out_dir(AppInfo, rebar_dir:get_cwd()),
AppInfo1 = rebar_app_info:out_dir(AppInfo, OutDir),

%% run compile in the default namespace
rebar_prv_compile:compile(rebar_state:namespace(State, default), AppInfo1),
Expand Down

0 comments on commit 5f3aec7

Please sign in to comment.