124 lines
4.2 KiB
Ruby
124 lines
4.2 KiB
Ruby
class Rocksdb < Formula
|
|
desc "Embeddable, persistent key-value store for fast storage"
|
|
homepage "https://rocksdb.org/"
|
|
url "https://github.com/facebook/rocksdb/archive/v6.15.4.tar.gz"
|
|
sha256 "845bc4597c69797b6731fb592d4e6e8b7995573f8ad2eea5cd34128715db750f"
|
|
license any_of: ["GPL-2.0-only", "Apache-2.0"]
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "98c2d9712a43aae4efdab83d7b3fe9323489c09a28845404db9620907ce70e08" => :big_sur
|
|
sha256 "42635bc093ed498a1f7c24545a894def03b6fde82ff45be1d6d8a9c658dd8400" => :catalina
|
|
sha256 "e7c1d9ff93f7248f945b826e114bf8424dccd0fde2de1c0b762d88497ae35933" => :mojave
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "gflags"
|
|
depends_on "lz4"
|
|
depends_on "snappy"
|
|
depends_on "zstd"
|
|
|
|
uses_from_macos "bzip2"
|
|
uses_from_macos "zlib"
|
|
|
|
# Add artifact suffix to shared library
|
|
# https://github.com/facebook/rocksdb/pull/7755
|
|
patch do
|
|
url "https://github.com/facebook/rocksdb/commit/98f3f3143007bcb5455105a05da7eeecc9cf53a0.patch?full_index=1"
|
|
sha256 "6fb59cd640ed8c39692855115b72e8aa8db50a7aa3842d53237e096e19f88fc1"
|
|
end
|
|
|
|
def install
|
|
ENV.cxx11
|
|
args = std_cmake_args + %w[
|
|
-DPORTABLE=ON
|
|
-DUSE_RTTI=ON
|
|
-DWITH_BENCHMARK_TOOLS=OFF
|
|
-DWITH_BZ2=ON
|
|
-DWITH_LZ4=ON
|
|
-DWITH_SNAPPY=ON
|
|
-DWITH_ZLIB=ON
|
|
-DWITH_ZSTD=ON
|
|
]
|
|
|
|
# build regular rocksdb
|
|
mkdir "build" do
|
|
system "cmake", "..", *args
|
|
system "make", "install"
|
|
|
|
cd "tools" do
|
|
bin.install "sst_dump" => "rocksdb_sst_dump"
|
|
bin.install "db_sanity_test" => "rocksdb_sanity_test"
|
|
bin.install "write_stress" => "rocksdb_write_stress"
|
|
bin.install "ldb" => "rocksdb_ldb"
|
|
bin.install "db_repl_stress" => "rocksdb_repl_stress"
|
|
bin.install "rocksdb_dump"
|
|
bin.install "rocksdb_undump"
|
|
end
|
|
bin.install "db_stress_tool/db_stress" => "rocksdb_stress"
|
|
end
|
|
|
|
# build rocksdb_lite
|
|
args += %w[
|
|
-DROCKSDB_LITE=ON
|
|
-DARTIFACT_SUFFIX=_lite
|
|
-DWITH_CORE_TOOLS=OFF
|
|
-DWITH_TOOLS=OFF
|
|
]
|
|
mkdir "build_lite" do
|
|
system "cmake", "..", *args
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <assert.h>
|
|
#include <rocksdb/options.h>
|
|
#include <rocksdb/memtablerep.h>
|
|
using namespace rocksdb;
|
|
int main() {
|
|
Options options;
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
extra_args = []
|
|
on_macos do
|
|
extra_args << "-stdlib=libc++"
|
|
extra_args << "-lstdc++"
|
|
end
|
|
system ENV.cxx, "test.cpp", "-o", "db_test", "-v",
|
|
"-std=c++11",
|
|
*extra_args,
|
|
"-lz", "-lbz2",
|
|
"-L#{lib}", "-lrocksdb_lite",
|
|
"-DROCKSDB_LITE=1",
|
|
"-L#{Formula["snappy"].opt_lib}", "-lsnappy",
|
|
"-L#{Formula["lz4"].opt_lib}", "-llz4",
|
|
"-L#{Formula["zstd"].opt_lib}", "-lzstd"
|
|
system "./db_test"
|
|
|
|
assert_match "sst_dump --file=", shell_output("#{bin}/rocksdb_sst_dump --help 2>&1")
|
|
assert_match "rocksdb_sanity_test <path>", shell_output("#{bin}/rocksdb_sanity_test --help 2>&1", 1)
|
|
assert_match "rocksdb_stress [OPTIONS]...", shell_output("#{bin}/rocksdb_stress --help 2>&1", 1)
|
|
assert_match "rocksdb_write_stress [OPTIONS]...", shell_output("#{bin}/rocksdb_write_stress --help 2>&1", 1)
|
|
assert_match "ldb - RocksDB Tool", shell_output("#{bin}/rocksdb_ldb --help 2>&1")
|
|
assert_match "rocksdb_repl_stress:", shell_output("#{bin}/rocksdb_repl_stress --help 2>&1", 1)
|
|
assert_match "rocksdb_dump:", shell_output("#{bin}/rocksdb_dump --help 2>&1", 1)
|
|
assert_match "rocksdb_undump:", shell_output("#{bin}/rocksdb_undump --help 2>&1", 1)
|
|
|
|
db = testpath / "db"
|
|
%w[no snappy zlib bzip2 lz4 zstd].each_with_index do |comp, idx|
|
|
key = "key-#{idx}"
|
|
value = "value-#{idx}"
|
|
|
|
put_cmd = "#{bin}/rocksdb_ldb put --db=#{db} --create_if_missing --compression_type=#{comp} #{key} #{value}"
|
|
assert_equal "OK", shell_output(put_cmd).chomp
|
|
|
|
get_cmd = "#{bin}/rocksdb_ldb get --db=#{db} #{key}"
|
|
assert_equal value, shell_output(get_cmd).chomp
|
|
end
|
|
end
|
|
end
|