homebrew-core/Formula/tarantool.rb

95 lines
3.3 KiB
Ruby

class Tarantool < Formula
desc "In-memory database and Lua application server"
homepage "https://tarantool.org/"
url "https://download.tarantool.org/tarantool/2.8/src/tarantool-2.8.3.0.tar.gz"
sha256 "953614448f23f37370c49c7832dba05b66c3b507c7047674403e05dbdc96bda8"
license "BSD-2-Clause"
version_scheme 1
head "https://github.com/tarantool/tarantool.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_monterey: "449362fd95727d7bdd16fe236a0d7e568e28c93c6a689143b7ba6d3789b87477"
sha256 cellar: :any, arm64_big_sur: "14a8805adc1acce67d1d8ad4a8058f0a91d830eb777196094bd7b6051c9022e3"
sha256 monterey: "c7c0b6de9a12a78c35a79284cfa7fe2fd06d700b27eef5e34b2c5b9f0044a1b7"
sha256 big_sur: "0ae949f642f828b42470057ac2573c693df046ccacdab1ba451b632b766ed24c"
sha256 catalina: "2dd055342cc0a398c0d594a272de9f1b677bec8c50b4187dd9f930aa3a3be441"
sha256 cellar: :any_skip_relocation, x86_64_linux: "129548b8d0ac6e99d44bca684e15df76078068267e5e3db1efba91761fa0900f"
end
depends_on "cmake" => :build
depends_on "icu4c"
depends_on "libyaml"
depends_on "openssl@1.1"
depends_on "readline"
depends_on "zstd"
uses_from_macos "curl"
uses_from_macos "ncurses"
def install
# Avoid keeping references to Homebrew's clang/clang++ shims
inreplace "src/trivia/config.h.cmake",
"#define COMPILER_INFO \"@CMAKE_C_COMPILER@ @CMAKE_CXX_COMPILER@\"",
"#define COMPILER_INFO \"/usr/bin/clang /usr/bin/clang++\""
args = std_cmake_args
args << "-DCMAKE_INSTALL_MANDIR=#{doc}"
args << "-DCMAKE_INSTALL_SYSCONFDIR=#{etc}"
args << "-DCMAKE_INSTALL_LOCALSTATEDIR=#{var}"
args << "-DENABLE_DIST=ON"
args << "-DOPENSSL_ROOT_DIR=#{Formula["openssl@1.1"].opt_prefix}"
args << "-DREADLINE_ROOT=#{Formula["readline"].opt_prefix}"
args << "-DENABLE_BUNDLED_LIBCURL=OFF"
args << "-DENABLE_BUNDLED_LIBYAML=OFF"
args << "-DENABLE_BUNDLED_ZSTD=OFF"
if OS.mac?
if MacOS.version >= :big_sur
sdk = MacOS.sdk_path_if_needed
lib_suffix = "tbd"
else
sdk = ""
lib_suffix = "dylib"
end
args << "-DCURL_INCLUDE_DIR=#{sdk}/usr/include"
args << "-DCURL_LIBRARY=#{sdk}/usr/lib/libcurl.#{lib_suffix}"
args << "-DCURSES_NEED_NCURSES=ON"
args << "-DCURSES_NCURSES_INCLUDE_PATH=#{sdk}/usr/include"
args << "-DCURSES_NCURSES_LIBRARY=#{sdk}/usr/lib/libncurses.#{lib_suffix}"
args << "-DICONV_INCLUDE_DIR=#{sdk}/usr/include"
else
args << "-DCURL_ROOT=#{Formula["curl"].opt_prefix}"
end
system "cmake", ".", *args
system "make"
system "make", "install"
end
def post_install
local_user = ENV["USER"]
inreplace etc/"default/tarantool", /(username\s*=).*/, "\\1 '#{local_user}'"
(var/"lib/tarantool").mkpath
(var/"log/tarantool").mkpath
(var/"run/tarantool").mkpath
end
test do
(testpath/"test.lua").write <<~EOS
box.cfg{}
local s = box.schema.create_space("test")
s:create_index("primary")
local tup = {1, 2, 3, 4}
s:insert(tup)
local ret = s:get(tup[1])
if (ret[3] ~= tup[3]) then
os.exit(-1)
end
os.exit(0)
EOS
system bin/"tarantool", "#{testpath}/test.lua"
end
end