From 5f89e9c28d5932cc7a3a7075d4a6eb1136169a7d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 08:32:12 -0500 Subject: fix erlydtl error return and dir to run from --- src/rebar_prv_erlydtl_compiler.erl | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_erlydtl_compiler.erl b/src/rebar_prv_erlydtl_compiler.erl index 65f0094..c5fb77a 100644 --- a/src/rebar_prv_erlydtl_compiler.erl +++ b/src/rebar_prv_erlydtl_compiler.erl @@ -130,20 +130,23 @@ do(State) -> %% We need a project app to store the results under in _build %% If there is more than 1 project app, check for an app config %% if that doesn't exist, error out. - App1 = case rebar_state:project_apps(State) of - [App] -> - App; - Apps -> - case option(app, DtlOpts) of - undefined -> - ?PRV_ERROR(no_main_app); - Name -> - rebar_app_utils:find(Name, Apps) - end - end, + case rebar_state:project_apps(State) of + [App] -> + run_erlydtl(App, DtlOpts, State), + {ok, State}; + Apps -> + case option(app, DtlOpts) of + undefined -> + ?PRV_ERROR(no_main_app); + Name -> + run_erlydtl(rebar_app_utils:find(Name, Apps), DtlOpts, State), + {ok, State} + end + end. - Dir = rebar_app_info:dir(App1), - OutDir = rebar_app_info:ebin_dir(App1), +run_erlydtl(App, DtlOpts, State) -> + Dir = rebar_app_info:dir(App), + OutDir = rebar_app_info:ebin_dir(App), rebar_base_compiler:run(State, [], filename:join(Dir, option(doc_root, DtlOpts)), @@ -154,9 +157,7 @@ do(State) -> compile_dtl(C, S, T, DtlOpts, Dir, OutDir) end, [{check_last_mod, false}, - {recursive, option(recursive, DtlOpts)}]), - - {ok, State}. + {recursive, option(recursive, DtlOpts)}]). -spec format_error(any()) -> iolist(). format_error(no_main_app) -> -- cgit v1.1 From 3126e7eb5561abea4a6674dbb528a550a2869cec Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 08:33:15 -0500 Subject: update project_apps and state before running post hooks --- src/rebar_prv_compile.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 11a01ed..94a1e0b 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -47,11 +47,13 @@ do(State) -> %% Set hooks to empty so top-level hooks aren't run for each project app State2 = rebar_state:set(rebar_state:set(State, post_hooks, []), pre_hooks, []), {ok, ProjectApps1} = rebar_digraph:compile_order(ProjectApps), + ProjectApps2 = build_apps(State2, Providers, ProjectApps1), + State3 = rebar_state:project_apps(State2, ProjectApps2), - rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State), + rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State3), - {ok, rebar_state:project_apps(State, ProjectApps2)}. + {ok, State3}. -spec format_error(any()) -> iolist(). format_error(Reason) -> -- cgit v1.1 From 5999ef1c962c5018b74dac5fdc8c79e7cc390374 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 08:33:41 -0500 Subject: ct: compile tests from test dir to outdir instead of compiling copies --- src/rebar_prv_common_test.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl index c1e263e..1d5806b 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -242,7 +242,7 @@ copy_and_compile_test_suites(State, Opts) -> Dirs = find_suite_dirs(AllSuites), lists:foreach(fun(S) -> NewPath = copy(State, S), - compile_dir(State, NewPath) + compile_dir(State, S, NewPath) end, Dirs), NewSuites = lists:map(fun(S) -> retarget_path(State, S) end, AllSuites), [{suite, NewSuites}|lists:keydelete(suite, 1, Opts)] @@ -254,12 +254,12 @@ copy_and_compile_test_dirs(State, Opts) -> %% dir is a single directory Dir when is_list(Dir), is_integer(hd(Dir)) -> NewPath = copy(State, Dir), - [{dir, compile_dir(State, NewPath)}|lists:keydelete(dir, 1, Opts)]; + [{dir, compile_dir(State, Dir, NewPath)}|lists:keydelete(dir, 1, Opts)]; %% dir is a list of directories Dirs when is_list(Dirs) -> NewDirs = lists:map(fun(Dir) -> NewPath = copy(State, Dir), - compile_dir(State, NewPath) + compile_dir(State, Dir, NewPath) end, Dirs), [{dir, NewDirs}|lists:keydelete(dir, 1, Opts)] end. @@ -294,11 +294,11 @@ copy(State, Target) -> NewTarget end. -compile_dir(State, Dir) -> +compile_dir(State, Dir, OutDir) -> NewState = replace_src_dirs(State, [Dir]), - ok = rebar_erlc_compiler:compile(NewState, rebar_dir:base_dir(State), Dir), + ok = rebar_erlc_compiler:compile(NewState, rebar_dir:base_dir(State), OutDir), ok = maybe_cover_compile(State, Dir), - Dir. + OutDir. retarget_path(State, Path) -> ProjectApps = rebar_state:project_apps(State), -- cgit v1.1 From 2e5b6fe559a3f26e1fb2a1847e730c76db3bf518 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 10:01:06 -0500 Subject: remove use of lists:droplast, it doesn't exist pre-17 --- src/rebar_erlc_compiler.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 792d358..f245eb5 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -549,7 +549,7 @@ warn_and_find_path(File, Dir) -> true -> [SrcHeader]; false -> - IncludeDir = filename:join(filename:join(lists:droplast(filename:split(Dir))), "include"), + IncludeDir = filename:join(filename:join(rebar_utils:droplast(filename:split(Dir))), "include"), IncludeHeader = filename:join(IncludeDir, File), case filelib:is_regular(IncludeHeader) of true -> -- cgit v1.1 From a917dc14dfba8f9aba7c104705cca6bf49c45ce9 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 12:00:58 -0500 Subject: restructure escriptize provider so the error is properly returned --- src/rebar_prv_escriptize.erl | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl index d17699e..12ceaca 100644 --- a/src/rebar_prv_escriptize.erl +++ b/src/rebar_prv_escriptize.erl @@ -62,22 +62,21 @@ desc() -> do(State) -> ?INFO("Building escript...", []), - escriptize(State). - -escriptize(State0) -> - App1 = case rebar_state:project_apps(State0) of - [App] -> - App; - Apps -> - case rebar_state:get(State0, escript_main_app, undefined) of - undefined -> - ?PRV_ERROR(no_main_app); - Name -> - rebar_app_utils:find(Name, Apps) - end - end, - - AppName = rebar_app_info:name(App1), + case rebar_state:project_apps(State) of + [App] -> + escriptize(State, App); + Apps -> + case rebar_state:get(State, escript_main_app, undefined) of + undefined -> + ?PRV_ERROR(no_main_app); + Name -> + AppInfo = rebar_app_utils:find(Name, Apps), + escriptize(State, AppInfo) + end + end. + +escriptize(State0, App) -> + AppName = rebar_app_info:name(App), AppNameStr = ec_cnv:to_list(AppName), %% Get the output filename for the escript -- this may include dirs @@ -152,7 +151,8 @@ get_app_beams([App | Rest], Acc) -> Path -> Prefix = filename:join(atom_to_list(App), "ebin"), Acc2 = load_files(Prefix, "*.beam", Path), - get_app_beams(Rest, Acc2 ++ Acc) + Acc3 = load_files(Prefix, "*.app", Path), + get_app_beams(Rest, Acc3 ++ Acc2 ++ Acc) end. get_extra(State) -> -- cgit v1.1 From 400853033e849cff05318a27df1e0f9cd9868a77 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 17 Apr 2015 12:01:16 -0500 Subject: replcae ensure_started bc it doens't exist in R15, with load --- src/rebar_prv_report.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_report.erl b/src/rebar_prv_report.erl index 45bc0b0..e052998 100644 --- a/src/rebar_prv_report.erl +++ b/src/rebar_prv_report.erl @@ -43,7 +43,7 @@ do(State) -> %% Show app versions (including rebar3) {ok, Vsn} = application:get_key(rebar, vsn), {ok, Apps} = application:get_key(rebar, applications), - [application:ensure_started(App) || App <- Apps], + [application:load(App) || App <- Apps], Vsns = [io_lib:format("~p: ~s~n", [App, AVsn]) || App <- lists:sort(Apps), {ok, AVsn} <- [application:get_key(App, vsn)]], @@ -101,4 +101,3 @@ time_to_string({{Y,M,D},{H,Min,S}}) -> parse_task(Str) -> hd(re:split(Str, " ")). - -- cgit v1.1