diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-09-11 22:41:45 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-09-14 20:00:39 -0500 |
commit | 665bdf6bdb02fe5279e8a8b05b72cd4519c757bc (patch) | |
tree | 99abf247a1a835bf990c4da54afa558e2f46827a | |
parent | 9dfec19c67fc72f9ff9abbef95bcfd74a4471056 (diff) |
add --paths option to bare compile provider
-rw-r--r-- | src/rebar_prv_bare_compile.erl | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/rebar_prv_bare_compile.erl b/src/rebar_prv_bare_compile.erl index 911c5c5..201620a 100644 --- a/src/rebar_prv_bare_compile.erl +++ b/src/rebar_prv_bare_compile.erl @@ -19,22 +19,35 @@ -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, []}])), + 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 path of ebin directories to add to code path"}]}])), {ok, State1}. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> + OrigPath = code:get_path(), + + %% Add code paths from --paths to the beginning of the code path + {RawOpts, _} = rebar_state:command_parsed_args(State), + Paths = proplists:get_value(paths, RawOpts), + CodePaths = filelib:wildcard(Paths), + code:add_pathsa(CodePaths), + [AppInfo] = rebar_state:project_apps(State), AppInfo1 = rebar_app_info:out_dir(AppInfo, rebar_dir:get_cwd()), rebar_prv_compile:compile(State, AppInfo1), + + rebar_utils:cleanup_code_path(OrigPath), + {ok, State}. -spec format_error(any()) -> iolist(). |