diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-08-28 21:19:04 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-08-28 21:19:04 -0500 |
commit | 901cea4671864cebc6d7da40e14a004ad2ad8687 (patch) | |
tree | 3f6b0fcdbc264e97947252f3cc11a7dc7bb5a489 | |
parent | e940d6583ab17f1467c4740c9cc206f72b6cc7ce (diff) |
quick and dirty fix for proper dep compilatoin order
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/rebar_app_info.erl | 12 | ||||
-rw-r--r-- | src/rebar_prv_app_builder.erl | 4 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 57 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 3 |
5 files changed, 48 insertions, 30 deletions
diff --git a/rebar.config b/rebar.config index 5e2aa09..3c4e0cf 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,8 @@ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 ft=erlang et +{rebar_packages_url, "http://localhost:8080"}. + %% escript_incl_extra is for internal rebar-private use only. %% Do not use outside rebar. Config interface is not stable. {escript_incl_extra, [{"priv/templates/*", "."}]}. diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index 6831fea..3c38083 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -16,7 +16,9 @@ original_vsn/2, ebin_dir/1, dir/1, - dir/2]). + dir/2, + source/1, + source/2]). -export_type([t/0]). @@ -110,3 +112,11 @@ dir(AppInfo=#app_info_t{}, Dir) -> -spec ebin_dir(t()) -> file:name(). ebin_dir(#app_info_t{dir=Dir}) -> filename:join(Dir, "ebin"). + +-spec source(t(), string()) -> t(). +source(AppInfo=#app_info_t{}, Source) -> + AppInfo#app_info_t{source=Source}. + +-spec source(t()) -> string(). +source(#app_info_t{source=Source}) -> + Source. diff --git a/src/rebar_prv_app_builder.erl b/src/rebar_prv_app_builder.erl index c4502e4..52a6b68 100644 --- a/src/rebar_prv_app_builder.erl +++ b/src/rebar_prv_app_builder.erl @@ -32,8 +32,6 @@ do(State) -> Apps = rebar_state:apps_to_build(State), lists:foreach(fun(AppInfo) -> - ?INFO("Compiling ~s ~s~n", [rebar_app_info:name(AppInfo) - ,rebar_app_info:original_vsn(AppInfo)]), _AppInfo1 = build(State, AppInfo) end, Apps), @@ -41,6 +39,8 @@ do(State) -> {ok, State}. build(State, AppInfo) -> + ?INFO("Compiling ~s ~s~n", [rebar_app_info:name(AppInfo) + ,rebar_app_info:original_vsn(AppInfo)]), rebar_erlc_compiler:compile(State, rebar_app_info:dir(AppInfo)), {ok, AppInfo1} = rebar_otp_app:compile(State, AppInfo), AppInfo1. diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index a01db16..ccfb3b0 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -74,7 +74,7 @@ do(State) -> Deps -> %% Split source deps form binary deps, needed to keep backwards compatibility {SrcDeps, Goals} = parse_deps(Deps), - case update_src_deps(State, SrcDeps, Goals, []) of + case update_src_deps(State, SrcDeps, Goals, [], []) of {State1, SrcDeps1, [], Locked} -> {ok, rebar_state:set(State1, locks, Locked)}; {State1, SrcDeps1, Goals1, Locked} -> @@ -89,14 +89,14 @@ do(State) -> ,FmtVsn ,Link}} end, Solved), - {State2, Deps1, Locked2} = update_deps(State1, M), + {State2, Deps1, _, Locked2} = update_deps(State1, M), State3 = rebar_state:set(State2, locks, Locked++Locked2), {ok, rebar_state:set(State3, goals, Goals1)} end end; Locks -> Locks1 = [new(Lock) || Lock <- Locks], - {State2, _, _} = update_deps(State, Locks1), + {State2, _, _, _} = update_deps(State, Locks1), {ok, State2} end. @@ -148,24 +148,39 @@ update_deps(State, Deps) -> UnbuiltApps = rebar_app_discover:find_unbuilt_apps([DepsDir]), FoundApps = rebar_app_discover:find_apps([DepsDir]), - download_missing_deps(State, DepsDir, FoundApps, Deps). + download_missing_deps(State, DepsDir, UnbuiltApps++FoundApps, Deps). %% Find source deps to build and download -update_src_deps(State, Deps, Goals, Locked) -> +update_src_deps(State, Deps, Goals, SrcApps, Locked) -> DepsDir = get_deps_dir(State), %% Find available apps to fulfill dependencies %% Should only have to do this once, not every iteration - %UnbuiltApps = rebar_app_discover:find_unbuilt_apps([DepsDir]), + UnbuiltApps = rebar_app_discover:find_unbuilt_apps([DepsDir]), FoundApps = rebar_app_discover:find_apps([DepsDir]), %% Resolve deps and their dependencies - {Deps1, NewGoals} = handle_src_deps(Deps, FoundApps, Goals), - case download_missing_deps(State, DepsDir, FoundApps, Deps1) of - {State1, [], []} -> - {State1, Deps1, NewGoals, Locked}; - {State1, Missing, Locked1} -> - update_src_deps(State1, Missing, NewGoals, Locked1++Locked) + {Deps1, NewGoals} = handle_src_deps(Deps, UnbuiltApps++FoundApps, Goals), + case download_missing_deps(State, DepsDir, UnbuiltApps++FoundApps, Deps1) of + {State1, [], SrcApps1, []} -> + Locked1 = lists:map(fun(AppSrc) -> + Source = rebar_app_info:source(AppSrc), + Name = rebar_app_info:name(AppSrc), + C = rebar_config:consult(rebar_app_info:dir(AppSrc)), + S = rebar_state:new(rebar_state:new() + ,C + ,rebar_app_info:dir(AppSrc)), + TargetDir = get_deps_dir(DepsDir, Name), + Ref = rebar_fetch:current_ref(binary_to_list(TargetDir), Source), + AppInfo = rebar_prv_app_builder:build(S, AppSrc), + + {Name + ,ec_cnv:to_binary(rebar_app_info:original_vsn(AppInfo)) + ,erlang:setelement(3, Source, Ref)} + end, SrcApps1++SrcApps), + {State1, Deps1, NewGoals, Locked1++Locked}; + {State1, Missing, SrcApps1, Locked1} -> + update_src_deps(State1, Missing, NewGoals, SrcApps1++SrcApps, Locked1++Locked) end. %% Collect deps of new deps @@ -185,28 +200,20 @@ download_missing_deps(State, DepsDir, Found, Deps) -> Name =:= rebar_app_info:name(F) end, Found) end, Deps), - Locked = lists:map(fun(Dep=#dep{name=Name, source=Source}) -> + {SrcApps, Locked} = lists:foldl(fun(Dep=#dep{name=Name, source=Source}, {SrcAppsAcc, LockedAcc}) -> TargetDir = get_deps_dir(DepsDir, Name), ?INFO("Fetching ~s ~s~n", [Name ,element(2, Source)]), rebar_fetch:download_source(TargetDir, Source), case rebar_app_discover:find_unbuilt_apps([TargetDir]) of [AppSrc] -> - C = rebar_config:consult(rebar_app_info:dir(AppSrc)), - S = rebar_state:new(rebar_state:new() - ,C - ,rebar_app_info:dir(AppSrc)), - AppInfo = rebar_prv_app_builder:build(S, AppSrc), - Ref = rebar_fetch:current_ref(binary_to_list(TargetDir), Source), - {Name - ,ec_cnv:to_binary(rebar_app_info:original_vsn(AppInfo)) - ,erlang:setelement(3, Source, Ref)}; + {[rebar_app_info:source(AppSrc, Source) | SrcAppsAcc], LockedAcc}; [] -> - Source + {SrcAppsAcc, [Source | LockedAcc]} end - end, Missing), + end, {[], []}, Missing), - {State, Missing, Locked}. + {State, Missing, lists:reverse(SrcApps), Locked}. parse_deps(Deps) -> lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, GoalsAcc}) -> diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 042a069..e37c08d 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -51,9 +51,8 @@ do(State) -> {ok, State1}; [] -> - ?INFO("Updating package index...", []), + ?INFO("Updating package index...~n", []), Url = url(State), - io:format("Url ~s~n", [Url]), ec_file:mkdir_p(filename:join([os:getenv("HOME"), ".rebar"])), PackagesFile = filename:join([os:getenv("HOME"), ".rebar", "packages"]), {ok, RequestId} = httpc:request(get, {Url, []}, [], [{stream, PackagesFile}, {sync, false}]), |