浏览代码

Merge pull request #342 from tsloughter/relx_fixes

Mainly CT changes
pull/345/head
Fred Hebert 10 年前
父节点
当前提交
123b0ea61a
共有 6 个文件被更改,包括 46 次插入44 次删除
  1. +1
    -1
      src/rebar_erlc_compiler.erl
  2. +6
    -6
      src/rebar_prv_common_test.erl
  3. +4
    -2
      src/rebar_prv_compile.erl
  4. +17
    -16
      src/rebar_prv_erlydtl_compiler.erl
  5. +17
    -17
      src/rebar_prv_escriptize.erl
  6. +1
    -2
      src/rebar_prv_report.erl

+ 1
- 1
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 ->

+ 6
- 6
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),

+ 4
- 2
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) ->

+ 17
- 16
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) ->

+ 17
- 17
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) ->

+ 1
- 2
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, " ")).

正在加载...
取消
保存