Przeglądaj źródła

chore(build): Single source of EMQX_DESCRIPTION

Zaiming Shi 4 lat temu
rodzic
commit
e1979bf488
6 zmienionych plików z 14 dodań i 18 usunięć
  1. 0 5
      Makefile
  2. 1 1
      data/emqx_vars
  3. 1 0
      src/emqx.app.src
  4. 0 6
      src/emqx.app.src.script
  5. 10 2
      src/emqx_app.erl
  6. 2 4
      src/emqx_sys.erl

+ 0 - 5
Makefile

@@ -53,11 +53,6 @@ coveralls: $(REBAR)
 
 .PHONY: $(REL_PROFILES)
 $(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
 
 ## Not calling rebar3 clean because

+ 1 - 1
data/emqx_vars

@@ -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}')"
 
 EMQX_LICENSE_CONF=''
-EMQX_DESCRIPTION="{{ emqx_description }}"
+export EMQX_DESCRIPTION='{{ emqx_description }}'
 
 ## computed vars
 REL_NAME="emqx"

+ 1 - 0
src/emqx.app.src

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

+ 0 - 6
src/emqx.app.src.script

@@ -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]}].

+ 10 - 2
src/emqx_app.erl

@@ -20,6 +20,7 @@
 
 -export([ start/2
         , stop/1
+        , get_description/0
         , get_release/0
         ]).
 
@@ -59,8 +60,15 @@ print_banner() ->
     io:format("Starting ~s on node ~s~n", [?APP, node()]).
 
 print_vsn() ->
-    {ok, Descr} = application:get_key(description),
-    io:format("~s ~s is running now!~n", [Descr, get_release()]).
+    io:format("~s ~s is running now!~n", [get_description(), 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).
 %% When testing, the 'cover' compiler stripps aways compile info

+ 2 - 4
src/emqx_sys.erl

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