ソースを参照

Merge pull request #237 from tsloughter/proper_code_path

fix code path update for deps
pull/239/head
Fred Hebert 10年前
コミット
11840e3083
3個のファイルの変更3行の追加38行の削除
  1. +0
    -1
      src/rebar3.erl
  2. +1
    -37
      src/rebar_core.erl
  3. +2
    -0
      src/rebar_prv_install_deps.erl

+ 0
- 1
src/rebar3.erl ファイルの表示

@ -125,7 +125,6 @@ run_aux(State, GlobalPluginProviders, RawArgs) ->
{ok, Providers} = application:get_env(rebar, providers),
{ok, PluginProviders, State4} = rebar_plugins:install(State3),
rebar_core:update_code_path(State4),
%% Providers can modify profiles stored in opts, so set default after initializing providers
AllProviders = Providers++PluginProviders++GlobalPluginProviders,

+ 1
- 37
src/rebar_core.erl ファイルの表示

@ -26,8 +26,7 @@
%% -------------------------------------------------------------------
-module(rebar_core).
-export([process_command/2
,update_code_path/1]).
-export([process_command/2]).
-include("rebar.hrl").
@ -103,38 +102,3 @@ do([ProviderName | Rest], State) ->
{error, Error} ->
{error, Error}
end.
update_code_path(State) ->
true = rebar_utils:expand_code_path(),
LibDirs = rebar_dir:lib_dirs(State),
DepsDir = rebar_dir:deps_dir(State),
PluginsDir = rebar_dir:plugins_dir(State),
_UpdatedCodePaths = update_code_path_(lists:usort([DepsDir, PluginsDir | LibDirs])).
%% ===================================================================
%% Internal functions
%% ===================================================================
update_code_path_(Paths) ->
LibPaths = expand_lib_dirs(Paths, rebar_dir:get_cwd(), []),
ok = code:add_pathsa(LibPaths),
%% track just the paths we added, so we can remove them without
%% removing other paths added by this dep
{added, LibPaths}.
expand_lib_dirs([], _Root, Acc) ->
Acc;
expand_lib_dirs([Dir | Rest], Root, Acc) ->
%% The current dir should only have an ebin dir.
%% Other lib dirs contain app directories, so need the wildcard
Apps = case Dir of
"." ->
[filename:join(Dir, "ebin")];
_ ->
filelib:wildcard(filename:join([Dir, "*", "ebin"]))
end,
FqApps = case filename:pathtype(Dir) of
absolute -> Apps;
_ -> [filename:join([Root, A]) || A <- Apps]
end,
expand_lib_dirs(Rest, Root, Acc ++ FqApps).

+ 2
- 0
src/rebar_prv_install_deps.erl ファイルの表示

@ -146,6 +146,8 @@ handle_deps(Profile, State, Deps, Upgrade, Locks) ->
,lists:ukeysort(2, Solved)),
%% Sort all apps to build order
State3 = rebar_state:all_deps(State2, AllDeps),
CodePaths = [rebar_app_info:ebin_dir(A) || A <- AllDeps],
ok = code:add_pathsa(CodePaths),
{ok, AllDeps, State3}.

読み込み中…
キャンセル
保存