mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Deprecate port_envs in favor of port_env
This commit is contained in:
parent
0424d75d78
commit
9d5557b16f
5 changed files with 91 additions and 55 deletions
|
@ -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
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
%% Port compilation environment variables. See rebar_port_compiler.erl for
|
%% Port compilation environment variables. See rebar_port_compiler.erl for
|
||||||
%% more info. Default is `[]'
|
%% more info. Default is `[]'
|
||||||
{port_envs, []}.
|
{port_env, []}.
|
||||||
|
|
||||||
%% port_specs
|
%% port_specs
|
||||||
%% List of filenames or wildcards to be compiled. May also contain a tuple
|
%% List of filenames or wildcards to be compiled. May also contain a tuple
|
||||||
|
|
|
@ -42,47 +42,47 @@
|
||||||
%% {arch_regex(), "priv/foo.so", ["c_src/foo.c"]}
|
%% {arch_regex(), "priv/foo.so", ["c_src/foo.c"]}
|
||||||
%% {"priv/foo", ["c_src/foo.c"]}
|
%% {"priv/foo", ["c_src/foo.c"]}
|
||||||
%%
|
%%
|
||||||
%% * port_envs - Erlang list of key/value pairs which will control
|
%% * port_env - Erlang list of key/value pairs which will control
|
||||||
%% the environment when running the compiler and linker.
|
%% the environment when running the compiler and linker.
|
||||||
%%
|
%%
|
||||||
%% By default, the following variables are defined:
|
%% By default, the following variables are defined:
|
||||||
%% CC - C compiler
|
%% CC - C compiler
|
||||||
%% CXX - C++ compiler
|
%% CXX - C++ compiler
|
||||||
%% CFLAGS - C compiler
|
%% CFLAGS - C compiler
|
||||||
%% CXXFLAGS - C++ compiler
|
%% CXXFLAGS - C++ compiler
|
||||||
%% LDFLAGS - Link flags
|
%% LDFLAGS - Link flags
|
||||||
%% ERL_CFLAGS - default -I paths for erts and ei
|
%% ERL_CFLAGS - default -I paths for erts and ei
|
||||||
%% ERL_LDFLAGS - default -L and -lerl_interface -lei
|
%% ERL_LDFLAGS - default -L and -lerl_interface -lei
|
||||||
%% DRV_CFLAGS - flags that will be used for compiling
|
%% DRV_CFLAGS - flags that will be used for compiling
|
||||||
%% DRV_LDFLAGS - flags that will be used for linking
|
%% DRV_LDFLAGS - flags that will be used for linking
|
||||||
%% EXE_CFLAGS - flags that will be used for compiling
|
%% EXE_CFLAGS - flags that will be used for compiling
|
||||||
%% EXE_LDFLAGS - flags that will be used for linking
|
%% EXE_LDFLAGS - flags that will be used for linking
|
||||||
%% ERL_EI_LIBDIR - ei library directory
|
%% ERL_EI_LIBDIR - ei library directory
|
||||||
%% DRV_CXX_TEMPLATE - C++ command template
|
%% DRV_CXX_TEMPLATE - C++ command template
|
||||||
%% DRV_CC_TEMPLATE - C command template
|
%% DRV_CC_TEMPLATE - C command template
|
||||||
%% DRV_LINK_TEMPLATE - Linker command template
|
%% DRV_LINK_TEMPLATE - Linker command template
|
||||||
%% EXE_CXX_TEMPLATE - C++ command template
|
%% EXE_CXX_TEMPLATE - C++ command template
|
||||||
%% EXE_CC_TEMPLATE - C command template
|
%% EXE_CC_TEMPLATE - C command template
|
||||||
%% EXE_LINK_TEMPLATE - Linker command template
|
%% EXE_LINK_TEMPLATE - Linker command template
|
||||||
%% PORT_IN_FILES - contains a space separated list of input
|
%% PORT_IN_FILES - contains a space separated list of input
|
||||||
%% file(s), (used in command template)
|
%% file(s), (used in command template)
|
||||||
%% PORT_OUT_FILE - contains the output filename (used in
|
%% PORT_OUT_FILE - contains the output filename (used in
|
||||||
%% command template)
|
%% command template)
|
||||||
%%
|
%%
|
||||||
%% Note that if you wish to extend (vs. replace) these variables,
|
%% Note that if you wish to extend (vs. replace) these variables,
|
||||||
%% you MUST include a shell-style reference in your definition.
|
%% you MUST include a shell-style reference in your definition.
|
||||||
%% e.g. to extend CFLAGS, do something like:
|
%% 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
|
%% It is also possible to specify platform specific options
|
||||||
%% by specifying a triplet where the first string is a regex
|
%% by specifying a triplet where the first string is a regex
|
||||||
%% that is checked against Erlang's system architecture string.
|
%% that is checked against Erlang's system architecture string.
|
||||||
%% e.g. to specify a CFLAG that only applies to x86_64 on linux
|
%% e.g. to specify a CFLAG that only applies to x86_64 on linux
|
||||||
%% do:
|
%% do:
|
||||||
%%
|
%%
|
||||||
%% {port_envs, [{"x86_64.*-linux", "CFLAGS",
|
%% {port_env, [{"x86_64.*-linux", "CFLAGS",
|
||||||
%% "$CFLAGS -X86Options"}]}
|
%% "$CFLAGS -X86Options"}]}
|
||||||
%%
|
%%
|
||||||
|
|
||||||
compile(Config, AppFile) ->
|
compile(Config, AppFile) ->
|
||||||
|
@ -152,10 +152,10 @@ setup_env(Config) ->
|
||||||
%% Extract environment values from the config (if specified) and
|
%% Extract environment values from the config (if specified) and
|
||||||
%% merge with the default for this operating system. This enables
|
%% merge with the default for this operating system. This enables
|
||||||
%% max flexibility for users.
|
%% max flexibility for users.
|
||||||
DefaultEnvs = filter_envs(default_env(), []),
|
DefaultEnv = filter_env(default_env(), []),
|
||||||
PortEnvs = port_envs(Config),
|
PortEnv = port_env(Config),
|
||||||
OverrideEnvs = global_defines() ++ filter_envs(PortEnvs, []),
|
OverrideEnv = global_defines() ++ filter_env(PortEnv, []),
|
||||||
RawEnv = apply_defaults(os_env(), DefaultEnvs) ++ OverrideEnvs,
|
RawEnv = apply_defaults(os_env(), DefaultEnv) ++ OverrideEnv,
|
||||||
expand_vars_loop(merge_each_var(RawEnv, [])).
|
expand_vars_loop(merge_each_var(RawEnv, [])).
|
||||||
|
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
@ -381,9 +381,11 @@ is_expandable(InStr) ->
|
||||||
nomatch -> false
|
nomatch -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
port_envs(Config) ->
|
port_env(Config) ->
|
||||||
PortEnvs = rebar_config:get_list(Config, port_envs, []),
|
%% TODO: remove support for deprecated port_envs option
|
||||||
%% TODO: remove migration of deprecated port_envs (DRV_-/EXE_-less vars)
|
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
|
%% when the deprecation grace period ends
|
||||||
WarnAndConvertVar = fun(Var) ->
|
WarnAndConvertVar = fun(Var) ->
|
||||||
New = "DRV_" ++ Var,
|
New = "DRV_" ++ Var,
|
||||||
|
@ -406,23 +408,23 @@ port_envs(Config) ->
|
||||||
({Var, Val}) ->
|
({Var, Val}) ->
|
||||||
{ConvertVar(Var), ReplaceVars(Val)}
|
{ConvertVar(Var), ReplaceVars(Val)}
|
||||||
end,
|
end,
|
||||||
[Convert(Env) || Env <- PortEnvs].
|
[Convert(EnvVar) || EnvVar <- PortEnv].
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Filter a list of env vars such that only those which match the provided
|
%% Filter a list of env vars such that only those which match the provided
|
||||||
%% architecture regex (or do not have a regex) are returned.
|
%% architecture regex (or do not have a regex) are returned.
|
||||||
%%
|
%%
|
||||||
filter_envs([], Acc) ->
|
filter_env([], Acc) ->
|
||||||
lists:reverse(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
|
case rebar_utils:is_arch(ArchRegex) of
|
||||||
true ->
|
true ->
|
||||||
filter_envs(Rest, [{Key, Value} | Acc]);
|
filter_env(Rest, [{Key, Value} | Acc]);
|
||||||
false ->
|
false ->
|
||||||
filter_envs(Rest, Acc)
|
filter_env(Rest, Acc)
|
||||||
end;
|
end;
|
||||||
filter_envs([{Key, Value} | Rest], Acc) ->
|
filter_env([{Key, Value} | Rest], Acc) ->
|
||||||
filter_envs(Rest, [{Key, Value} | Acc]).
|
filter_env(Rest, [{Key, Value} | Acc]).
|
||||||
|
|
||||||
|
|
||||||
erts_dir() ->
|
erts_dir() ->
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
expand_env_variable/3,
|
expand_env_variable/3,
|
||||||
vcs_vsn/2,
|
vcs_vsn/2,
|
||||||
get_deprecated_global/3,
|
get_deprecated_global/3,
|
||||||
|
get_deprecated_list/4, get_deprecated_list/5,
|
||||||
|
get_deprecated_local/4, get_deprecated_local/5,
|
||||||
delayed_halt/1]).
|
delayed_halt/1]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
@ -235,9 +237,12 @@ vcs_vsn_1(Vcs, Dir) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_deprecated_global(OldOpt, NewOpt, When) ->
|
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 ->
|
undefined ->
|
||||||
case rebar_config:get_global(OldOpt, undefined) of
|
case rebar_config:get_global(OldOpt, Default) of
|
||||||
undefined ->
|
undefined ->
|
||||||
undefined;
|
undefined;
|
||||||
Old ->
|
Old ->
|
||||||
|
@ -248,6 +253,21 @@ get_deprecated_global(OldOpt, NewOpt, When) ->
|
||||||
New
|
New
|
||||||
end.
|
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) ->
|
deprecated(Old, New, Opts, When) when is_list(Opts) ->
|
||||||
case lists:member(Old, Opts) of
|
case lists:member(Old, Opts) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -287,6 +307,20 @@ delayed_halt(Code) ->
|
||||||
%% Internal functions
|
%% 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
|
%% We do the shell variable substitution ourselves on Windows and hope that the
|
||||||
%% command doesn't use any other shell magic.
|
%% command doesn't use any other shell magic.
|
||||||
patch_on_windows(Cmd, Env) ->
|
patch_on_windows(Cmd, Env) ->
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
==> rebar (xref)
|
==> 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
|
||||||
|
|
Loading…
Reference in a new issue