소스 검색

Symlink existing default deps when in new profile

Should fix #360
pull/361/head
Fred Hebert 10 년 전
부모
커밋
18c395ff15
2개의 변경된 파일29개의 추가작업 그리고 8개의 파일을 삭제
  1. +15
    -8
      src/rebar_prv_install_deps.erl
  2. +14
    -0
      test/rebar_install_deps_SUITE.erl

+ 15
- 8
src/rebar_prv_install_deps.erl 파일 보기

@ -395,14 +395,8 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) ->
false ->
case fetch_app(AppInfo, AppDir, State) of
true ->
case needs_symlinking(State, Profile) of
true ->
SymDir = filename:join([rebar_dir:deps_dir(State), rebar_app_info:name(AppInfo)]),
symlink_dep(AppDir, SymDir),
{true, AppInfo};
false ->
{true, AppInfo}
end;
maybe_symlink_default(State, Profile, AppDir, AppInfo),
{true, AppInfo};
Other ->
{Other, AppInfo}
end;
@ -417,6 +411,7 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) ->
%% Preserve the state we created with overrides
AppState = rebar_app_info:state(AppInfo),
AppInfo2 = rebar_app_info:state(AppInfo1, AppState),
maybe_symlink_default(State, Profile, AppDir, AppInfo2),
case sets:is_element(rebar_app_info:name(AppInfo), Seen) of
true ->
{false, AppInfo2};
@ -445,6 +440,18 @@ needs_symlinking(State, Profile) ->
false
end.
maybe_symlink_default(State, Profile, AppDir, AppInfo) ->
case needs_symlinking(State, Profile) of
true ->
SymDir = filename:join([rebar_dir:deps_dir(State),
rebar_app_info:name(AppInfo)]),
symlink_dep(AppDir, SymDir),
true;
false ->
false
end.
symlink_dep(From, To) ->
?INFO("Linking ~s to ~s", [From, To]),
filelib:ensure_dir(To),

+ 14
- 0
test/rebar_install_deps_SUITE.erl 파일 보기

@ -218,6 +218,13 @@ default_profile(Config) ->
|| {dep, App} <- Apps],
[?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs
file:read_file_info(filename:join([BuildDir, "profile", "lib", App])))
|| {dep, App} <- Apps],
%% A second run to another profile also links default to the right spot
rebar_test_utils:run_and_check(
Config, RebarConfig, ["as", "other", "install_deps"], Expect
),
[?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs
file:read_file_info(filename:join([BuildDir, "other", "lib", App])))
|| {dep, App} <- Apps].
nondefault_profile(Config) ->
@ -234,6 +241,13 @@ nondefault_profile(Config) ->
|| {dep, App} <- Apps],
[?assertMatch({ok, #file_info{type=directory}},
file:read_file_info(filename:join([BuildDir, "nondef", "lib", App])))
|| {dep, App} <- Apps],
%% A second run to another profile doesn't link dependencies
rebar_test_utils:run_and_check(
Config, RebarConfig, ["as", "other", "install_deps"], Expect
),
[?assertMatch({error, enoent},
file:read_file_info(filename:join([BuildDir, "default", "lib", App])))
|| {dep, App} <- Apps].

불러오는 중...
취소
저장