1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
##
## Copyright (c) 2016-2022 VMware, Inc. or its affiliates. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.HipeCompileCommand do
@moduledoc """
HiPE support has been deprecated since Erlang/OTP 22 (mid-2019) and
won't be a part of Erlang/OTP 24.
Therefore this command is DEPRECATED and is no-op.
"""
alias RabbitMQ.CLI.Core.{DocGuide, Validators}
import RabbitMQ.CLI.Core.CodePath
@behaviour RabbitMQ.CLI.CommandBehaviour
#
# API
#
def distribution(_), do: :none
use RabbitMQ.CLI.Core.MergesNoDefaults
def validate([], _), do: {:validation_failure, :not_enough_args}
def validate([target_dir], opts) do
:ok
|> Validators.validate_step(fn ->
case acceptable_path?(target_dir) do
true -> :ok
false -> {:error, {:bad_argument, "Target directory path cannot be blank"}}
end
end)
|> Validators.validate_step(fn ->
case File.dir?(target_dir) do
true ->
:ok
false ->
case File.mkdir_p(target_dir) do
:ok ->
:ok
{:error, perm} when perm == :eperm or perm == :eacces ->
{:error,
{:bad_argument,
"Cannot create target directory #{target_dir}: insufficient permissions"}}
end
end
end)
|> Validators.validate_step(fn -> require_rabbit(opts) end)
end
def validate(_, _), do: {:validation_failure, :too_many_args}
def run([_target_dir], _opts) do
:ok
end
use RabbitMQ.CLI.DefaultOutput
def usage, do: "hipe_compile <directory>"
def usage_additional do
[
["<directory>", "Target directory for HiPE-compiled modules"]
]
end
def usage_doc_guides() do
[
DocGuide.configuration(),
DocGuide.erlang_versions()
]
end
def help_section(), do: :deprecated
def description() do
"DEPRECATED. This command is a no-op. HiPE is no longer supported by modern Erlang versions"
end
def banner([_target_dir], _) do
"This command is a no-op. HiPE is no longer supported by modern Erlang versions"
end
#
# Implementation
#
# Accepts any non-blank path
defp acceptable_path?(value) do
String.length(String.trim(value)) != 0
end
end
|