summaryrefslogtreecommitdiff
path: root/src/rebar_port_compiler.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_port_compiler.erl')
-rw-r--r--src/rebar_port_compiler.erl37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 70ee308..0abb044 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -27,8 +27,11 @@
-module(rebar_port_compiler).
-export([compile/2,
- clean/2,
- setup_env/1]).
+ clean/2]).
+
+%% for internal use only
+-export([setup_env/1,
+ info/2]).
-include("rebar.hrl").
@@ -97,7 +100,8 @@ compile(Config, AppFile) ->
[] ->
ok;
Specs ->
- SharedEnv = rebar_config:get_env(Config, ?MODULE),
+ SharedEnv = rebar_config:get_env(Config, rebar_deps) ++
+ rebar_config:get_env(Config, ?MODULE),
%% Compile each of the sources
NewBins = compile_sources(Config, Specs, SharedEnv),
@@ -149,6 +153,27 @@ setup_env(Config) ->
%% Internal functions
%% ===================================================================
+info(help, compile) ->
+ info_help("Build port sources");
+info(help, clean) ->
+ info_help("Delete port build results").
+
+info_help(Description) ->
+ ?CONSOLE(
+ "~s.~n"
+ "~n"
+ "Valid rebar.config options:~n"
+ " ~p~n"
+ " ~p~n",
+ [
+ Description,
+ {port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
+ {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]},
+ {port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
+ {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
+ {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}
+ ]).
+
setup_env(Config, ExtraEnv) ->
%% Extract environment values from the config (if specified) and
%% merge with the default for this operating system. This enables
@@ -399,7 +424,7 @@ expand_vars_loop([], Recurse, Vars, Count) ->
expand_vars_loop(Recurse, [], Vars, Count-1);
expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) ->
%% Identify the variables that need expansion in this value
- ReOpts = [global, {capture, all_but_first, list}],
+ ReOpts = [global, {capture, all_but_first, list}, unicode],
case re:run(V, "\\\${?(\\w+)}?", ReOpts) of
{match, Matches} ->
%% Identify the unique variables that need to be expanded
@@ -472,8 +497,8 @@ erts_dir() ->
lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)]).
os_env() ->
- Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) ||
- S <- os:getenv()],
+ ReOpts = [{return, list}, {parts, 2}, unicode],
+ Os = [list_to_tuple(re:split(S, "=", ReOpts)) || S <- os:getenv()],
%% Drop variables without a name (win32)
[T1 || {K, _V} = T1 <- Os, K =/= []].