summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-09-01 16:33:32 -0500
committerTristan Sloughter <t@crashfast.com>2014-09-01 18:17:59 -0500
commit8c5f312d909c4335ea2c132c60d6c773eb707e7b (patch)
tree003f19e1ae0de80760701cf2d40d91dbd04ac602 /src
parentb8785e654189f8d41636337c1b8a5c7a6bde22ef (diff)
only build invalid (not built) source deps and project apps
Diffstat (limited to 'src')
-rw-r--r--src/rebar_app_discover.erl97
-rw-r--r--src/rebar_app_info.erl13
-rw-r--r--src/rebar_prv_compile.erl7
-rw-r--r--src/rebar_prv_install_deps.erl20
-rw-r--r--src/rebar_topo.erl12
5 files changed, 84 insertions, 65 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index b256889..19be610 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -3,7 +3,9 @@
-export([do/2,
find_unbuilt_apps/1,
find_apps/1,
- find_apps/2]).
+ find_apps/2,
+ find_app/2,
+ validate_application_info/1]).
do(State, LibDirs) ->
BaseDir = rebar_state:dir(State),
@@ -50,51 +52,54 @@ find_apps(LibDirs) ->
find_apps(LibDirs, Validate) ->
lists:filtermap(fun(AppDir) ->
- AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])),
- AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
- case AppFile of
- [File] ->
- AppInfo = create_app_info(AppDir, File),
- AppInfo1 = rebar_app_info:app_file(AppInfo, File),
- AppInfo2 = case AppSrcFile of
- [F] ->
- rebar_app_info:app_file_src(AppInfo1, F);
- [] ->
- AppInfo1
- end,
- case Validate of
- valid ->
- case validate_application_info(AppInfo2) of
- true ->
- {true, AppInfo2};
- false ->
- false
- end;
- invalid ->
- case validate_application_info(AppInfo2) of
- false ->
- {true, AppInfo2};
- true ->
- false
- end;
- all ->
- {true, AppInfo2}
- end;
- [] ->
- case AppSrcFile of
- [File] ->
- case Validate of
- V when V =:= invalid ; V =:= all ->
- AppInfo = create_app_info(AppDir, File),
- {true, rebar_app_info:app_file_src(AppInfo, File)};
- valid ->
- false
- end;
- [] ->
- false
- end
- end
- end, all_app_dirs(LibDirs)).
+ find_app(AppDir, Validate)
+ end, all_app_dirs(LibDirs)).
+
+find_app(AppDir, Validate) ->
+ AppFile = filelib:wildcard(filename:join([AppDir, "ebin", "*.app"])),
+ AppSrcFile = filelib:wildcard(filename:join([AppDir, "src", "*.app.src"])),
+ case AppFile of
+ [File] ->
+ AppInfo = create_app_info(AppDir, File),
+ AppInfo1 = rebar_app_info:app_file(AppInfo, File),
+ AppInfo2 = case AppSrcFile of
+ [F] ->
+ rebar_app_info:app_file_src(AppInfo1, F);
+ [] ->
+ AppInfo1
+ end,
+ case Validate of
+ valid ->
+ case validate_application_info(AppInfo2) of
+ true ->
+ {true, AppInfo2};
+ false ->
+ false
+ end;
+ invalid ->
+ case validate_application_info(AppInfo2) of
+ false ->
+ {true, AppInfo2};
+ true ->
+ false
+ end;
+ all ->
+ {true, AppInfo2}
+ end;
+ [] ->
+ case AppSrcFile of
+ [File] ->
+ case Validate of
+ V when V =:= invalid ; V =:= all ->
+ AppInfo = create_app_info(AppDir, File),
+ {true, rebar_app_info:app_file_src(AppInfo, File)};
+ valid ->
+ false
+ end;
+ [] ->
+ false
+ end
+ end.
app_dir(AppFile) ->
filename:join(lists:droplast(filename:split(filename:dirname(AppFile)))).
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl
index 8f0cc69..fb2c5f9 100644
--- a/src/rebar_app_info.erl
+++ b/src/rebar_app_info.erl
@@ -5,6 +5,7 @@
new/2,
new/3,
new/4,
+ discover/1,
name/1,
name/2,
config/1,
@@ -82,6 +83,14 @@ new(AppName, Vsn, Dir, Deps) ->
dir=Dir,
deps=Deps}}.
+%% @doc discover a complete version of the app info with all fields set.
+-spec discover(file:name()) ->
+ {ok, t()}.
+discover(Dir) ->
+ {true, AppInfo} = rebar_app_discover:find_app(Dir, all),
+ {ok, AppInfo}.
+
+
-spec name(t()) -> atom().
name(#app_info_t{name=Name}) ->
Name.
@@ -175,8 +184,8 @@ source(#app_info_t{source=Source}) ->
Source.
-spec valid(t()) -> boolean().
-valid(#app_info_t{dir=Dir, valid=undefined}) ->
- true;
+valid(AppInfo=#app_info_t{valid=undefined}) ->
+ rebar_app_discover:validate_application_info(AppInfo);
valid(#app_info_t{valid=Valid}) ->
Valid.
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 6eb2339..4f5d75c 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -29,13 +29,14 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
do(State) ->
- Apps = rebar_state:project_apps(State),
+ ProjectApps = rebar_state:project_apps(State),
+ Deps = rebar_state:get(State, deps_to_build, []),
lists:foreach(fun(AppInfo) ->
C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(AppInfo)),
- _AppInfo1 = build(S, AppInfo)
- end, Apps),
+ build(S, AppInfo)
+ end, Deps++ProjectApps),
rebar_lock:create(State),
{ok, State}.
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 8806f36..4da2dbc 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -138,12 +138,19 @@ handle_deps(State, Deps) ->
end, S)
end,
- FinalDeps = ordsets:union([ordsets:from_list(ProjectApps)
- ,rebar_state:src_deps(State2)
+ Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State2)),
+ AllDeps = ordsets:union([ordsets:from_list(ProjectApps)
+ ,ordsets:to_list(rebar_state:src_deps(State2))
,ordsets:from_list(Solved)]),
+
%% Sort all apps to build order
- {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(FinalDeps)),
- {ok, rebar_state:project_apps(State2, Sort)}.
+ State3 = rebar_state:set(State2, all_deps, AllDeps),
+ {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)),
+ {ok, rebar_state:set(State3, deps_to_build, lists:dropwhile(fun is_valid/1, Sort) -- ProjectApps)}.
+
+-spec is_valid(rebar_app_info:t()) -> boolean().
+is_valid(App) ->
+ rebar_app_info:valid(App).
-spec package_to_app(file:name(), dict:dict(), binary(), binary()) -> rebar_app_info:t().
package_to_app(DepsDir, Packages, Name, Vsn) ->
@@ -205,9 +212,8 @@ parse_deps(DepsDir, Deps) ->
(Name, {SrcDepsAcc, BinaryDepsAcc}) when is_atom(Name) ->
{SrcDepsAcc, [ec_cnv:to_binary(Name) | BinaryDepsAcc]};
({Name, _, Source}, {SrcDepsAcc, BinaryDepsAcc}) ->
- {ok, Dep} = rebar_app_info:new(Name),
- Dep1 = rebar_app_info:source(
- rebar_app_info:dir(Dep, get_deps_dir(DepsDir, Name)), Source),
+ {ok, Dep} = rebar_app_info:discover(get_deps_dir(DepsDir, Name)),
+ Dep1 = rebar_app_info:source(Dep, Source),
{ordsets:add_element(Dep1, SrcDepsAcc), BinaryDepsAcc}
end, {ordsets:new(), []}, Deps).
diff --git a/src/rebar_topo.erl b/src/rebar_topo.erl
index e2a03c6..87ee234 100644
--- a/src/rebar_topo.erl
+++ b/src/rebar_topo.erl
@@ -91,15 +91,13 @@ format_error({cycle, Pairs}) ->
%%====================================================================
-spec names_to_apps([atom()], [rebar_app_info:t()]) -> [rebar_app_info:t()].
names_to_apps(Names, Apps) ->
- [find_app_by_name(Name, Apps) || Name <- Names].
+ [element(2, App) || App <- [find_app_by_name(Name, Apps) || Name <- Names], App =/= error].
--spec find_app_by_name(atom(), [rebar_app_info:t()]) -> rebar_app_info:t().
+-spec find_app_by_name(atom(), [rebar_app_info:t()]) -> {ok, rebar_app_info:t()} | error.
find_app_by_name(Name, Apps) ->
- {ok, App1} =
- ec_lists:find(fun(App) ->
- rebar_app_info:name(App) =:= Name
- end, Apps),
- App1.
+ ec_lists:find(fun(App) ->
+ rebar_app_info:name(App) =:= Name
+ end, Apps).
-spec apps_to_pairs([rebar_app_info:t()]) -> [pair()].
apps_to_pairs(Apps) ->