summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-04-27 11:10:35 -0400
committerGitHub <noreply@github.com>2018-04-27 11:10:35 -0400
commita908284b112ff77dbf0ae9b9f946bc7b739faf29 (patch)
treef40b11f47c1d57cd9614582d36b89b6f423227e4 /src/rebar_prv_compile.erl
parentd3efb4708cd2303b506988c71ee3671a743b1da2 (diff)
parent0af9aba244dd10d8fdcb8520057cf8a4dcdd90bf (diff)
Merge pull request #1770 from ferd/danikp-feature_long_src_paths
ensure dest exists before copying to it and fix src_dirs symlinking
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r--src/rebar_prv_compile.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 72320fb..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];
@@ -238,6 +242,14 @@ symlink_or_copy(OldAppDir, AppDir, 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
+ end.
+
copy(OldAppDir, AppDir, Dir) ->
Source = filename:join([OldAppDir, Dir]),
Target = filename:join([AppDir, Dir]),