Navigation Menu

Skip to content

Commit

Permalink
Add support for arch specific port_sources
Browse files Browse the repository at this point in the history
On one project I have a need to specify port_sources on R14 only
and on another different project port_sources for Darwin and Linux.
To this end add support to handle tuples of the form
{ArchRegex, PortSource} in the port_sources list, eg:

    {port_sources, [{"R14", ["c_src/*.c"]}]}.
  • Loading branch information
andrewtj authored and Tuncer Ayaz committed Jan 17, 2011
1 parent e66b8c5 commit b52b82c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/rebar_port_compiler.erl
Expand Up @@ -37,7 +37,11 @@

%% Supported configuration variables:
%%
%% * port_sources - Erlang list of files and/or wildcard strings to be compiled
%% * port_sources - Erlang list of files and/or wildcard strings to be
%% compiled. Platform specific sources can be specified
%% by enclosing a string in a tuple of the form
%% {Regex, String} wherein Regex is a regular expression
%% that is checked against the system architecture.
%%
%% * so_specs - Erlang list of tuples of the form {"priv/so_name.so", ["c_src/object_file_name.o"]} useful for
%% building multiple *.so files.
Expand Down Expand Up @@ -136,6 +140,14 @@ clean(Config, AppFile) ->

expand_sources([], Acc) ->
Acc;
expand_sources([{ArchRegex, Spec} | Rest], Acc) ->
case rebar_utils:is_arch(ArchRegex) of
true ->
Acc2 = filelib:wildcard(Spec) ++ Acc,
expand_sources(Rest, Acc2);
false ->
expand_sources(Rest, Acc)
end;
expand_sources([Spec | Rest], Acc) ->
Acc2 = filelib:wildcard(Spec) ++ Acc,
expand_sources(Rest, Acc2).
Expand Down

0 comments on commit b52b82c

Please sign in to comment.