diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-04-17 13:45:40 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-04-17 13:45:40 -0400 |
commit | 123b0ea61afd5d1524d0c08b5e8ebcc3b01f0866 (patch) | |
tree | 473bd543a33fc16907e59df950edce0e5f486897 /src | |
parent | cbd22cf49003421214880b252015f331f4346e6e (diff) | |
parent | 400853033e849cff05318a27df1e0f9cd9868a77 (diff) |
Merge pull request #342 from tsloughter/relx_fixes
Mainly CT changes
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_erlc_compiler.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_common_test.erl | 12 | ||||
-rw-r--r-- | src/rebar_prv_compile.erl | 6 | ||||
-rw-r--r-- | src/rebar_prv_erlydtl_compiler.erl | 33 | ||||
-rw-r--r-- | src/rebar_prv_escriptize.erl | 34 | ||||
-rw-r--r-- | src/rebar_prv_report.erl | 3 |
6 files changed, 46 insertions, 44 deletions
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 -> 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), 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) -> 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) -> 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) -> 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, " ")). - |