Skip to content
Browse files

Merge branch 'master' of git://github.com/basho/rebar into basho

  • Loading branch information...
2 parents f50b411 + 9d5557b commit 295da2bd0f3d6648d04c05795b9e9ce74caafeac @gar1t committed Mar 15, 2012
Showing with 93 additions and 56 deletions.
  1. +1 −1 dialyzer_reference
  2. +1 −1 rebar.config.sample
  3. +52 −50 src/rebar_port_compiler.erl
  4. +2 −1 src/rebar_subdirs.erl
  5. +36 −2 src/rebar_utils.erl
  6. +1 −1 xref_reference
View
2 dialyzer_reference
@@ -1,2 +1,2 @@
-rebar_utils.erl:152: Call to missing or unexported function escript:foldl/3
+rebar_utils.erl:154: Call to missing or unexported function escript:foldl/3
View
2 rebar.config.sample
@@ -37,7 +37,7 @@
%% Port compilation environment variables. See rebar_port_compiler.erl for
%% more info. Default is `[]'
-{port_envs, []}.
+{port_env, []}.
%% port_specs
%% List of filenames or wildcards to be compiled. May also contain a tuple
View
102 src/rebar_port_compiler.erl
@@ -42,47 +42,47 @@
%% {arch_regex(), "priv/foo.so", ["c_src/foo.c"]}
%% {"priv/foo", ["c_src/foo.c"]}
%%
-%% * port_envs - Erlang list of key/value pairs which will control
-%% the environment when running the compiler and linker.
+%% * port_env - Erlang list of key/value pairs which will control
+%% the environment when running the compiler and linker.
%%
-%% By default, the following variables are defined:
-%% CC - C compiler
-%% CXX - C++ compiler
-%% CFLAGS - C compiler
-%% CXXFLAGS - C++ compiler
-%% LDFLAGS - Link flags
-%% ERL_CFLAGS - default -I paths for erts and ei
-%% ERL_LDFLAGS - default -L and -lerl_interface -lei
-%% DRV_CFLAGS - flags that will be used for compiling
-%% DRV_LDFLAGS - flags that will be used for linking
-%% EXE_CFLAGS - flags that will be used for compiling
-%% EXE_LDFLAGS - flags that will be used for linking
-%% ERL_EI_LIBDIR - ei library directory
-%% DRV_CXX_TEMPLATE - C++ command template
-%% DRV_CC_TEMPLATE - C command template
-%% DRV_LINK_TEMPLATE - Linker command template
-%% EXE_CXX_TEMPLATE - C++ command template
-%% EXE_CC_TEMPLATE - C command template
-%% EXE_LINK_TEMPLATE - Linker command template
-%% PORT_IN_FILES - contains a space separated list of input
-%% file(s), (used in command template)
-%% PORT_OUT_FILE - contains the output filename (used in
-%% command template)
+%% By default, the following variables are defined:
+%% CC - C compiler
+%% CXX - C++ compiler
+%% CFLAGS - C compiler
+%% CXXFLAGS - C++ compiler
+%% LDFLAGS - Link flags
+%% ERL_CFLAGS - default -I paths for erts and ei
+%% ERL_LDFLAGS - default -L and -lerl_interface -lei
+%% DRV_CFLAGS - flags that will be used for compiling
+%% DRV_LDFLAGS - flags that will be used for linking
+%% EXE_CFLAGS - flags that will be used for compiling
+%% EXE_LDFLAGS - flags that will be used for linking
+%% ERL_EI_LIBDIR - ei library directory
+%% DRV_CXX_TEMPLATE - C++ command template
+%% DRV_CC_TEMPLATE - C command template
+%% DRV_LINK_TEMPLATE - Linker command template
+%% EXE_CXX_TEMPLATE - C++ command template
+%% EXE_CC_TEMPLATE - C command template
+%% EXE_LINK_TEMPLATE - Linker command template
+%% PORT_IN_FILES - contains a space separated list of input
+%% file(s), (used in command template)
+%% PORT_OUT_FILE - contains the output filename (used in
+%% command template)
%%
-%% Note that if you wish to extend (vs. replace) these variables,
-%% you MUST include a shell-style reference in your definition.
-%% e.g. to extend CFLAGS, do something like:
+%% Note that if you wish to extend (vs. replace) these variables,
+%% you MUST include a shell-style reference in your definition.
+%% e.g. to extend CFLAGS, do something like:
%%
-%% {port_envs, [{"CFLAGS", "$CFLAGS -MyOtherOptions"}]}
+%% {port_env, [{"CFLAGS", "$CFLAGS -MyOtherOptions"}]}
%%
-%% It is also possible to specify platform specific options
-%% by specifying a triplet where the first string is a regex
-%% that is checked against Erlang's system architecture string.
-%% e.g. to specify a CFLAG that only applies to x86_64 on linux
-%% do:
+%% It is also possible to specify platform specific options
+%% by specifying a triplet where the first string is a regex
+%% that is checked against Erlang's system architecture string.
+%% e.g. to specify a CFLAG that only applies to x86_64 on linux
+%% do:
%%
-%% {port_envs, [{"x86_64.*-linux", "CFLAGS",
-%% "$CFLAGS -X86Options"}]}
+%% {port_env, [{"x86_64.*-linux", "CFLAGS",
+%% "$CFLAGS -X86Options"}]}
%%
compile(Config, AppFile) ->
@@ -152,10 +152,10 @@ setup_env(Config) ->
%% Extract environment values from the config (if specified) and
%% merge with the default for this operating system. This enables
%% max flexibility for users.
- DefaultEnvs = filter_envs(default_env(), []),
- PortEnvs = port_envs(Config),
- OverrideEnvs = global_defines() ++ filter_envs(PortEnvs, []),
- RawEnv = apply_defaults(os_env(), DefaultEnvs) ++ OverrideEnvs,
+ DefaultEnv = filter_env(default_env(), []),
+ PortEnv = port_env(Config),
+ OverrideEnv = global_defines() ++ filter_env(PortEnv, []),
+ RawEnv = apply_defaults(os_env(), DefaultEnv) ++ OverrideEnv,
expand_vars_loop(merge_each_var(RawEnv, [])).
%% ===================================================================
@@ -381,9 +381,11 @@ is_expandable(InStr) ->
nomatch -> false
end.
-port_envs(Config) ->
- PortEnvs = rebar_config:get_list(Config, port_envs, []),
- %% TODO: remove migration of deprecated port_envs (DRV_-/EXE_-less vars)
+port_env(Config) ->
+ %% TODO: remove support for deprecated port_envs option
+ PortEnv = rebar_utils:get_deprecated_list(Config, port_envs, port_env,
+ [], "soon"),
+ %% TODO: remove migration of deprecated port_env DRV_-/EXE_-less vars
%% when the deprecation grace period ends
WarnAndConvertVar = fun(Var) ->
New = "DRV_" ++ Var,
@@ -406,23 +408,23 @@ port_envs(Config) ->
({Var, Val}) ->
{ConvertVar(Var), ReplaceVars(Val)}
end,
- [Convert(Env) || Env <- PortEnvs].
+ [Convert(EnvVar) || EnvVar <- PortEnv].
%%
%% Filter a list of env vars such that only those which match the provided
%% architecture regex (or do not have a regex) are returned.
%%
-filter_envs([], Acc) ->
+filter_env([], Acc) ->
lists:reverse(Acc);
-filter_envs([{ArchRegex, Key, Value} | Rest], Acc) ->
+filter_env([{ArchRegex, Key, Value} | Rest], Acc) ->
case rebar_utils:is_arch(ArchRegex) of
true ->
- filter_envs(Rest, [{Key, Value} | Acc]);
+ filter_env(Rest, [{Key, Value} | Acc]);
false ->
- filter_envs(Rest, Acc)
+ filter_env(Rest, Acc)
end;
-filter_envs([{Key, Value} | Rest], Acc) ->
- filter_envs(Rest, [{Key, Value} | Acc]).
+filter_env([{Key, Value} | Rest], Acc) ->
+ filter_env(Rest, [{Key, Value} | Acc]).
erts_dir() ->
View
3 src/rebar_subdirs.erl
@@ -38,7 +38,8 @@
preprocess(Config, _) ->
%% Get the list of subdirs specified in the config (if any).
Cwd = rebar_utils:get_cwd(),
- Subdirs0 = rebar_config:get_local(Config, sub_dirs, []),
+ ListSubdirs = rebar_config:get_local(Config, sub_dirs, []),
+ Subdirs0 = lists:flatmap(fun filelib:wildcard/1, ListSubdirs),
case {rebar_core:is_skip_dir(Cwd), Subdirs0} of
{true, []} ->
{ok, []};
View
38 src/rebar_utils.erl
@@ -46,6 +46,8 @@
expand_env_variable/3,
vcs_vsn/2,
get_deprecated_global/3,
+ get_deprecated_list/4, get_deprecated_list/5,
+ get_deprecated_local/4, get_deprecated_local/5,
delayed_halt/1]).
-include("rebar.hrl").
@@ -235,9 +237,12 @@ vcs_vsn_1(Vcs, Dir) ->
end.
get_deprecated_global(OldOpt, NewOpt, When) ->
- case rebar_config:get_global(NewOpt, undefined) of
+ get_deprecated_global(OldOpt, NewOpt, undefined, When).
+
+get_deprecated_global(OldOpt, NewOpt, Default, When) ->
+ case rebar_config:get_global(NewOpt, Default) of
undefined ->
- case rebar_config:get_global(OldOpt, undefined) of
+ case rebar_config:get_global(OldOpt, Default) of
undefined ->
undefined;
Old ->
@@ -248,6 +253,21 @@ get_deprecated_global(OldOpt, NewOpt, When) ->
New
end.
+
+get_deprecated_list(Config, OldOpt, NewOpt, When) ->
+ get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
+
+get_deprecated_list(Config, OldOpt, NewOpt, Default, When) ->
+ get_deprecated_3(fun rebar_config:get_list/3,
+ Config, OldOpt, NewOpt, Default, When).
+
+get_deprecated_local(Config, OldOpt, NewOpt, When) ->
+ get_deprecated_local(Config, OldOpt, NewOpt, undefined, When).
+
+get_deprecated_local(Config, OldOpt, NewOpt, Default, When) ->
+ get_deprecated_3(fun rebar_config:get_local/3,
+ Config, OldOpt, NewOpt, Default, When).
+
deprecated(Old, New, Opts, When) when is_list(Opts) ->
case lists:member(Old, Opts) of
true ->
@@ -287,6 +307,20 @@ delayed_halt(Code) ->
%% Internal functions
%% ====================================================================
+get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
+ case Get(Config, NewOpt, Default) of
+ Default ->
+ case Get(Config, OldOpt, Default) of
+ Default ->
+ Default;
+ Old ->
+ deprecated(OldOpt, NewOpt, When),
+ Old
+ end;
+ New ->
+ New
+ end.
+
%% We do the shell variable substitution ourselves on Windows and hope that the
%% command doesn't use any other shell magic.
patch_on_windows(Cmd, Env) ->
View
2 xref_reference
@@ -1,2 +1,2 @@
==> rebar (xref)
-src/rebar_utils.erl:146: Warning escript_foldl/3 calls undefined function escript:foldl/3
+src/rebar_utils.erl:148: Warning escript_foldl/3 calls undefined function escript:foldl/3

0 comments on commit 295da2b

Please sign in to comment.
Something went wrong with that request. Please try again.