diff --git a/Makefile b/Makefile index 146841948..dadc9dd3b 100644 --- a/Makefile +++ b/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 diff --git a/rebar.config.erl b/rebar.config.erl index 1492114a1..2ae7559bd 100644 --- a/rebar.config.erl +++ b/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/"} diff --git a/scripts/get-dashboard.sh b/scripts/get-dashboard.sh index bc28164a5..3e47490b0 100755 --- a/scripts/get-dashboard.sh +++ b/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'