chore(build): Single source of EMQX_DESCRIPTION

This commit is contained in:
Zaiming Shi 2021-03-09 15:43:44 +01:00
parent d14b90ef2e
commit e1979bf488
6 changed files with 14 additions and 18 deletions

View File

@ -53,11 +53,6 @@ coveralls: $(REBAR)
.PHONY: $(REL_PROFILES) .PHONY: $(REL_PROFILES)
$(REL_PROFILES:%=%): $(REBAR) get-dashboard $(REL_PROFILES:%=%): $(REBAR) get-dashboard
ifneq ($(shell echo $(@) |grep edge),)
@export EMQX_DESC="$${EMQX_DESC} Edge"
else
@export EMQX_DESC="$${EMQX_DESC} Broker"
endif
@$(REBAR) as $(@) release @$(REBAR) as $(@) release
## Not calling rebar3 clean because ## Not calling rebar3 clean because

View File

@ -16,7 +16,7 @@ RUNNER_USER="{{ runner_user }}"
LIB_EKKA_DIR="${RUNNER_LIB_DIR}/ekka-$(grep ekka "${RUNNER_ROOT_DIR}/releases/RELEASES" | awk -F '\"' '{print $2}')" LIB_EKKA_DIR="${RUNNER_LIB_DIR}/ekka-$(grep ekka "${RUNNER_ROOT_DIR}/releases/RELEASES" | awk -F '\"' '{print $2}')"
EMQX_LICENSE_CONF='' EMQX_LICENSE_CONF=''
EMQX_DESCRIPTION="{{ emqx_description }}" export EMQX_DESCRIPTION='{{ emqx_description }}'
## computed vars ## computed vars
REL_NAME="emqx" REL_NAME="emqx"

View File

@ -1,5 +1,6 @@
{application, emqx, {application, emqx,
[{id, "emqx"}, [{id, "emqx"},
{description, "EMQ X"},
{vsn, "4.3.0"}, % strict semver, bump manually! {vsn, "4.3.0"}, % strict semver, bump manually!
{modules, []}, {modules, []},
{registered, []}, {registered, []},

View File

@ -1,6 +0,0 @@
[{application, Name, Opts}] = CONFIG,
Desc = case os:getenv("EMQX_DESC") of
[_ | _] = D -> D;
_ -> "EMQ X test"
end,
[{application, Name, [{description, Desc} | Opts]}].

View File

@ -20,6 +20,7 @@
-export([ start/2 -export([ start/2
, stop/1 , stop/1
, get_description/0
, get_release/0 , get_release/0
]). ]).
@ -59,8 +60,15 @@ print_banner() ->
io:format("Starting ~s on node ~s~n", [?APP, node()]). io:format("Starting ~s on node ~s~n", [?APP, node()]).
print_vsn() -> print_vsn() ->
{ok, Descr} = application:get_key(description), io:format("~s ~s is running now!~n", [get_description(), get_release()]).
io:format("~s ~s is running now!~n", [Descr, get_release()]).
get_description() ->
{ok, Descr0} = application:get_key(?APP, description),
case os:getenv("EMQX_DESCRIPTION") of
false -> Descr0;
"" -> Descr0;
Str -> string:strip(Str, both, $\n)
end.
-ifdef(TEST). -ifdef(TEST).
%% When testing, the 'cover' compiler stripps aways compile info %% When testing, the 'cover' compiler stripps aways compile info

View File

@ -85,13 +85,11 @@ stop() ->
%% @doc Get sys version %% @doc Get sys version
-spec(version() -> string()). -spec(version() -> string()).
version() -> version() -> emqx_app:get_release().
{ok, Version} = application:get_key(?APP, vsn), Version.
%% @doc Get sys description %% @doc Get sys description
-spec(sysdescr() -> string()). -spec(sysdescr() -> string()).
sysdescr() -> sysdescr() -> emqx_app:get_description().
{ok, Descr} = application:get_key(?APP, description), Descr.
%% @doc Get sys uptime %% @doc Get sys uptime
-spec(uptime() -> string()). -spec(uptime() -> string()).