Skip to content

Commit 8347191

Browse files
committed
Expand extra src dirs recursively in manifests
This expands all extra src dirs that have the recursive flag set in a `rebar.config` (Rebar doesn't have any built-in functionality to recursively expand such directories).
1 parent 161b38c commit 8347191

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

apps/rebar/src/rebar_prv_manifest.erl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ adapt_context(App) ->
124124
Dir = rebar_app_info:dir(App),
125125
EbinDir = rebar_app_info:ebin_dir(App),
126126
RebarOpts = rebar_app_info:opts(App),
127-
ExtraSrcDirs = rebar_dir:extra_src_dirs(RebarOpts),
127+
ExtraSrcDirs = extra_src_dirs(Dir, RebarOpts),
128128
Macros = proplists:get_value(macros, DependenciesOpts),
129129
ParseTransforms = proplists:get_value(parse_transforms, DependenciesOpts),
130130
#{name => Name,
@@ -184,3 +184,21 @@ is_json_available() ->
184184
{error, _} ->
185185
false
186186
end.
187+
188+
extra_src_dirs(Root, RebarOpts) ->
189+
Extra = rebar_dir:extra_src_dirs(RebarOpts),
190+
[Dir || E <- Extra, Dir <- expand(Root, E, rebar_dir:recursive(RebarOpts, E))].
191+
192+
expand(_Root, Dir, false) ->
193+
[Dir];
194+
expand(Root, Dir, true) ->
195+
SubDirs = [
196+
relative_to(Root, Path) ||
197+
Path <- filelib:wildcard(filename:join([Root, Dir, "**"])),
198+
filelib:is_dir(Path)
199+
],
200+
[Dir | SubDirs].
201+
202+
relative_to(Root, Path) ->
203+
{ok, Relative} = rebar_file_utils:path_from_ancestor(Path, Root),
204+
Relative.

0 commit comments

Comments
 (0)