From 98752aab9390137d7cba0b70e0c1c08b9ca308d4 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Wed, 26 Aug 2015 22:13:04 -0500 Subject: wip: move state into app_info --- src/rebar_prv_compile.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 74be7a6..072255d 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -52,7 +52,7 @@ do(State) -> {ok, ProjectApps1} = rebar_digraph:compile_order(ProjectApps), %% Run top level hooks *before* project apps compiled but *after* deps are - rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, State), + rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, element(2,rebar_app_info:new(noen)), State), ProjectApps2 = build_apps(State, Providers, ProjectApps1), State2 = rebar_state:project_apps(State, ProjectApps2), @@ -60,7 +60,7 @@ do(State) -> ProjAppsPaths = [filename:join(rebar_app_info:out_dir(X), "ebin") || X <- ProjectApps2], State3 = rebar_state:code_paths(State2, all_deps, DepsPaths ++ ProjAppsPaths), - rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State2), + rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, element(2,rebar_app_info:new(noen)), State2), has_all_artifacts(State3), rebar_utils:cleanup_code_path(rebar_state:code_paths(State3, default) @@ -80,7 +80,7 @@ build_apps(State, Providers, Apps) -> build_app(State, Providers, AppInfo) -> AppDir = rebar_app_info:dir(AppInfo), OutDir = rebar_app_info:out_dir(AppInfo), - copy_app_dirs(State, AppDir, OutDir), + copy_app_dirs(AppInfo, AppDir, OutDir), S = rebar_app_info:state_or_new(State, AppInfo), S1 = rebar_state:all_deps(S, rebar_state:all_deps(State)), @@ -89,12 +89,12 @@ build_app(State, Providers, AppInfo) -> compile(State, Providers, AppInfo) -> ?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]), AppDir = rebar_app_info:dir(AppInfo), - rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, State), + rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), - rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:out_dir(AppInfo))), + rebar_erlc_compiler:compile(AppInfo), case rebar_otp_app:compile(State, AppInfo) of {ok, AppInfo1} -> - rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, State), + rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo, State), has_all_artifacts(State), AppInfo1; Error -> @@ -113,7 +113,7 @@ has_all_artifacts(State) -> true end. -copy_app_dirs(State, OldAppDir, AppDir) -> +copy_app_dirs(AppInfo, OldAppDir, AppDir) -> case ec_cnv:to_binary(filename:absname(OldAppDir)) =/= ec_cnv:to_binary(filename:absname(AppDir)) of true -> @@ -142,7 +142,7 @@ copy_app_dirs(State, OldAppDir, AppDir) -> end, %% link to src_dirs to be adjacent to ebin is needed for R15 use of cover/xref - SrcDirs = rebar_dir:all_src_dirs(State, ["src"], []), + SrcDirs = rebar_dir:all_src_dirs(rebar_app_info:opts(AppInfo), ["src"], []), [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include"] ++ SrcDirs]; false -> ok -- cgit v1.1 From f209ccc2b8ea79279532f1fe1debe24aa0e6a488 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 29 Aug 2015 17:07:18 -0500 Subject: remove state record from app_info record --- src/rebar_prv_compile.erl | 4 ++-- 1 file changed, 2 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 072255d..1675a41 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -82,8 +82,8 @@ build_app(State, Providers, AppInfo) -> OutDir = rebar_app_info:out_dir(AppInfo), copy_app_dirs(AppInfo, AppDir, OutDir), - S = rebar_app_info:state_or_new(State, AppInfo), - S1 = rebar_state:all_deps(S, rebar_state:all_deps(State)), + %S = rebar_app_info:state_or_new(State, AppInfo), + S1 = rebar_state:all_deps(State, rebar_state:all_deps(State)), compile(S1, Providers, AppInfo). compile(State, Providers, AppInfo) -> -- cgit v1.1 From 8e25a45cbbc3ba796e3cb4331c15a2914fa0e644 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 30 Aug 2015 13:39:38 -0500 Subject: update use of hooks and plugins with state in app_info --- src/rebar_prv_compile.erl | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 1675a41..547f5d3 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -45,14 +45,14 @@ do(State) -> %% Need to allow global config vars used on deps. %% Right now no way to differeniate and just give deps a new state. %% But need an account of "all deps" for some hooks to use. - EmptyState = rebar_state:new(), - build_apps(rebar_state:all_deps(EmptyState, - rebar_state:all_deps(State)), Providers, Deps), - + %% EmptyState = rebar_state:new(), + %% build_apps(rebar_state:all_deps(EmptyState, + %% rebar_state:all_deps(State)), Providers, Deps), + build_apps(State, Providers, Deps), {ok, ProjectApps1} = rebar_digraph:compile_order(ProjectApps), %% Run top level hooks *before* project apps compiled but *after* deps are - rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, element(2,rebar_app_info:new(noen)), State), + rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, State), ProjectApps2 = build_apps(State, Providers, ProjectApps1), State2 = rebar_state:project_apps(State, ProjectApps2), @@ -60,9 +60,13 @@ do(State) -> ProjAppsPaths = [filename:join(rebar_app_info:out_dir(X), "ebin") || X <- ProjectApps2], State3 = rebar_state:code_paths(State2, all_deps, DepsPaths ++ ProjAppsPaths), - rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, element(2,rebar_app_info:new(noen)), State2), - has_all_artifacts(State3), - + rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State2), + case rebar_state:has_all_artifacts(State3) of + {false, File} -> + throw(?PRV_ERROR({missing_artifact, File})); + true -> + true + end, rebar_utils:cleanup_code_path(rebar_state:code_paths(State3, default) ++ rebar_state:code_paths(State, all_plugin_deps)), @@ -83,8 +87,8 @@ build_app(State, Providers, AppInfo) -> copy_app_dirs(AppInfo, AppDir, OutDir), %S = rebar_app_info:state_or_new(State, AppInfo), - S1 = rebar_state:all_deps(State, rebar_state:all_deps(State)), - compile(S1, Providers, AppInfo). + %S1 = rebar_state:all_deps(State, rebar_state:all_deps(State)), + compile(State, Providers, AppInfo). compile(State, Providers, AppInfo) -> ?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]), @@ -95,7 +99,7 @@ compile(State, Providers, AppInfo) -> case rebar_otp_app:compile(State, AppInfo) of {ok, AppInfo1} -> rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo, State), - has_all_artifacts(State), + has_all_artifacts(AppInfo1), AppInfo1; Error -> throw(Error) @@ -105,8 +109,8 @@ compile(State, Providers, AppInfo) -> %% Internal functions %% =================================================================== -has_all_artifacts(State) -> - case rebar_state:has_all_artifacts(State) of +has_all_artifacts(AppInfo1) -> + case rebar_app_info:has_all_artifacts(AppInfo1) of {false, File} -> throw(?PRV_ERROR({missing_artifact, File})); true -> -- cgit v1.1 From e6f6ccc7570ad57f6d1416b3f8c59551b7aaa5c6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 31 Aug 2015 21:40:33 -0500 Subject: more cleanup --- src/rebar_prv_compile.erl | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 547f5d3..56e5e84 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -42,12 +42,6 @@ do(State) -> Deps = rebar_state:deps_to_build(State), Cwd = rebar_state:dir(State), - %% Need to allow global config vars used on deps. - %% Right now no way to differeniate and just give deps a new state. - %% But need an account of "all deps" for some hooks to use. - %% EmptyState = rebar_state:new(), - %% build_apps(rebar_state:all_deps(EmptyState, - %% rebar_state:all_deps(State)), Providers, Deps), build_apps(State, Providers, Deps), {ok, ProjectApps1} = rebar_digraph:compile_order(ProjectApps), @@ -85,9 +79,6 @@ build_app(State, Providers, AppInfo) -> AppDir = rebar_app_info:dir(AppInfo), OutDir = rebar_app_info:out_dir(AppInfo), copy_app_dirs(AppInfo, AppDir, OutDir), - - %S = rebar_app_info:state_or_new(State, AppInfo), - %S1 = rebar_state:all_deps(State, rebar_state:all_deps(State)), compile(State, Providers, AppInfo). compile(State, Providers, AppInfo) -> -- cgit v1.1