Просмотр исходного кода

chore(build): use only mark file to tell apart ce ee

Zaiming Shi 4 лет назад
Родитель
Сommit
cd0890796d
3 измененных файлов с 15 добавлено и 5 удалено
  1. 0 1
      Makefile
  2. 14 3
      rebar.config.erl
  3. 1 1
      scripts/get-dashboard.sh

+ 0 - 1
Makefile

@@ -3,7 +3,6 @@ DASHBOARD_VERSION = v4.3.0-beta.1
 REBAR = $(CURDIR)/rebar3
 BUILD = $(CURDIR)/build
 SCRIPTS = $(CURDIR)/scripts
-export EMQX_ENTERPRISE=false
 export PKG_VSN ?= $(shell $(CURDIR)/pkg-vsn.sh)
 
 PROFILE ?= emqx

+ 14 - 3
rebar.config.erl

@@ -22,6 +22,7 @@ overrides() ->
     [ {add, [ {extra_src_dirs, [{"etc", [{recursive,true}]}]}
             , {erl_opts, [ deterministic
                          , {compile_info, [{emqx_vsn, get_vsn()}]}
+                         | [{d, 'EMQX_ENTERPRISE'} || is_enterprise()]
                          ]}
             ]}
     ].
@@ -32,9 +33,11 @@ config() ->
     , {project_app_dirs, project_app_dirs()}
     ].
 
+is_enterprise() ->
+    filelib:is_regular("EMQX_ENTERPRISE").
+
 extra_lib_dir() ->
-    EnterpriseFlag = os:getenv("EMQX_ENTERPRISE"),
-    case EnterpriseFlag =:= "true" orelse EnterpriseFlag =:= "1" of
+    case is_enterprise() of
         true -> "lib-ee";
         false -> "lib-ce"
     end.
@@ -61,6 +64,7 @@ test_deps() ->
 common_compile_opts() ->
     [ deterministic
     , {compile_info, [{emqx_vsn, get_vsn()}]}
+    | [{d, 'EMQX_ENTERPRISE'} || is_enterprise()]
     ].
 
 prod_compile_opts() ->
@@ -180,7 +184,9 @@ relx_plugin_apps(ReleaseType) ->
     , emqx_sasl
     , emqx_telemetry
     , emqx_modules
-    ] ++ relx_plugin_apps_per_rel(ReleaseType).
+    ]
+    ++ relx_plugin_apps_per_rel(ReleaseType)
+    ++ relx_plugin_apps_enterprise(is_enterprise()).
 
 relx_plugin_apps_per_rel(cloud) ->
     [ emqx_lwm2m
@@ -197,6 +203,11 @@ relx_plugin_apps_per_rel(cloud) ->
 relx_plugin_apps_per_rel(edge) ->
     [].
 
+relx_plugin_apps_enterprise(true) ->
+    [list_to_atom(A) || A <- filelib:wildcard("*", "lib-ee"),
+                        filelib:is_dir(filename:join(["lib-ee", A]))];
+relx_plugin_apps_enterprise(false) -> [].
+
 relx_overlay(ReleaseType) ->
     [ {mkdir,"log/"}
     , {mkdir,"data/"}

+ 1 - 1
scripts/get-dashboard.sh

@@ -13,7 +13,7 @@ else
     DOWNLOAD_URL="https://github.com/emqx/emqx-dashboard-frontend/releases/download/${VERSION}/emqx-dashboard.zip"
 fi
 
-if [ "${EMQX_ENTERPRISE:-}" = 'true' ] || [ "${EMQX_ENTERPRISE:-}" == '1' ]; then
+if [ -f 'EMQX_ENTERPRISE' ]; then
     DASHBOARD_PATH='lib-ee/emqx_dashboard/priv'
 else
     DASHBOARD_PATH='lib-ce/emqx_dashboard/priv'