From 775261dd0b24d74e48f5873ef1ffff56c0c4829a Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 27 Apr 2018 09:32:39 -0400 Subject: 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. --- src/rebar_prv_compile.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 72320fb..1748118 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -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]), -- cgit v1.1 From 0af9aba244dd10d8fdcb8520057cf8a4dcdd90bf Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 27 Apr 2018 10:22:07 -0400 Subject: Fix symlink/copying logic in compiler for priv Priv and include dirs need the virtual symlink in order to preserve hook functionality in some edge cases. --- src/rebar_prv_compile.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/rebar_prv_compile.erl') diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 1748118..0b4fa5f 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -225,7 +225,11 @@ copy_app_dirs(AppInfo, OldAppDir, AppDir) -> end, {SrcDirs, ExtraDirs} = resolve_src_dirs(rebar_app_info:opts(AppInfo)), %% link to src_dirs to be adjacent to ebin is needed for R15 use of cover/xref - [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include"] ++ SrcDirs], + %% priv/ and include/ are symlinked unconditionally to allow hooks + %% to write to them _after_ compilation has taken place when the + %% initial directory did not, and still work + [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include"]], + [symlink_or_copy_existing(OldAppDir, AppDir, Dir) || Dir <- SrcDirs], %% copy all extra_src_dirs as they build into themselves and linking means they %% are shared across profiles [copy(OldAppDir, AppDir, Dir) || Dir <- ExtraDirs]; @@ -236,6 +240,11 @@ 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). + +symlink_or_copy_existing(OldAppDir, AppDir, Dir) -> + Source = filename:join([OldAppDir, Dir]), + Target = filename:join([AppDir, Dir]), case ec_file:is_dir(Source) of true -> rebar_file_utils:symlink_or_copy(Source, Target); false -> ok -- cgit v1.1