瀏覽代碼

Merge pull request #786 from tsloughter/api_compile

add 'bare compile' provider, for starters for use by mix
pull/789/head
Fred Hebert 9 年之前
父節點
當前提交
d9638f88fb
共有 5 個文件被更改,包括 64 次插入5 次删除
  1. +1
    -0
      src/rebar.app.src
  2. +55
    -0
      src/rebar_prv_bare_compile.erl
  3. +5
    -1
      src/rebar_prv_compile.erl
  4. +1
    -1
      src/rebar_prv_escriptize.erl
  5. +2
    -3
      src/rebar_prv_local_install.erl

+ 1
- 0
src/rebar.app.src 查看文件

@ -36,6 +36,7 @@
{providers, [rebar_prv_app_discovery,
rebar_prv_as,
rebar_prv_bare_compile,
rebar_prv_clean,
rebar_prv_common_test,
rebar_prv_compile,

+ 55
- 0
src/rebar_prv_bare_compile.erl 查看文件

@ -0,0 +1,55 @@
-module(rebar_prv_bare_compile).
-behaviour(provider).
-export([init/1,
do/1,
format_error/1]).
-include_lib("providers/include/providers.hrl").
-include("rebar.hrl").
-define(PROVIDER, compile).
-define(NAMESPACE, bare).
-define(DEPS, [{default, app_discovery}]).
%% ===================================================================
%% Public API
%% ===================================================================
-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 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().
format_error(Reason) ->
io_lib:format("~p", [Reason]).

+ 5
- 1
src/rebar_prv_compile.erl 查看文件

@ -6,7 +6,8 @@
do/1,
format_error/1]).
-export([compile/3]).
-export([compile/2,
compile/3]).
-include_lib("providers/include/providers.hrl").
-include("rebar.hrl").
@ -81,6 +82,9 @@ build_app(State, Providers, AppInfo) ->
copy_app_dirs(AppInfo, AppDir, OutDir),
compile(State, Providers, AppInfo).
compile(State, AppInfo) ->
compile(State, rebar_state:providers(State), AppInfo).
compile(State, Providers, AppInfo) ->
?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]),
AppDir = rebar_app_info:dir(AppInfo),

+ 1
- 1
src/rebar_prv_escriptize.erl 查看文件

@ -107,7 +107,7 @@ escriptize(State0, App) ->
ExtraFiles = usort(InclBeams ++ InclExtra),
Files = get_nonempty(EbinFiles ++ ExtraFiles),
DefaultEmuArgs = ?FMT("%%! -escript main ~s -pa ~s/~s/ebin\n",
DefaultEmuArgs = ?FMT("%%! -escript main ~s -pz ~s/~s/ebin\n",
[AppNameStr, AppNameStr, AppNameStr]),
EscriptSections =
[ {shebang,

+ 2
- 3
src/rebar_prv_local_install.erl 查看文件

@ -58,10 +58,9 @@ format_error(Reason) ->
io_lib:format("~p", [Reason]).
bin_contents(OutputDir) ->
<<"
#!/usr/bin/env sh
<<"#!/usr/bin/env sh
erl -pa ", (ec_cnv:to_binary(OutputDir))/binary,"/*/ebin +sbtu +A0 -noshell -boot start_clean -s rebar3 main -extra \"$@\"
erl -pz ", (ec_cnv:to_binary(OutputDir))/binary,"/*/ebin +sbtu +A0 -noshell -boot start_clean -s rebar3 main -extra \"$@\"
">>.
extract_escript(State, ScriptPath) ->

Loading…
取消
儲存