build: pass build profile as environment variable
This commit is contained in:
parent
4949fb222e
commit
c93829c784
11
build
11
build
|
@ -14,9 +14,18 @@ if [ "$DEBUG" -eq 1 ]; then
|
|||
set -x
|
||||
fi
|
||||
|
||||
PROFILE="$1"
|
||||
PROFILE_ARG="$1"
|
||||
ARTIFACT="$2"
|
||||
|
||||
if [[ "${PROFILE:-${PROFILE_ARG}}" != "$PROFILE_ARG" ]]; then
|
||||
echo "PROFILE env var is set to '$PROFILE', but '$0' arg1 is '$1'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure PROFILE is exported, it is needed by rebar.config.erl
|
||||
PROFILE=$PROFILE_ARG
|
||||
export PROFILE
|
||||
|
||||
# ensure dir
|
||||
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
do(Dir, CONFIG) ->
|
||||
ok = assert_otp(),
|
||||
ok = warn_profile_env(),
|
||||
case iolist_to_binary(Dir) of
|
||||
<<".">> ->
|
||||
C1 = deps(CONFIG),
|
||||
|
@ -117,6 +118,9 @@ is_raspbian() ->
|
|||
is_win32() ->
|
||||
win32 =:= element(1, os:type()).
|
||||
|
||||
project_app_dirs() ->
|
||||
project_app_dirs(get_edition_from_profille_env()).
|
||||
|
||||
project_app_dirs(Edition) ->
|
||||
["apps/*"] ++
|
||||
case is_enterprise(Edition) of
|
||||
|
@ -149,6 +153,9 @@ test_deps() ->
|
|||
{er_coap_client, {git, "https://github.com/emqx/er_coap_client", {tag, "v1.0.5"}}}
|
||||
].
|
||||
|
||||
common_compile_opts(Vsn) ->
|
||||
common_compile_opts(get_edition_from_profille_env(), Vsn).
|
||||
|
||||
common_compile_opts(Edition, Vsn) ->
|
||||
% always include debug_info
|
||||
[
|
||||
|
@ -159,6 +166,32 @@ common_compile_opts(Edition, Vsn) ->
|
|||
[{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"] ++
|
||||
[{d, 'BUILD_WITHOUT_QUIC'} || not is_quicer_supported()].
|
||||
|
||||
warn_profile_env() ->
|
||||
case os:getenv("PROFILE") of
|
||||
false ->
|
||||
io:format(
|
||||
standard_error,
|
||||
"WARN: environment variable PROFILE is not set, using 'emqx-enterprise'~n",
|
||||
[]
|
||||
);
|
||||
_ ->
|
||||
ok
|
||||
end.
|
||||
|
||||
%% this function is only used for test/check profiles
|
||||
get_edition_from_profille_env() ->
|
||||
case os:getenv("PROFILE") of
|
||||
"emqx" ->
|
||||
ce;
|
||||
"emqx-enterprise" ->
|
||||
ee;
|
||||
false ->
|
||||
ee;
|
||||
V ->
|
||||
io:format(standard_error, "ERROR: bad_PROFILE ~p~n", [V]),
|
||||
exit(bad_PROFILE)
|
||||
end.
|
||||
|
||||
prod_compile_opts(Edition, Vsn) ->
|
||||
[
|
||||
compressed,
|
||||
|
@ -212,14 +245,14 @@ profiles_dev() ->
|
|||
Vsn = get_vsn('emqx-enterprise'),
|
||||
[
|
||||
{check, [
|
||||
{erl_opts, common_compile_opts(ee, Vsn)},
|
||||
{project_app_dirs, project_app_dirs(ee)}
|
||||
{erl_opts, common_compile_opts(Vsn)},
|
||||
{project_app_dirs, project_app_dirs()}
|
||||
]},
|
||||
{test, [
|
||||
{deps, test_deps()},
|
||||
{erl_opts, common_compile_opts(ee, Vsn) ++ erl_opts_i()},
|
||||
{erl_opts, common_compile_opts(Vsn) ++ erl_opts_i()},
|
||||
{extra_src_dirs, [{"test", [{recursive, true}]}]},
|
||||
{project_app_dirs, project_app_dirs(ee)}
|
||||
{project_app_dirs, project_app_dirs()}
|
||||
]}
|
||||
].
|
||||
|
||||
|
|
Loading…
Reference in New Issue