diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rebar_app_discover.erl | 7 | ||||
| -rw-r--r-- | src/rebar_app_utils.erl | 1 | ||||
| -rw-r--r-- | src/rebar_digraph.erl | 6 | ||||
| -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 | 9 | ||||
| -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 | 
9 files changed, 59 insertions, 48 deletions
| diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index fe930bd..16dcf24 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -164,7 +164,12 @@ create_app_info(AppDir, AppFile) ->              AppInfo1 = rebar_app_info:applications(                           rebar_app_info:app_details(AppInfo, AppDetails),                           IncludedApplications++Applications), -            Valid = rebar_app_utils:validate_application_info(AppInfo1), +            Valid = case rebar_app_utils:validate_application_info(AppInfo1) of +                        true -> +                            true; +                        _ -> +                            false +                    end,              rebar_app_info:dir(rebar_app_info:valid(AppInfo1, Valid), AppDir);          _ ->              error diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 143d73d..3da00be 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -77,7 +77,6 @@ validate_application_info(AppInfo, AppDetail) ->                      ?PRV_ERROR({module_list, AppFile});                  List ->                      has_all_beams(EbinDir, List) -              end      end. diff --git a/src/rebar_digraph.erl b/src/rebar_digraph.erl index 7c1fe90..9e10d49 100644 --- a/src/rebar_digraph.erl +++ b/src/rebar_digraph.erl @@ -13,7 +13,7 @@ compile_order(Apps) ->      Graph = digraph:new(),      lists:foreach(fun(App) ->                            Name = rebar_app_info:name(App), -                          Deps = rebar_app_info:deps(App), +                          Deps = all_apps_deps(App),                            add(Graph, {Name, Deps})                    end, Apps),      case digraph_utils:topsort(Graph) of @@ -123,3 +123,7 @@ find_app_by_name(Name, Apps) ->      ec_lists:find(fun(App) ->                            rebar_app_info:name(App) =:= Name                    end, Apps). + +all_apps_deps(App) -> +    Applications = [atom_to_binary(X, utf8) || X <- rebar_app_info:applications(App)], +    lists:usort(rebar_app_info:deps(App) ++ Applications). 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 a440927..94a1e0b 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -46,11 +46,14 @@ do(State) ->      %% Use the project State for building project apps      %% 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, []), -    ProjectApps1 = build_apps(State2, Providers, ProjectApps), +    {ok, ProjectApps1} = rebar_digraph:compile_order(ProjectApps), -    rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State), +    ProjectApps2 = build_apps(State2, Providers, ProjectApps1), +    State3 = rebar_state:project_apps(State2, ProjectApps2), -    {ok, rebar_state:project_apps(State, ProjectApps1)}. +    rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, State3), + +    {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, " ")). - | 
