Skip to content

Commit

Permalink
Fix symlink/copying logic in compiler for priv
Browse files Browse the repository at this point in the history
Priv and include dirs need the virtual symlink in order to preserve hook
functionality in some edge cases.
  • Loading branch information
ferd committed Apr 27, 2018
1 parent 19d20c5 commit 0af9aba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rebar_prv_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -234,6 +238,11 @@ copy_app_dirs(AppInfo, OldAppDir, AppDir) ->
end.

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
Expand Down

0 comments on commit 0af9aba

Please sign in to comment.