From 7121a9542801702a63bf6a7ccb92a9bd27ffc6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Mon, 6 Nov 2017 11:29:42 +0100 Subject: [PATCH] Define flags that depend on erlang version in mix.exs --- mix.exs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 2ac1992cf..d5dc7175e 100644 --- a/mix.exs +++ b/mix.exs @@ -32,10 +32,23 @@ defmodule Ejabberd.Mixfile do ++ 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 erlc_options do # Use our own includes + includes from all dependencies includes = ["include"] ++ deps_include(["fast_xml", "xmpp", "p1_utils"]) - [:debug_info, {:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn(path) -> {:i, path} end) + [:debug_info, {:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn(path) -> {:i, path} end) ++ + if_function_exported(:crypto, :strong_rand_bytes, 1, [{:d, :STRONG_RAND_BYTES}]) ++ + if_function_exported(:rand, :uniform, 1, [{:d, :RAND_UNIFORM}]) ++ + if_function_exported(:gb_sets, :iterator_from, 2, [{:d, :GB_SETS_ITERATOR_FROM}]) ++ + if_function_exported(:public_key, :short_name_hash, 1, [{:d, :SHORT_NAME_HASH}]) end defp cond_options do