build: workaround for windows build

This commit is contained in:
William Yang 2022-06-15 11:18:24 +02:00
parent 96a510fbf1
commit 45e2605485
6 changed files with 30 additions and 16 deletions

View File

@ -13,26 +13,34 @@ IsWin32 = fun() ->
end,
IsMacOS = fun() ->
{unix, darwin} =:= os:type()
end,
{unix, darwin} =:= os:type()
end,
IsQuicSupp = fun() ->
not (IsCentos6() orelse IsWin32()
orelse IsMacOS() orelse
false =/= os:getenv("BUILD_WITHOUT_QUIC")
)
orelse "1" == os:getenv("BUILD_WITH_QUIC")
end,
not (IsCentos6() orelse IsWin32() orelse
IsMacOS() orelse
false =/= os:getenv("BUILD_WITHOUT_QUIC")) orelse
"1" == os:getenv("BUILD_WITH_QUIC")
end,
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.11"}}}.
ExtraDeps = fun(C) ->
{deps, Deps0} = lists:keyfind(deps, 1, C),
Deps =
Deps0 ++ [Bcrypt || not IsWin32()] ++
[Quicer || IsQuicSupp()],
lists:keystore(deps, 1, C, {deps, Deps})
{erl_opts, ErlOpts0} = lists:keyfind(erl_opts, 1, C),
IsQuic = IsQuicSupp(),
New = [
{deps, Deps0 ++ [Bcrypt || not IsWin32()] ++ [Quicer || IsQuic]},
{erl_opts, ErlOpts0 ++ [{d, 'BUILD_WITHOUT_QUIC'} || not IsQuic]}
],
lists:foldl(
fun({Key, _Val} = KV, Acc) ->
lists:keystore(Key, 1, Acc, KV)
end,
C,
New
)
end,
ExtraDeps(CONFIG).

View File

@ -15,7 +15,12 @@
%%--------------------------------------------------------------------
-module(emqx_quic_connection).
-ifndef(BUILD_WITHOUT_QUIC).
-include_lib("quicer/include/quicer.hrl").
-else.
-define(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, 0).
-endif.
%% Callbacks
-export([

View File

@ -16,7 +16,6 @@
%% MQTT/QUIC Stream
-module(emqx_quic_stream).
-include_lib("quicer/include/quicer.hrl").
%% emqx transport Callbacks
-export([

View File

@ -21,7 +21,7 @@
%% eredis_cluster's dependency getting resolved earlier.
%% Here we pin 1.5.2 to avoid surprises in the future.
{poolboy, {git, "https://github.com/emqx/poolboy.git", {tag, "1.5.2"}}},
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.5.1"}}}
{emqtt, {git, "https://github.com/qzhuyan/emqtt", {branch, "dev/william/bump-quicer"}}}
]}.
{shell, [

View File

@ -58,7 +58,8 @@ defmodule EMQXUmbrella.MixProject do
{:ecpool, github: "emqx/ecpool", tag: "0.5.2"},
{:replayq, "0.3.4", override: true},
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
{:emqtt, github: "emqx/emqtt", tag: "1.5.1", override: true},
# {:emqtt, github: "emqx/emqtt", tag: "1.5.1", override: true},
{:emqtt, github: "qzhuyan/emqtt", branch: "dev/william/bump-quicer", override: true},
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
{:observer_cli, "1.7.1"},
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},

View File

@ -138,7 +138,8 @@ common_compile_opts(Edition, Vsn) ->
{compile_info, [{emqx_vsn, Vsn}]},
{d, 'EMQX_RELEASE_EDITION', Edition}
] ++
[{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"].
[{d, 'EMQX_BENCHMARK'} || os:getenv("EMQX_BENCHMARK") =:= "1"] ++
[{d, 'BUILD_WITHOUT_QUIC'} || not is_quicer_supported()].
prod_compile_opts(Edition, Vsn) ->
[