Browse Source

Prevent copying or symlink non-existing src_dirs

This would cause crashes on linux and force people to have a src_dirs
config that is strictly matching what is on the file system rather than
acting as a specification of those that are valid.

To compare, if lib_dirs worked the same, then any repo that did not both
have apps/ and lib/ would crash, as the spec mentions both options as
valid.
pull/1770/head
Fred Hebert 7 years ago
parent
commit
775261dd0b
2 changed files with 4 additions and 4 deletions
  1. +4
    -1
      src/rebar_prv_compile.erl
  2. +0
    -3
      test/rebar_dir_SUITE.erl

+ 4
- 1
src/rebar_prv_compile.erl View File

@ -236,7 +236,10 @@ copy_app_dirs(AppInfo, OldAppDir, AppDir) ->
symlink_or_copy(OldAppDir, AppDir, Dir) ->
Source = filename:join([OldAppDir, Dir]),
Target = filename:join([AppDir, Dir]),
rebar_file_utils:symlink_or_copy(Source, Target).
case ec_file:is_dir(Source) of
true -> rebar_file_utils:symlink_or_copy(Source, Target);
false -> ok
end.
copy(OldAppDir, AppDir, Dir) ->
Source = filename:join([OldAppDir, Dir]),

+ 0
- 3
test/rebar_dir_SUITE.erl View File

@ -79,13 +79,10 @@ alt_src_dir_nested(Config) ->
RebarConfig = [{src_dirs, ["src", "alt/nested"]}],
AppsDir = ?config(apps, Config),
Name1 = ?config(app_one, Config),
Name2 = ?config(app_two, Config),
ModDir = filename:join([AppsDir, "apps", Name1, "alt", "nested"]),
ModDir2 = filename:join([AppsDir, "apps", Name2, "alt", "nested"]),
Mod = "-module(altmod). -export([main/0]). main() -> ok.",
ec_file:mkdir_path(ModDir),
ec_file:mkdir_path(ModDir2),
ok = file:write_file(filename:join([ModDir, "altmod.erl"]), Mod),
Ebin = filename:join([AppsDir, "_build", "default", "lib", Name1, "ebin", "altmod.beam"]),

Loading…
Cancel
Save