summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tunnell-Jones <andrew@tj.id.au>2011-05-26 09:20:45 +0000
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-05-28 15:31:51 +0200
commitaef6c70f598cf4cd1414bf5d4284e536f450a21a (patch)
tree2e588b3a8594ec34ea5af986a99c104e3ba7f90b
parentcb188366ee6e31e332c8b9c9ee64d51521b29876 (diff)
Change arch-specific port_sources to take a list
Change the second parameter of a regex tagged port_source from being a filename or wildcard to being a list of filenames or wildcards. Previously: {"R14", "c_src/*.c"} Now: {"R14", ["c_src/*.c"]} Motivation for change is to avoid repeating regexes.
-rw-r--r--rebar.config.sample7
-rw-r--r--src/rebar_port_compiler.erl12
2 files changed, 11 insertions, 8 deletions
diff --git a/rebar.config.sample b/rebar.config.sample
index aec1b6c..3a62a0a 100644
--- a/rebar.config.sample
+++ b/rebar.config.sample
@@ -35,8 +35,11 @@
%% == Port Compiler ==
-%% List and wildcard list of files to be compiled. Default is `"c_src/*.c"'
-{port_sources, []}.
+%% List of filenames or wildcards to be compiled. May also contain a tuple
+%% consisting of a regular expression to be applied against the system
+%% architecture and a list of filenames or wildcards to include should the
+%% expression pass. Default is `"c_src/*.c"'
+{port_sources, ["c_src/*.c", {"R14", ["c_src/*.c"]}]}.
%% Port compilation environment variables. See rebar_port_compiler.erl for
%% more info. Default is `[]'
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index e442061..a9b73cc 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -38,11 +38,11 @@
%% Supported configuration variables:
%%
-%% * 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.
+%% * port_sources - Erlang list of filenames or wildcards to be compiled. May
+%% also contain a tuple consisting of a regular expression to
+%% be applied against the system architecture and a list of
+%% filenames or wildcards to include should the expression
+%% pass.
%%
%% * so_specs - Erlang list of tuples of the form
%% {"priv/so_name.so", ["c_src/object_file_name.o"]}
@@ -166,7 +166,7 @@ expand_sources([], Acc) ->
expand_sources([{ArchRegex, Spec} | Rest], Acc) ->
case rebar_utils:is_arch(ArchRegex) of
true ->
- Acc2 = filelib:wildcard(Spec) ++ Acc,
+ Acc2 = expand_sources(Spec, Acc),
expand_sources(Rest, Acc2);
false ->
expand_sources(Rest, Acc)