Bläddra i källkod

build: replace cloud release type with standard and pass it as argument

Ivan Dyachkov 1 år sedan
förälder
incheckning
3386f565aa
4 ändrade filer med 74 tillägg och 61 borttagningar
  1. 19 17
      mix.exs
  2. 51 40
      rebar.config.erl
  3. 3 3
      scripts/check-elixir-applications.exs
  4. 1 1
      scripts/check_missing_reboot_apps.exs

+ 19 - 17
mix.exs

@@ -113,8 +113,9 @@ defmodule EMQXUmbrella.MixProject do
     set_emqx_app_system_env(apps, profile_info, version)
   end
 
-  defp umbrella_apps(profile_info) do
-    enterprise_apps = enterprise_umbrella_apps()
+  defp umbrella_apps(profile_info = %{release_type: release_type}) do
+    enterprise_apps = enterprise_umbrella_apps(release_type)
+    excluded_apps = excluded_apps(release_type)
 
     "apps/*"
     |> Path.wildcard()
@@ -140,10 +141,11 @@ defmodule EMQXUmbrella.MixProject do
           false
       end
     end)
+    |> Enum.reject(fn {app, _} -> app in excluded_apps end)
   end
 
-  defp enterprise_apps(_profile_info = %{edition_type: :enterprise}) do
-    Enum.map(enterprise_umbrella_apps(), fn app_name ->
+  defp enterprise_apps(_profile_info = %{release_type: release_type, edition_type: :enterprise}) do
+    Enum.map(enterprise_umbrella_apps(release_type), fn app_name ->
       path = "apps/#{app_name}"
       {app_name, path: path, manager: :rebar3, override: true}
     end)
@@ -154,7 +156,7 @@ defmodule EMQXUmbrella.MixProject do
   end
 
   # need to remove those when listing `/apps/`...
-  defp enterprise_umbrella_apps() do
+  defp enterprise_umbrella_apps(_release_type) do
     MapSet.new([
       :emqx_bridge_kafka,
       :emqx_bridge_confluent,
@@ -304,7 +306,7 @@ defmodule EMQXUmbrella.MixProject do
           end
 
         [
-          applications: applications(edition_type),
+          applications: applications(release_type, edition_type),
           skip_mode_validation_for: [
             :emqx_mix,
             :emqx_gateway,
@@ -344,7 +346,7 @@ defmodule EMQXUmbrella.MixProject do
     ]
   end
 
-  def applications(edition_type) do
+  def applications(release_type, edition_type) do
     {:ok,
      [
        %{
@@ -365,7 +367,7 @@ defmodule EMQXUmbrella.MixProject do
 
     business_apps = common_business_apps ++ edition_specific_apps
 
-    excluded_apps = excluded_apps()
+    excluded_apps = excluded_apps(release_type)
 
     system_apps =
       Enum.map(system_apps, fn app ->
@@ -380,7 +382,7 @@ defmodule EMQXUmbrella.MixProject do
     |> Keyword.reject(fn {app, _type} -> app in excluded_apps end)
   end
 
-  defp excluded_apps() do
+  defp excluded_apps(_release_type) do
     %{
       mnesia_rocksdb: enable_rocksdb?(),
       quicer: enable_quicer?(),
@@ -451,19 +453,19 @@ defmodule EMQXUmbrella.MixProject do
     } =
       case Mix.env() do
         :dev ->
-          {:cloud, :bin, :community}
+          {:standard, :bin, :community}
 
         :emqx ->
-          {:cloud, :bin, :community}
+          {:standard, :bin, :community}
 
         :"emqx-enterprise" ->
-          {:cloud, :bin, :enterprise}
+          {:standard, :bin, :enterprise}
 
         :"emqx-pkg" ->
-          {:cloud, :pkg, :community}
+          {:standard, :pkg, :community}
 
         :"emqx-enterprise-pkg" ->
-          {:cloud, :pkg, :enterprise}
+          {:standard, :pkg, :enterprise}
       end
 
     normalize_env!()
@@ -566,7 +568,7 @@ defmodule EMQXUmbrella.MixProject do
 
     vm_args_template_path =
       case release_type do
-        :cloud ->
+        _ ->
           "apps/emqx/etc/vm.args.cloud"
       end
 
@@ -780,10 +782,10 @@ defmodule EMQXUmbrella.MixProject do
 
   defp emqx_description(release_type, edition_type) do
     case {release_type, edition_type} do
-      {:cloud, :enterprise} ->
+      {_, :enterprise} ->
         "EMQX Enterprise"
 
-      {:cloud, :community} ->
+      {_, :community} ->
         "EMQX"
     end
   end

+ 51 - 40
rebar.config.erl

@@ -157,17 +157,24 @@ is_rocksdb_supported(_) ->
     not is_build_without("ROCKSDB").
 
 project_app_dirs() ->
-    project_app_dirs(get_edition_from_profile_env()).
+    #{edition := Edition, reltype := RelType} = get_edition_from_profile_env(),
+    project_app_dirs(Edition, RelType).
 
-project_app_dirs(Edition) ->
+project_app_dirs(Edition, RelType) ->
     IsEnterprise = is_enterprise(Edition),
+    ExcludedApps = excluded_apps(RelType),
     UmbrellaApps = [
         Path
      || Path <- filelib:wildcard("apps/*"),
-        is_community_umbrella_app(Path) orelse IsEnterprise
+        not project_app_excluded(Path, ExcludedApps) andalso
+            (is_community_umbrella_app(Path) orelse IsEnterprise)
     ],
     UmbrellaApps.
 
+project_app_excluded("apps/" ++ AppStr, ExcludedApps) ->
+    App = list_to_atom(AppStr),
+    lists:member(App, ExcludedApps).
+
 plugins() ->
     [
         %{relup_helper, {git, "https://github.com/emqx/relup_helper", {tag, "2.1.0"}}},
@@ -196,9 +203,10 @@ test_deps() ->
     ].
 
 common_compile_opts() ->
-    common_compile_opts(get_edition_from_profile_env(), undefined).
+    #{edition := Edition, reltype := RelType} = get_edition_from_profile_env(),
+    common_compile_opts(Edition, RelType, undefined).
 
-common_compile_opts(Edition, Vsn) ->
+common_compile_opts(Edition, _RelType, Vsn) ->
     % always include debug_info
     [
         debug_info,
@@ -224,71 +232,72 @@ warn_profile_env() ->
 get_edition_from_profile_env() ->
     case os:getenv("PROFILE") of
         "emqx-enterprise" ++ _ ->
-            ee;
+            #{edition => ee, reltype => standard};
         "emqx" ++ _ ->
-            ce;
+            #{edition => ce, reltype => standard};
         false ->
-            ee;
+            #{edition => ee, reltype => standard};
         V ->
             io:format(standard_error, "ERROR: bad_PROFILE ~p~n", [V]),
             exit(bad_PROFILE)
     end.
 
-prod_compile_opts(Edition, Vsn) ->
+prod_compile_opts(Edition, RelType, Vsn) ->
     [
         compressed,
         deterministic,
         warnings_as_errors
-        | common_compile_opts(Edition, Vsn)
+        | common_compile_opts(Edition, RelType, Vsn)
     ].
 
 prod_overrides() ->
     [{add, [{erl_opts, [deterministic]}]}].
 
 profiles() ->
-    case get_edition_from_profile_env() of
+    #{edition := Edition, reltype := RelType} = get_edition_from_profile_env(),
+    case Edition of
         ee ->
-            profiles_ee();
+            profiles_ee(RelType);
         ce ->
-            profiles_ce()
-    end ++ profiles_dev().
+            profiles_ce(RelType)
+    end ++ profiles_dev(RelType).
 
-profiles_ce() ->
+profiles_ce(RelType) ->
     Vsn = get_vsn(emqx),
     [
         {'emqx', [
-            {erl_opts, prod_compile_opts(ce, Vsn)},
-            {relx, relx(Vsn, cloud, bin, ce)},
+            {erl_opts, prod_compile_opts(ce, RelType, Vsn)},
+            {relx, relx(Vsn, RelType, bin, ce)},
             {overrides, prod_overrides()},
-            {project_app_dirs, project_app_dirs(ce)}
+            {project_app_dirs, project_app_dirs(ce, RelType)}
         ]},
         {'emqx-pkg', [
-            {erl_opts, prod_compile_opts(ce, Vsn)},
-            {relx, relx(Vsn, cloud, pkg, ce)},
+            {erl_opts, prod_compile_opts(ce, RelType, Vsn)},
+            {relx, relx(Vsn, RelType, pkg, ce)},
             {overrides, prod_overrides()},
-            {project_app_dirs, project_app_dirs(ce)}
+            {project_app_dirs, project_app_dirs(ce, RelType)}
         ]}
     ].
 
-profiles_ee() ->
+profiles_ee(RelType) ->
     Vsn = get_vsn('emqx-enterprise'),
     [
         {'emqx-enterprise', [
-            {erl_opts, prod_compile_opts(ee, Vsn)},
-            {relx, relx(Vsn, cloud, bin, ee)},
+            {erl_opts, prod_compile_opts(ee, RelType, Vsn)},
+            {relx, relx(Vsn, RelType, bin, ee)},
             {overrides, prod_overrides()},
-            {project_app_dirs, project_app_dirs(ee)}
+            {project_app_dirs, project_app_dirs(ee, RelType)}
         ]},
         {'emqx-enterprise-pkg', [
-            {erl_opts, prod_compile_opts(ee, Vsn)},
-            {relx, relx(Vsn, cloud, pkg, ee)},
+            {erl_opts, prod_compile_opts(ee, RelType, Vsn)},
+            {relx, relx(Vsn, RelType, pkg, ee)},
             {overrides, prod_overrides()},
-            {project_app_dirs, project_app_dirs(ee)}
+            {project_app_dirs, project_app_dirs(ee, RelType)}
         ]}
     ].
 
 %% EE has more files than CE, always test/check with EE options.
-profiles_dev() ->
+profiles_dev(_RelType) ->
     [
         {check, [
             {erl_opts, common_compile_opts()},
@@ -302,7 +311,7 @@ profiles_dev() ->
         ]}
     ].
 
-%% RelType: cloud (full size)
+%% RelType: standard
 %% PkgType: bin | pkg
 %% Edition: ce (opensource) | ee (enterprise)
 relx(Vsn, RelType, PkgType, Edition) ->
@@ -341,10 +350,10 @@ relform() ->
         Other -> Other
     end.
 
-emqx_description(cloud, ee) -> "EMQX Enterprise";
-emqx_description(cloud, ce) -> "EMQX".
+emqx_description(_, ee) -> "EMQX Enterprise";
+emqx_description(_, ce) -> "EMQX".
 
-overlay_vars(cloud, PkgType, Edition) ->
+overlay_vars(_RelType, PkgType, Edition) ->
     [
         {emqx_default_erlang_cookie, "emqxsecretcookie"}
     ] ++
@@ -411,15 +420,16 @@ relx_apps(ReleaseType, Edition) ->
             ce -> CEBusinessApps
         end,
     BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
+    ExcludedApps = excluded_apps(ReleaseType),
     Apps =
-        (SystemApps ++
+        ([App || App <- SystemApps, not lists:member(App, ExcludedApps)] ++
             %% EMQX starts the DB and the business applications:
-            [{App, load} || App <- DBApps] ++
+            [{App, load} || App <- DBApps, not lists:member(App, ExcludedApps)] ++
             [emqx_machine] ++
-            [{App, load} || App <- BusinessApps]),
-    lists:foldl(fun proplists:delete/2, Apps, excluded_apps(ReleaseType)).
+            [{App, load} || App <- BusinessApps, not lists:member(App, ExcludedApps)]),
+    Apps.
 
-excluded_apps(_ReleaseType) ->
+excluded_apps(_RelType) ->
     OptionalApps = [
         {quicer, is_quicer_supported()},
         {jq, is_jq_supported()},
@@ -489,7 +499,7 @@ emqx_etc_overlay(ReleaseType) ->
     emqx_etc_overlay_per_rel(ReleaseType) ++
         emqx_etc_overlay().
 
-emqx_etc_overlay_per_rel(cloud) ->
+emqx_etc_overlay_per_rel(_RelType) ->
     [{"{{base_dir}}/lib/emqx/etc/vm.args.cloud", "etc/vm.args"}].
 
 emqx_etc_overlay() ->
@@ -543,10 +553,11 @@ dialyzer(Config) ->
         end,
 
     AppNames = app_names(),
+    ExcludedApps = excluded_apps(standard),
 
     KnownApps = [Name || Name <- AppsToAnalyse, lists:member(Name, AppNames)],
 
-    AppsToExclude = AppNames -- KnownApps,
+    AppsToExclude = ExcludedApps -- KnownApps ++ AppNames,
 
     Extra =
         [system_monitor, tools, covertool] ++

+ 3 - 3
scripts/check-elixir-applications.exs

@@ -22,7 +22,7 @@ defmodule CheckElixirApplications do
       env: [{"DEBUG", "1"}]
     )
 
-    mix_apps = mix_applications(inputs.edition_type)
+    mix_apps = mix_applications(inputs.release_type, inputs.edition_type)
     rebar_apps = rebar_applications(profile)
     results = diff_apps(mix_apps, rebar_apps)
 
@@ -70,8 +70,8 @@ defmodule CheckElixirApplications do
     end
   end
 
-  defp mix_applications(edition_type) do
-    EMQXUmbrella.MixProject.applications(edition_type)
+  defp mix_applications(release_type, edition_type) do
+    EMQXUmbrella.MixProject.applications(release_type, edition_type)
   end
 
   defp rebar_applications(profile) do

+ 1 - 1
scripts/check_missing_reboot_apps.exs

@@ -14,7 +14,7 @@ profile = Mix.env()
 # need to use this information because we might have compiled all
 # applications in the test profile, and thus filter what's in the
 # release lib directory.
-rel_apps = MixProject.applications(inputs.edition_type)
+rel_apps = MixProject.applications(inputs.release_type, inputs.edition_type)
 
 apps =
   rel_apps