Browse Source

simplify dep download and building

pull/3/head
Tristan Sloughter 10 years ago
parent
commit
99136c38b5
5 changed files with 25 additions and 32 deletions
  1. +1
    -1
      src/rebar_core.erl
  2. +2
    -2
      src/rebar_ct.erl
  3. +13
    -15
      src/rebar_prv_app_builder.erl
  4. +7
    -12
      src/rebar_prv_deps.erl
  5. +2
    -2
      src/rebar_prv_update.erl

+ 1
- 1
src/rebar_core.erl View File

@ -39,7 +39,7 @@ process_command(State, Command) ->
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIRS),
_UpdatedCodePaths = update_code_path([DepsDir | LibDirs]),
rebar_deps:setup_env(State),
rebar_prv_deps:setup_env(State),
TargetProviders = rebar_provider:get_target_providers(Command, State),

+ 2
- 2
src/rebar_ct.erl View File

@ -225,7 +225,7 @@ make_cmd(TestDir, RawLogDir, State) ->
%% that are part of the root Erlang install are filtered out to
%% avoid duplication
Apps = rebar_state:apps_to_build(State),
DepsDir = rebar_deps:get_deps_dir(State),
DepsDir = rebar_prv_deps:get_deps_dir(State),
DepsDirEbin = filename:join([DepsDir, "*", "ebin"]),
AppDirs = [filename:join(rebar_app_info:dir(A), "ebin") || A <- Apps],
CodeDirs = [io_lib:format("\"~s\"", [Dir]) || Dir <- [DepsDirEbin | AppDirs]],
@ -311,7 +311,7 @@ get_cover_config(State, Cwd) ->
end.
collect_glob(State, Cwd, Glob) ->
DepsDir = rebar_deps:get_deps_dir(State),
DepsDir = rebar_prv_deps:get_deps_dir(State),
CwdParts = filename:split(Cwd),
filelib:fold_files(Cwd, Glob, true, fun(F, Acc) ->
%% Ignore any specs under the deps/ directory. Do this pulling

+ 13
- 15
src/rebar_prv_app_builder.erl View File

@ -28,15 +28,14 @@ init(State) ->
{ok, State1}.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
do(Config) ->
Apps = rebar_state:apps_to_build(Config),
Config1 =
lists:foldl(fun(AppInfo, ConfigAcc) ->
?INFO("Compiling ~p ~s~n", [rebar_app_info:name(AppInfo)
,rebar_app_info:original_vsn(AppInfo)]),
{_AppInfo1, ConfigAcc1} = build(ConfigAcc, AppInfo),
ConfigAcc1
end, Config, Apps),
do(State) ->
Apps = rebar_state:apps_to_build(State),
lists:foreach(fun(AppInfo) ->
?INFO("Compiling ~p ~s~n", [rebar_app_info:name(AppInfo)
,rebar_app_info:original_vsn(AppInfo)]),
_AppInfo1 = build(State, AppInfo)
end, Apps),
%% DepsDir = get_deps_dir(Config1),
%% LockDeps = lists:map(fun({Name, Vsn, Source}) ->
@ -44,13 +43,12 @@ do(Config) ->
%% rebar_fetch:new(Dir, Name, Vsn, Source)
%% end, rebar_state:deps(Config)),
%% ok = file:write_file("./rebar.lock", io_lib:format("~p.~n", [LockDeps])),
{ok, Config1}.
{ok, State}.
build(Config, AppInfo) ->
{ok, AppInfo1} = rebar_otp_app:compile(Config, AppInfo),
Config1 = rebar_state:apps_to_build(Config, AppInfo1),
rebar_erlc_compiler:compile(Config, rebar_app_info:dir(AppInfo1)),
{AppInfo1, Config1}.
build(State, AppInfo) ->
{ok, AppInfo1} = rebar_otp_app:compile(State, AppInfo),
rebar_erlc_compiler:compile(State, rebar_app_info:dir(AppInfo1)),
AppInfo1.
%% ===================================================================
%% Internal functions

+ 7
- 12
src/rebar_prv_deps.erl View File

@ -144,7 +144,7 @@ download_missing_deps(State, DepsDir, Found, Unbuilt, Deps) ->
to_binary(dep_name(X)) =:= to_binary(rebar_app_info:name(F))
end, Found++Unbuilt)
end, Deps),
lists:foreach(fun({DepName, _DepVsn, DepSource}) ->
ec_plists:map(fun({DepName, _DepVsn, DepSource}) ->
TargetDir = get_deps_dir(DepsDir, DepName),
case filelib:is_dir(TargetDir) of
true ->
@ -152,22 +152,17 @@ download_missing_deps(State, DepsDir, Found, Unbuilt, Deps) ->
false ->
?INFO("Fetching ~s ~s~n", [element(1, DepSource)
,element(2, DepSource)]),
rebar_fetch:download_source(TargetDir, DepSource)
end
end, Missing),
State1 = lists:foldl(fun(X, StateAcc) ->
TargetDir = get_deps_dir(DepsDir, dep_name(X)),
rebar_fetch:download_source(TargetDir, DepSource),
case rebar_app_discover:find_unbuilt_apps([TargetDir]) of
[AppSrc] ->
{_AppInfo1, StateAcc1} = rebar_prv_app_builder:build(StateAcc, AppSrc),
StateAcc1;
_AppInfo1 = rebar_prv_app_builder:build(State, AppSrc);
[] ->
StateAcc
[]
end
end, State, Missing),
end
end, Missing),
{State1, []}.
{State, []}.
%% set REBAR_DEPS_DIR and ERL_LIBS environment variables
setup_env(State) ->

+ 2
- 2
src/rebar_prv_update.erl View File

@ -35,10 +35,10 @@ do(State) ->
[Name] ->
?INFO("Updating ~s~n", [Name]),
DepsDir = rebar_deps:get_deps_dir(State),
DepsDir = rebar_prv_deps:get_deps_dir(State),
Deps = rebar_state:get_local(State, deps, []),
{_, _, Source} = lists:keyfind(list_to_atom(Name), 1, Deps),
TargetDir = rebar_deps:get_deps_dir(DepsDir, Name),
TargetDir = rebar_prv_deps:get_deps_dir(DepsDir, Name),
rebar_fetch:update_source1(TargetDir, Source),
[App] = rebar_app_discover:find_apps([TargetDir]),

Loading…
Cancel
Save