]> granicus.if.org Git - ejabberd/commitdiff
Start elixir config code only if elixir was enabled in configure script
authorPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 8 Sep 2016 14:29:19 +0000 (16:29 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Thu, 8 Sep 2016 14:29:45 +0000 (16:29 +0200)
rebar.config
src/ejabberd_app.erl
src/ejabberd_config.erl

index 06a7d350aecf0ac8f7935bf24a86e51bce0a98c0..3c9610021b931aae127383fd8aac099cafbd6d29 100644 (file)
@@ -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,
index 9d127e748fb8cd7eb4c8ea79ecf147dc6eee72a3..890ab6f9044ea4d8613bbe431416f3e92c10d8ae 100644 (file)
@@ -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.
index 7d5dfbc0c2e40bcfee146084c96fa7d31b295f08..6ca6a40a846a03397aab0bb739ff30ca758c6945 100644 (file)
@@ -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) ->