diff --git a/rebar.config b/rebar.config index 06a7d350a..3c9610021 100644 --- a/rebar.config +++ b/rebar.config @@ -74,6 +74,7 @@ {if_var_true, debug, debug_info}, {if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}}, {if_var_match, db_type, mssql, {d, 'mssql'}}, + {if_var_true, elixir, {d, 'ELIXIR_ENABLED'}}, {if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}}, {if_var_true, hipe, native}, {src_dirs, [asn1, src, diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 9d127e748..890ab6f90 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -255,7 +255,12 @@ register_elixir_config_hooks() -> end. start_elixir_application() -> - case application:ensure_started(elixir) of - ok -> ok; - {error, _Msg} -> ?ERROR_MSG("Elixir application not started.", []) - end. + case ejabberd_config:is_elixir_enabled() of + true -> + case application:ensure_started(elixir) of + ok -> ok; + {error, _Msg} -> ?ERROR_MSG("Elixir application not started.", []) + end; + _ -> + ok + end. diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 7d5dfbc0c..6ca6a40a8 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -37,7 +37,8 @@ prepare_opt_val/4, convert_table_to_binary/5, transform_options/1, collect_options/1, default_db/2, convert_to_yaml/1, convert_to_yaml/2, v_db/2, - env_binary_to_list/2, opt_type/1, may_hide_data/1]). + env_binary_to_list/2, opt_type/1, may_hide_data/1, + is_elixir_enabled/0]). -export([start/2]). @@ -148,13 +149,18 @@ read_file(File) -> {include_modules_configs, true}]). read_file(File, Opts) -> - Terms1 = case 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(File) of - true -> - 'Elixir.Ejabberd.Config':init(File), - 'Elixir.Ejabberd.Config':get_ejabberd_opts(); - false -> - get_plain_terms_file(File, Opts) - end, + Terms1 = case is_elixir_enabled() of + true -> + case 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(File) of + true -> + 'Elixir.Ejabberd.Config':init(File), + 'Elixir.Ejabberd.Config':get_ejabberd_opts(); + false -> + get_plain_terms_file(File, Opts) + end; + false -> + get_plain_terms_file(File, Opts) + end, Terms_macros = case proplists:get_bool(replace_macros, Opts) of true -> replace_macros(Terms1); false -> Terms1 @@ -1049,9 +1055,22 @@ replace_modules(Modules) -> %% Elixir module naming %% ==================== +-ifdef(ELIXIR_ENABLED). +is_elixir_enabled() -> + true. +-else. +is_elixir_enabled() -> + false. +-endif. + is_using_elixir_config() -> - Config = get_ejabberd_config_path(), - 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(Config). + case is_elixir_enabled() of + true -> + Config = get_ejabberd_config_path(), + 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(Config); + false -> + false + end. %% If module name start with uppercase letter, this is an Elixir module: is_elixir_module(Module) ->