Browse Source

build: add EMQX_ENTERPRISE compile flag

Zaiming (Stone) Shi 4 năm trước cách đây
mục cha
commit
b9e507110c
2 tập tin đã thay đổi với 11 bổ sung9 xóa
  1. 5 5
      apps/emqx/src/emqx_release.erl
  2. 6 4
      rebar.config.erl

+ 5 - 5
apps/emqx/src/emqx_release.erl

@@ -85,8 +85,8 @@ version() ->
             Vsn
     end.
 
-build_vsn() ->
-    case edition() of
-        ee -> ?EMQX_RELEASE_EE;
-        _ -> ?EMQX_RELEASE_CE
-    end.
+-ifdef(EMQX_ENTERPRISE).
+build_vsn() -> ?EMQX_RELEASE_EE.
+-else.
+build_vsn() -> ?EMQX_RELEASE_CE.
+-endif.

+ 6 - 4
rebar.config.erl

@@ -151,15 +151,16 @@ profiles_ce() ->
 
 profiles_ee() ->
     Vsn = get_vsn('emqx-enterprise'),
+    EE = {d, 'EMQX_ENTERPRISE'},
     [ {'emqx-enterprise',
-       [ {erl_opts, prod_compile_opts(Vsn)}
+       [ {erl_opts, [EE | prod_compile_opts(Vsn)]}
        , {relx, relx(Vsn, cloud, bin, ee)}
        , {overrides, prod_overrides()}
        , {project_app_dirs, project_app_dirs(ee)}
        , {post_hooks, [{compile, "bash build emqx-enterprise doc"}]}
        ]}
     , {'emqx-enterprise-pkg',
-       [ {erl_opts, prod_compile_opts(Vsn)}
+       [ {erl_opts, [EE | prod_compile_opts(Vsn)]}
        , {relx, relx(Vsn, cloud, pkg, ee)}
        , {overrides, prod_overrides()}
        , {project_app_dirs, project_app_dirs(ee)}
@@ -170,13 +171,14 @@ profiles_ee() ->
 %% EE has more files than CE, always test/check with EE options.
 profiles_dev() ->
     Vsn = get_vsn('emqx-enterprise'),
+    EE = {d, 'EMQX_ENTERPRISE'},
     [ {check,
-       [ {erl_opts, common_compile_opts(Vsn)}
+       [ {erl_opts, [EE | common_compile_opts(Vsn)]}
        , {project_app_dirs, project_app_dirs(ee)}
        ]}
     , {test,
        [ {deps, test_deps()}
-       , {erl_opts, common_compile_opts(Vsn) ++ erl_opts_i()}
+       , {erl_opts, [EE | common_compile_opts(Vsn) ++ erl_opts_i()]}
        , {extra_src_dirs, [{"test", [{recursive, true}]}]}
        , {project_app_dirs, project_app_dirs(ee)}
        ]}