瀏覽代碼

Merge pull request #165 from tsloughter/project_app_info

update project app list with new appinfo records after build
pull/164/merge
Fred Hebert 10 年之前
父節點
當前提交
f93a70905f
共有 3 個檔案被更改,包括 32 行新增29 行删除
  1. +1
    -0
      src/rebar_otp_app.erl
  2. +8
    -8
      src/rebar_plugins.erl
  3. +23
    -21
      src/rebar_prv_compile.erl

+ 1
- 0
src/rebar_otp_app.erl 查看文件

@ -54,6 +54,7 @@ compile(State, App) ->
validate_app(State2, App1). validate_app(State2, App1).
format_error({file_read, File, Reason}) -> format_error({file_read, File, Reason}) ->
io_lib:format("Failed to read ~s for processing: ~p", [File, Reason]); io_lib:format("Failed to read ~s for processing: ~p", [File, Reason]);
format_error({invalid_name, File, AppName}) -> format_error({invalid_name, File, AppName}) ->

+ 8
- 8
src/rebar_plugins.erl 查看文件

@ -32,14 +32,7 @@ handle_plugin(Plugin, State) ->
Apps = rebar_state:all_deps(State1), Apps = rebar_state:all_deps(State1),
ToBuild = lists:dropwhile(fun rebar_app_info:valid/1, Apps), ToBuild = lists:dropwhile(fun rebar_app_info:valid/1, Apps),
lists:foreach(fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
C = rebar_config:consult(AppDir),
S = rebar_state:new(rebar_state:new(), C, AppDir),
rebar_prv_compile:build(S, AppInfo),
true = code:add_patha(filename:join(AppDir, "ebin"))
end, ToBuild),
[build_plugin(AppInfo) || AppInfo <- ToBuild],
plugin_providers(Plugin) plugin_providers(Plugin)
catch catch
C:T -> C:T ->
@ -48,6 +41,13 @@ handle_plugin(Plugin, State) ->
false false
end. end.
build_plugin(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
C = rebar_config:consult(AppDir),
S = rebar_state:new(rebar_state:new(), C, AppDir),
rebar_prv_compile:compile(S, AppInfo),
true = code:add_patha(filename:join(AppDir, "ebin")).
plugin_providers({Plugin, _, _}) when is_atom(Plugin) -> plugin_providers({Plugin, _, _}) when is_atom(Plugin) ->
validate_plugin(Plugin); validate_plugin(Plugin);
plugin_providers({Plugin, _}) when is_atom(Plugin) -> plugin_providers({Plugin, _}) when is_atom(Plugin) ->

+ 23
- 21
src/rebar_prv_compile.erl 查看文件

@ -6,7 +6,7 @@
do/1, do/1,
format_error/1]). format_error/1]).
-export([build/2]).
-export([compile/2]).
-include("rebar.hrl"). -include("rebar.hrl").
@ -55,34 +55,36 @@ do(State) ->
%% Use the project State for building project apps %% Use the project State for building project apps
%% Set hooks to empty so top-level hooks aren't run for each project app %% Set hooks to empty so top-level hooks aren't run for each project app
State2 = rebar_state:set(rebar_state:set(State1, post_hooks, []), pre_hooks, []), State2 = rebar_state:set(rebar_state:set(State1, post_hooks, []), pre_hooks, []),
build_apps(State2, ProjectApps),
ProjectApps1 = build_apps(State2, ProjectApps),
rebar_hooks:run_compile_hooks(Cwd, post_hooks, compile, State1), rebar_hooks:run_compile_hooks(Cwd, post_hooks, compile, State1),
{ok, State1}.
{ok, rebar_state:project_apps(State1, ProjectApps1)}.
-spec format_error(any()) -> iolist(). -spec format_error(any()) -> iolist().
format_error(Reason) -> format_error(Reason) ->
io_lib:format("~p", [Reason]). io_lib:format("~p", [Reason]).
build_apps(State, Apps) -> build_apps(State, Apps) ->
lists:foreach(fun(AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
AppState ->
AppState
end,
%% Legacy hook support
rebar_hooks:run_compile_hooks(AppDir, pre_hooks, compile, S),
build(S, AppInfo),
rebar_hooks:run_compile_hooks(AppDir, post_hooks, compile, S),
true = code:add_patha(filename:join(AppDir, "ebin"))
end, Apps).
build(State, AppInfo) ->
[build_app(State, AppInfo) || AppInfo <- Apps].
build_app(State, AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
rebar_state:new(State, C, AppDir);
AppState ->
AppState
end,
%% Legacy hook support
rebar_hooks:run_compile_hooks(AppDir, pre_hooks, compile, S),
AppInfo1 = compile(S, AppInfo),
rebar_hooks:run_compile_hooks(AppDir, post_hooks, compile, S),
true = code:add_patha(filename:join(AppDir, "ebin")),
AppInfo1.
compile(State, AppInfo) ->
?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]), ?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]),
rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo))), rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo))),
case rebar_otp_app:compile(State, AppInfo) of case rebar_otp_app:compile(State, AppInfo) of

Loading…
取消
儲存