diff options
author | Andrew Tunnell-Jones <andrew@tj.id.au> | 2011-01-10 00:29:22 +0000 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-01-17 16:57:46 +0100 |
commit | b52b82cc29f7fca1b08668b45b7b29ad945614b1 (patch) | |
tree | 546d82fa01f0ee7aee7a9f2af7567f86db3c7744 /src | |
parent | e66b8c5f7d00bb6c3ffa98d3e25f5ef0ca0646b1 (diff) |
Add support for arch specific port_sources
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"]}]}.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_port_compiler.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 3bcbb26..e684042 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -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. @@ -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). |