From 95ea5494727797202e802be75d5544814060dda3 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Mon, 13 Mar 2017 21:21:15 +0300 Subject: [PATCH] rabbit app is loaded during validation; handle "already compiled" cases References #178. --- .../cli/ctl/commands/hipe_compile_command.ex | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex index 07ad57d1bf..afaba38e2a 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex @@ -39,20 +39,8 @@ defmodule RabbitMQ.CLI.Ctl.Commands.HipeCompileCommand do def validate(_, _), do: {:validation_failure, :too_many_args} def run([target_dir], _opts) do - case Application.load(:rabbit) do - :ok -> - Code.ensure_loaded(:rabbit_hipe) - hipe_compile(target_dir) - {:error, {:already_loaded, :rabbit}} -> - Code.ensure_loaded(:rabbit_hipe) - hipe_compile(target_dir) - :ok; - {:error, {'no such file or directory', 'rabbit.app'}} -> - {:error, "Failed to load RabbitMQ server app metadata. Cannot proceed with HiPE compilation."} - {:error, _reason} -> - {:error, "Failed to load RabbitMQ modules or app metadata. Cannot proceed with HiPE compilation."} - end - + Code.ensure_loaded(:rabbit_hipe) + hipe_compile(target_dir) end def banner([target_dir], _) do @@ -66,8 +54,11 @@ defmodule RabbitMQ.CLI.Ctl.Commands.HipeCompileCommand do defp hipe_compile(target_dir) do case :rabbit_hipe.can_hipe_compile() do true -> - {:ok, _, _} = :rabbit_hipe.compile_to_directory(target_dir) - :ok + case :rabbit_hipe.compile_to_directory(target_dir) do + {:ok, _, _} -> :ok + {:ok, :already_compiled} -> {:ok, "already compiled"} + {:error, message} -> {:error, message} + end false -> {:error, "HiPE compilation is not supported"} end