diff --git a/mix.exs b/mix.exs index 350800add..415db4331 100644 --- a/mix.exs +++ b/mix.exs @@ -98,11 +98,12 @@ defmodule EMQXUmbrella.MixProject do # set by hackney (dependency) {:ssl_verify_fun, "1.1.7", override: true}, {:rfc3339, github: "emqx/rfc3339", tag: "0.2.3", override: true}, + {:bcrypt, github: "emqx/erlang-bcrypt", tag: "0.6.1", override: true}, {:uuid, github: "okeuday/uuid", tag: "v2.0.6", override: true}, {:quickrand, github: "okeuday/quickrand", tag: "v2.0.6", override: true} ] ++ emqx_apps(profile_info, version) ++ - enterprise_deps(profile_info) ++ bcrypt_dep() ++ jq_dep() ++ quicer_dep() + enterprise_deps(profile_info) ++ jq_dep() ++ quicer_dep() end defp emqx_apps(profile_info, version) do @@ -374,10 +375,8 @@ defmodule EMQXUmbrella.MixProject do %{ mnesia_rocksdb: enable_rocksdb?(), quicer: enable_quicer?(), - bcrypt: enable_bcrypt?(), jq: enable_jq?(), - observer: is_app?(:observer), - os_mon: enable_os_mon?() + observer: is_app?(:observer) } |> Enum.reject(&elem(&1, 1)) |> Enum.map(&elem(&1, 0)) @@ -786,12 +785,6 @@ defmodule EMQXUmbrella.MixProject do defp emqx_schema_mod(:enterprise), do: :emqx_enterprise_schema defp emqx_schema_mod(:community), do: :emqx_conf_schema - defp bcrypt_dep() do - if enable_bcrypt?(), - do: [{:bcrypt, github: "emqx/erlang-bcrypt", tag: "0.6.1", override: true}], - else: [] - end - defp jq_dep() do if enable_jq?(), do: [{:jq, github: "emqx/jq", tag: "v0.3.12", override: true}], @@ -805,35 +798,25 @@ defmodule EMQXUmbrella.MixProject do else: [] end - defp enable_bcrypt?() do - not win32?() - end - - defp enable_os_mon?() do - not win32?() - end - defp enable_jq?() do not Enum.any?([ - build_without_jq?(), - win32?() - ]) or "1" == System.get_env("BUILD_WITH_JQ") + build_without_jq?() + ]) end defp enable_quicer?() do - not Enum.any?([ - build_without_quic?(), - win32?(), - centos6?(), - macos?() - ]) or "1" == System.get_env("BUILD_WITH_QUIC") + "1" == System.get_env("BUILD_WITH_QUIC") or + not Enum.any?([ + macos?(), + build_without_quic?() + ]) end defp enable_rocksdb?() do not Enum.any?([ - build_without_rocksdb?(), - raspbian?() - ]) or "1" == System.get_env("BUILD_WITH_ROCKSDB") + raspbian?(), + build_without_rocksdb?() + ]) end defp pkg_vsn() do @@ -848,19 +831,6 @@ defmodule EMQXUmbrella.MixProject do String.trim(str) end - defp win32?(), - do: match?({:win_32, _}, :os.type()) - - defp centos6?() do - case File.read("/etc/centos-release") do - {:ok, "CentOS release 6" <> _} -> - true - - _ -> - false - end - end - defp macos?() do {:unix, :darwin} == :os.type() end diff --git a/rebar.config b/rebar.config index d66a1a520..6e5cad59f 100644 --- a/rebar.config +++ b/rebar.config @@ -97,6 +97,7 @@ , {uuid, {git, "https://github.com/okeuday/uuid.git", {tag, "v2.0.6"}}} , {ssl_verify_fun, "1.1.7"} , {rfc3339, {git, "https://github.com/emqx/rfc3339.git", {tag, "0.2.3"}}} + , {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.1"}}} ]}. {xref_ignores, diff --git a/rebar.config.erl b/rebar.config.erl index fc350aa5d..76a1f824b 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -35,9 +35,6 @@ assert_otp() -> ok end. -bcrypt() -> - {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.1"}}}. - quicer() -> {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.308"}}}. @@ -47,8 +44,7 @@ jq() -> deps(Config) -> {deps, OldDeps} = lists:keyfind(deps, 1, Config), MoreDeps = - [bcrypt() || provide_bcrypt_dep()] ++ - [jq() || is_jq_supported()] ++ + [jq() || is_jq_supported()] ++ [quicer() || is_quicer_supported()], lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps}). @@ -121,45 +117,41 @@ is_community_umbrella_app("apps/emqx_gateway_jt808") -> false; is_community_umbrella_app("apps/emqx_bridge_syskeeper") -> false; is_community_umbrella_app(_) -> true. +%% BUILD_WITHOUT_JQ +%% BUILD_WITHOUT_QUIC +%% BUILD_WITHOUT_ROCKSDB +is_build_without(Name) -> + "1" =:= os:getenv("BUILD_WITHOUT_" ++ Name). + +%% BUILD_WITH_QUIC +is_build_with(Name) -> + "1" =:= os:getenv("BUILD_WITH_" ++ Name). + is_jq_supported() -> - not (false =/= os:getenv("BUILD_WITHOUT_JQ") orelse - is_win32()) orelse - "1" == os:getenv("BUILD_WITH_JQ"). + not is_build_without("JQ"). is_quicer_supported() -> - not (false =/= os:getenv("BUILD_WITHOUT_QUIC") orelse - is_macos() orelse - is_win32() orelse is_centos_6()) orelse - "1" == os:getenv("BUILD_WITH_QUIC"). + %% for ones who want to build QUIC on macos + %% export BUILD_WITH_QUIC=1 + is_build_with("QUIC") orelse + is_quicer_supported(os:type()). + +is_quicer_supported({unix, darwin}) -> + %% no quic on macos so far + false; +is_quicer_supported(_) -> + not is_build_without("QUIC"). is_rocksdb_supported() -> - not (false =/= os:getenv("BUILD_WITHOUT_ROCKSDB") orelse - is_raspbian()) orelse - "1" == os:getenv("BUILD_WITH_ROCKSDB"). + %% there is no way one can build rocksdb on raspbian + %% so no need to check is_build_with + Distro = os_cmd("./scripts/get-distro.sh"), + is_rocksdb_supported(Distro). -is_macos() -> - {unix, darwin} =:= os:type(). - -is_centos_6() -> - %% reason: - %% glibc is too old - case file:read_file("/etc/centos-release") of - {ok, <<"CentOS release 6", _/binary>>} -> - true; - _ -> - false - end. - -is_raspbian() -> - case os_cmd("./scripts/get-distro.sh") of - "raspbian" ++ _ -> - true; - _ -> - false - end. - -is_win32() -> - win32 =:= element(1, os:type()). +is_rocksdb_supported("respbian" ++ _) -> + false; +is_rocksdb_supported(_) -> + not is_build_without("ROCKSDB"). project_app_dirs() -> project_app_dirs(get_edition_from_profile_env()). @@ -421,14 +413,12 @@ relx_apps(ReleaseType, Edition) -> [{App, load} || App <- BusinessApps]), lists:foldl(fun proplists:delete/2, Apps, excluded_apps(ReleaseType)). -excluded_apps(ReleaseType) -> +excluded_apps(_ReleaseType) -> OptionalApps = [ {quicer, is_quicer_supported()}, - {bcrypt, provide_bcrypt_release(ReleaseType)}, {jq, is_jq_supported()}, {observer, is_app(observer)}, - {mnesia_rocksdb, is_rocksdb_supported()}, - {os_mon, provide_os_mon_release()} + {mnesia_rocksdb, is_rocksdb_supported()} ], [App || {App, false} <- OptionalApps]. @@ -531,15 +521,6 @@ is_debug(VarName) -> _ -> true end. -provide_bcrypt_dep() -> - not is_win32(). - -provide_os_mon_release() -> - not is_win32(). - -provide_bcrypt_release(ReleaseType) -> - provide_bcrypt_dep() andalso ReleaseType =:= cloud. - erl_opts_i() -> [{i, "apps"}] ++ [{i, Dir} || Dir <- filelib:wildcard(filename:join(["apps", "*", "include"]))]. @@ -562,8 +543,7 @@ dialyzer(Config) -> AppsToExclude = AppNames -- KnownApps, Extra = - [os_mon, system_monitor, tools, covertool] ++ - [bcrypt || provide_bcrypt_dep()] ++ + [system_monitor, tools, covertool] ++ [jq || is_jq_supported()] ++ [quicer || is_quicer_supported()], NewDialyzerConfig =