chore(mix): fix mix builds
This commit is contained in:
parent
d5ea435e86
commit
39f22585d0
1
Makefile
1
Makefile
|
@ -152,6 +152,7 @@ $(PROFILES:%=clean-%):
|
||||||
.PHONY: clean-all
|
.PHONY: clean-all
|
||||||
clean-all:
|
clean-all:
|
||||||
@rm -f rebar.lock
|
@rm -f rebar.lock
|
||||||
|
@rm -rf deps
|
||||||
@rm -rf _build
|
@rm -rf _build
|
||||||
|
|
||||||
.PHONY: deps-all
|
.PHONY: deps-all
|
||||||
|
|
|
@ -59,4 +59,12 @@
|
||||||
{statistics, true}
|
{statistics, true}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{project_plugins, [erlfmt]}.
|
{project_plugins, [
|
||||||
|
{erlfmt, [
|
||||||
|
{files, [
|
||||||
|
"{src,include,test}/*.{hrl,erl,app.src}",
|
||||||
|
"rebar.config",
|
||||||
|
"rebar.config.script"
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
]}.
|
||||||
|
|
|
@ -27,17 +27,17 @@ Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.
|
||||||
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.113"}}}.
|
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.113"}}}.
|
||||||
|
|
||||||
Dialyzer = fun(Config) ->
|
Dialyzer = fun(Config) ->
|
||||||
{dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config),
|
{dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config),
|
||||||
{plt_extra_apps, OldExtra} = lists:keyfind(plt_extra_apps, 1, OldDialyzerConfig),
|
{plt_extra_apps, OldExtra} = lists:keyfind(plt_extra_apps, 1, OldDialyzerConfig),
|
||||||
Extra = OldExtra ++ [quicer || IsQuicSupp()],
|
Extra = OldExtra ++ [quicer || IsQuicSupp()],
|
||||||
NewDialyzerConfig = [{plt_extra_apps, Extra} | OldDialyzerConfig],
|
NewDialyzerConfig = [{plt_extra_apps, Extra} | OldDialyzerConfig],
|
||||||
lists:keystore(
|
lists:keystore(
|
||||||
dialyzer,
|
dialyzer,
|
||||||
1,
|
1,
|
||||||
Config,
|
Config,
|
||||||
{dialyzer, NewDialyzerConfig}
|
{dialyzer, NewDialyzerConfig}
|
||||||
)
|
)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
ExtraDeps = fun(C) ->
|
ExtraDeps = fun(C) ->
|
||||||
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
||||||
|
|
25
build
25
build
|
@ -147,7 +147,7 @@ make_rel() {
|
||||||
|
|
||||||
make_elixir_rel() {
|
make_elixir_rel() {
|
||||||
./scripts/pre-compile.sh "$PROFILE"
|
./scripts/pre-compile.sh "$PROFILE"
|
||||||
export_release_vars "$PROFILE"
|
export_elixir_release_vars "$PROFILE"
|
||||||
# for some reason, this has to be run outside "do"...
|
# for some reason, this has to be run outside "do"...
|
||||||
mix local.rebar --if-missing --force
|
mix local.rebar --if-missing --force
|
||||||
# shellcheck disable=SC1010
|
# shellcheck disable=SC1010
|
||||||
|
@ -362,7 +362,7 @@ function join {
|
||||||
|
|
||||||
# used to control the Elixir Mix Release output
|
# used to control the Elixir Mix Release output
|
||||||
# see docstring in `mix.exs`
|
# see docstring in `mix.exs`
|
||||||
export_release_vars() {
|
export_elixir_release_vars() {
|
||||||
local profile="$1"
|
local profile="$1"
|
||||||
case "$profile" in
|
case "$profile" in
|
||||||
emqx|emqx-enterprise)
|
emqx|emqx-enterprise)
|
||||||
|
@ -376,27 +376,6 @@ export_release_vars() {
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
export MIX_ENV="$profile"
|
export MIX_ENV="$profile"
|
||||||
|
|
||||||
local erl_opts=()
|
|
||||||
|
|
||||||
case "$(is_enterprise "$profile")" in
|
|
||||||
'yes')
|
|
||||||
erl_opts+=( "{d, 'EMQX_RELEASE_EDITION', ee}" )
|
|
||||||
;;
|
|
||||||
'no')
|
|
||||||
erl_opts+=( "{d, 'EMQX_RELEASE_EDITION', ce}" )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# At this time, Mix provides no easy way to pass `erl_opts' to
|
|
||||||
# dependencies. The workaround is to set this variable before
|
|
||||||
# compiling the project, so that `emqx_release.erl' picks up
|
|
||||||
# `emqx_vsn' as if it was compiled by rebar3.
|
|
||||||
erl_opts+=( "{compile_info,[{emqx_vsn,\"${PKG_VSN}\"}]}" )
|
|
||||||
erl_opts+=( "{d,snk_kind,msg}" )
|
|
||||||
|
|
||||||
ERL_COMPILER_OPTIONS="[$(join , "${erl_opts[@]}")]"
|
|
||||||
export ERL_COMPILER_OPTIONS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log "building artifact=$ARTIFACT for profile=$PROFILE"
|
log "building artifact=$ARTIFACT for profile=$PROFILE"
|
||||||
|
|
68
mix.exs
68
mix.exs
|
@ -31,16 +31,17 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
|
|
||||||
def project() do
|
def project() do
|
||||||
profile_info = check_profile!()
|
profile_info = check_profile!()
|
||||||
|
version = pkg_vsn()
|
||||||
|
|
||||||
[
|
[
|
||||||
app: :emqx_mix,
|
app: :emqx_mix,
|
||||||
version: pkg_vsn(),
|
version: version,
|
||||||
deps: deps(profile_info),
|
deps: deps(profile_info, version),
|
||||||
releases: releases()
|
releases: releases()
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp deps(profile_info) do
|
defp deps(profile_info, version) do
|
||||||
# we need several overrides here because dependencies specify
|
# we need several overrides here because dependencies specify
|
||||||
# other exact versions, and not ranges.
|
# other exact versions, and not ranges.
|
||||||
[
|
[
|
||||||
|
@ -61,7 +62,9 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:ecpool, github: "emqx/ecpool", tag: "0.5.3", override: true},
|
{:ecpool, github: "emqx/ecpool", tag: "0.5.3", override: true},
|
||||||
{:replayq, github: "emqx/replayq", tag: "0.3.7", override: true},
|
{:replayq, github: "emqx/replayq", tag: "0.3.7", override: true},
|
||||||
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
||||||
{:emqtt, github: "emqx/emqtt", tag: "1.8.5", override: true},
|
# maybe forbid to fetch quicer
|
||||||
|
{:emqtt,
|
||||||
|
github: "emqx/emqtt", tag: "1.8.5", override: true, system_env: maybe_no_quic_env()},
|
||||||
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
|
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
|
||||||
{:observer_cli, "1.7.1"},
|
{:observer_cli, "1.7.1"},
|
||||||
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},
|
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},
|
||||||
|
@ -92,11 +95,15 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:gpb, "4.19.5", override: true, runtime: false},
|
{:gpb, "4.19.5", override: true, runtime: false},
|
||||||
{:hackney, github: "benoitc/hackney", tag: "1.18.1", override: true}
|
{:hackney, github: "benoitc/hackney", tag: "1.18.1", override: true}
|
||||||
] ++
|
] ++
|
||||||
umbrella_apps() ++
|
emqx_apps(profile_info, version) ++
|
||||||
enterprise_apps(profile_info) ++
|
|
||||||
enterprise_deps(profile_info) ++ bcrypt_dep() ++ jq_dep() ++ quicer_dep()
|
enterprise_deps(profile_info) ++ bcrypt_dep() ++ jq_dep() ++ quicer_dep()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp emqx_apps(profile_info, version) do
|
||||||
|
apps = umbrella_apps() ++ enterprise_apps(profile_info)
|
||||||
|
set_emqx_app_system_env(apps, profile_info, version)
|
||||||
|
end
|
||||||
|
|
||||||
defp umbrella_apps() do
|
defp umbrella_apps() do
|
||||||
"apps/*"
|
"apps/*"
|
||||||
|> Path.wildcard()
|
|> Path.wildcard()
|
||||||
|
@ -145,6 +152,46 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp set_emqx_app_system_env(apps, profile_info, version) do
|
||||||
|
system_env = emqx_app_system_env(profile_info, version) ++ maybe_no_quic_env()
|
||||||
|
|
||||||
|
Enum.map(
|
||||||
|
apps,
|
||||||
|
fn {app, opts} ->
|
||||||
|
{app,
|
||||||
|
Keyword.update(
|
||||||
|
opts,
|
||||||
|
:system_env,
|
||||||
|
system_env,
|
||||||
|
&Keyword.merge(&1, system_env)
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def emqx_app_system_env(profile_info, version) do
|
||||||
|
erlc_options(profile_info, version)
|
||||||
|
|> dump_as_erl()
|
||||||
|
|> then(&[{"ERL_COMPILER_OPTIONS", &1}])
|
||||||
|
end
|
||||||
|
|
||||||
|
defp erlc_options(%{edition_type: edition_type}, version) do
|
||||||
|
[
|
||||||
|
:debug_info,
|
||||||
|
{:compile_info, [{:emqx_vsn, String.to_charlist(version)}]},
|
||||||
|
{:d, :EMQX_RELEASE_EDITION, erlang_edition(edition_type)},
|
||||||
|
{:d, :snk_kind, :msg}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def maybe_no_quic_env() do
|
||||||
|
if not enable_quicer?() do
|
||||||
|
[{"BUILD_WITHOUT_QUIC", "true"}]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp releases() do
|
defp releases() do
|
||||||
[
|
[
|
||||||
emqx: fn ->
|
emqx: fn ->
|
||||||
|
@ -804,4 +851,13 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
|> List.first()
|
|> List.first()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp dump_as_erl(term) do
|
||||||
|
term
|
||||||
|
|> then(&:io_lib.format("~0p", [&1]))
|
||||||
|
|> :erlang.iolist_to_binary()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp erlang_edition(:community), do: :ce
|
||||||
|
defp erlang_edition(:enterprise), do: :ee
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue