diff options
Diffstat (limited to 'mix.exs')
-rw-r--r-- | mix.exs | 96 |
1 files changed, 61 insertions, 35 deletions
@@ -5,7 +5,7 @@ defmodule Ejabberd.MixProject do [app: :ejabberd, version: version(), description: description(), - elixir: "~> 1.4", + elixir: elixir_required_version(), elixirc_paths: ["lib"], compile_path: ".", compilers: [:asn1] ++ Mix.compilers, @@ -26,9 +26,9 @@ defmodule Ejabberd.MixProject do '0.0' -> "0.0.0" # the full git repository wasn't downloaded 'latest.0' -> "0.0.0" # running 'docker-ejabberd/ecs/build.sh latest' [_, _, ?., _, _] = x -> - head = String.replace(:erlang.list_to_binary(x), ~r/0+([0-9])/, "\\1") + head = String.replace(:erlang.list_to_binary(x), ~r/\.0+([0-9])/, ".\\1") <<head::binary, ".0">> - vsn -> String.replace(:erlang.list_to_binary(vsn), ~r/0+([0-9])/, "\\1") + vsn -> String.replace(:erlang.list_to_binary(vsn), ~r/\.0+([0-9])/, ".\\1") end end @@ -43,22 +43,13 @@ defmodule Ejabberd.MixProject do extra_applications: [:mix], applications: [:idna, :inets, :kernel, :sasl, :ssl, :stdlib, :base64url, :fast_tls, :fast_xml, :fast_yaml, :jiffy, :jose, - :p1_utils, :stringprep, :stun, :yconf], - included_applications: [:lager, :mnesia, :os_mon, - :cache_tab, :eimp, :esip, :mqtree, :p1_acme, + :p1_utils, :stringprep, :yconf], + included_applications: [:mnesia, :os_mon, + :cache_tab, :eimp, :mqtree, :p1_acme, :p1_oauth2, :pkix, :xmpp] ++ cond_apps()] end - defp if_function_exported(mod, fun, arity, okResult) do - :code.ensure_loaded(mod) - if :erlang.function_exported(mod, fun, arity) do - okResult - else - [] - end - end - defp if_version_above(ver, okResult) do if :erlang.system_info(:otp_release) > ver do okResult @@ -78,18 +69,19 @@ defmodule Ejabberd.MixProject do defp erlc_options do # Use our own includes + includes from all dependencies includes = ["include"] ++ deps_include(["fast_xml", "xmpp", "p1_utils"]) - result = [:debug_info, {:d, :ELIXIR_ENABLED}] ++ + result = [{:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn (path) -> {:i, path} end) ++ if_version_above('20', [{:d, :DEPRECATED_GET_STACKTRACE}]) ++ + if_version_above('20', [{:d, :HAVE_URI_STRING}]) ++ + if_version_above('20', [{:d, :HAVE_ERL_ERROR}]) ++ if_version_below('21', [{:d, :USE_OLD_HTTP_URI}]) ++ if_version_below('22', [{:d, :LAGER}]) ++ + if_version_below('21', [{:d, :NO_CUSTOMIZE_HOSTNAME_CHECK}]) ++ if_version_below('23', [{:d, :USE_OLD_CRYPTO_HMAC}]) ++ if_version_below('23', [{:d, :USE_OLD_PG2}]) ++ if_version_below('24', [{:d, :COMPILER_REPORTS_ONLY_LINES}]) ++ - if_version_below('24', [{:d, :SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL}]) ++ - if_function_exported(:uri_string, :normalize, 1, [{:d, :HAVE_URI_STRING}]) - if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}]) + if_version_below('24', [{:d, :SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL}]) defines = for {:d, value} <- result, do: {:d, value} result ++ [{:d, :ALL_DEFS, defines}] end @@ -97,7 +89,9 @@ defmodule Ejabberd.MixProject do defp cond_options do for {:true, option} <- [{config(:sip), {:d, :SIP}}, {config(:stun), {:d, :STUN}}, - {config(:roster_gateway_workaround), {:d, :ROSTER_GATWAY_WORKAROUND}}, + {config(:debug), :debug_info}, + {not config(:debug), {:debug_info, false}}, + {config(:roster_gateway_workaround), {:d, :ROSTER_GATEWAY_WORKAROUND}}, {config(:new_sql_schema), {:d, :NEW_SQL_SCHEMA}} ], do: option @@ -106,26 +100,19 @@ defmodule Ejabberd.MixProject do defp deps do [{:base64url, "~> 1.0"}, {:cache_tab, "~> 1.0"}, - {:distillery, "~> 2.0"}, {:eimp, "~> 1.0"}, - {:esip, "~> 1.0"}, - {:ex_doc, ">= 0.0.0", only: :dev}, {:fast_tls, "~> 1.1"}, {:fast_xml, "~> 1.1"}, {:fast_yaml, "~> 1.0"}, {:idna, "~> 6.0"}, - {:jiffy, "~> 1.0.5"}, + {:jiffy, "~> 1.1.1"}, {:jose, "~> 1.11.1"}, - {:lager, "~> 3.9.1"}, {:mqtree, "~> 1.0"}, {:p1_acme, "~> 1.0"}, - {:p1_mysql, "~> 1.0"}, {:p1_oauth2, "~> 0.6"}, - {:p1_pgsql, "~> 1.1"}, {:p1_utils, "~> 1.0"}, {:pkix, "~> 1.0"}, {:stringprep, ">= 1.0.26"}, - {:stun, "~> 1.0"}, {:xmpp, "~> 1.5"}, {:yconf, "~> 1.0"}] ++ cond_deps() @@ -146,15 +133,24 @@ defmodule Ejabberd.MixProject do defp cond_deps do for {:true, dep} <- [{config(:pam), {:epam, "~> 1.0"}}, {config(:redis), {:eredis, "~> 1.2.0"}}, + {config(:sip), {:esip, "~> 1.0"}}, {config(:zlib), {:ezlib, "~> 1.0"}}, + {if_version_below('22', true), {:lager, "~> 3.9.1"}}, {config(:lua), {:luerl, "~> 1.0"}}, - {config(:sqlite), {:sqlite3, "~> 1.1"}}], do: + {config(:mysql), {:p1_mysql, "~> 1.0"}}, + {config(:pgsql), {:p1_pgsql, "~> 1.1"}}, + {config(:sqlite), {:sqlite3, "~> 1.1"}}, + {config(:stun), {:stun, "~> 1.0"}}], do: dep end defp cond_apps do - for {:true, app} <- [{config(:redis), :eredis}, + for {:true, app} <- [{config(:pam), :epam}, + {config(:lua), :luerl}, + {config(:redis), :eredis}, + {if_version_below('22', true), :lager}, {config(:mysql), :p1_mysql}, + {config(:sip), :esip}, {config(:odbc), :odbc}, {config(:pgsql), :p1_pgsql}, {config(:sqlite), :sqlite3}], do: @@ -188,6 +184,35 @@ defmodule Ejabberd.MixProject do end end + defp elixir_required_version do + case {System.get_env("RELIVE", "false"), + MapSet.member?(MapSet.new(System.argv()), "release")} + do + {"true", _} -> + case Version.match?(System.version(), "~> 1.11") do + false -> + IO.puts("ERROR: To use 'make relive', Elixir 1.11.0 or higher is required.") + _ -> :ok + end + "~> 1.11" + {_, true} -> + case Version.match?(System.version(), "~> 1.10") do + false -> + IO.puts("ERROR: To build releases, Elixir 1.10.0 or higher is required.") + _ -> :ok + end + case Version.match?(System.version(), "< 1.11.4") + and :erlang.system_info(:otp_release) > '23' do + true -> + IO.puts("ERROR: To build releases with Elixir lower than 1.11.4, Erlang/OTP lower than 24 is required.") + _ -> :ok + end + "~> 1.10" + _ -> + "~> 1.4" + end + end + defp releases do maybe_tar = case Mix.env() do :prod -> [:tar] @@ -232,7 +257,7 @@ defmodule Ejabberd.MixProject do end # Mix/Elixir lower than 1.11.0 use config/releases.exs instead of runtime.exs - case Version.match?(System.version, ">= 1.11.0") do + case Version.match?(System.version, "~> 1.11") do true -> :ok false -> @@ -244,9 +269,10 @@ defmodule Ejabberd.MixProject do execute.("sed -e 's|{{\\(\[_a-z\]*\\)}}|<%= @\\1 %>|g' ejabberdctl.example2> ejabberdctl.example2a") Mix.Generator.copy_template("ejabberdctl.example2a", "ejabberdctl.example2b", assigns) execute.("sed -e 's|{{\\(\[_a-z\]*\\)}}|<%= @\\1 %>|g' ejabberdctl.example2b > ejabberdctl.example3") - execute.("sed -e 's|ERLANG_NODE=ejabberd@localhost|ERLANG_NODE=ejabberd|g' ejabberdctl.example3 > ejabberdctl.example4") - execute.("sed -e 's|INSTALLUSER=|ERL_OPTIONS=\"-setcookie \\$\\(cat \"\\${SCRIPT_DIR%/*}/releases/COOKIE\")\"\\nINSTALLUSER=|g' ejabberdctl.example4 > ejabberdctl.example5") - Mix.Generator.copy_template("ejabberdctl.example5", "#{ro}/bin/ejabberdctl", assigns) + execute.("sed -e 's|^ERLANG_NODE=ejabberd@localhost|ERLANG_NODE=ejabberd|g' ejabberdctl.example3 > ejabberdctl.example4") + execute.("sed -e 's|^ERLANG_OPTS=\"|ERLANG_OPTS=\"-boot ../releases/#{release.version}/start_clean -boot_var RELEASE_LIB ../lib |' ejabberdctl.example4 > ejabberdctl.example5") + execute.("sed -e 's|^INSTALLUSER=|ERL_OPTIONS=\"-setcookie \\$\\(cat \"\\${SCRIPT_DIR%/*}/releases/COOKIE\")\"\\nINSTALLUSER=|g' ejabberdctl.example5 > ejabberdctl.example6") + Mix.Generator.copy_template("ejabberdctl.example6", "#{ro}/bin/ejabberdctl", assigns) File.chmod("#{ro}/bin/ejabberdctl", 0o755) File.rm("ejabberdctl.example1") @@ -256,6 +282,7 @@ defmodule Ejabberd.MixProject do File.rm("ejabberdctl.example3") File.rm("ejabberdctl.example4") File.rm("ejabberdctl.example5") + File.rm("ejabberdctl.example6") suffix = case Mix.env() do :dev -> @@ -268,7 +295,6 @@ defmodule Ejabberd.MixProject do Mix.Generator.copy_file("ejabberd.yml.example", "#{ro}/etc/ejabberd/ejabberd.yml#{suffix}") Mix.Generator.copy_file("ejabberdctl.cfg.example", "#{ro}/etc/ejabberd/ejabberdctl.cfg#{suffix}") Mix.Generator.copy_file("inetrc", "#{ro}/etc/ejabberd/inetrc") - Mix.Generator.copy_template("rel/vm.args.mix", "#{ro}/etc/ejabberd/vm.args", assigns) Enum.each(File.ls!("sql"), fn x -> |