142 lines
5.3 KiB
Ruby
142 lines
5.3 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/v7.0.3.tar.gz"
|
|
sha256 "85bcdcd4adcd77eed6748804d5672d5725b5d2a469694e2a3dbd21b175cf4fd2"
|
|
license any_of: ["GPL-2.0-only", "Apache-2.0"]
|
|
head "https://github.com/facebook/rocksdb.git", branch: "main"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "72d280af1e3cc131ef2de59781a7eb89d4ce61df0defc23a2e3ddb0c8d21bb4e"
|
|
sha256 cellar: :any, arm64_big_sur: "7749fba348ffefb6fe0830146c031d038e2e5cf3d5e863abf6a8b61ae200dcee"
|
|
sha256 cellar: :any, monterey: "7ec3031bd34da67798b9b5aa6090b5ba438e1aea18ff7a098b3834c0051e15c2"
|
|
sha256 cellar: :any, big_sur: "bc59c25326447c43172e92f784533d722dca9ae1edf5cd4b0200056fc046dda3"
|
|
sha256 cellar: :any, catalina: "94b0de194cd78db1eaeb43220754fdec2349734b7098a6fc44bb681e8e712e88"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "262d1ae78f4a4c82220f64d915aec54bdc4e6e923268b7848524bae2e314b754"
|
|
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"
|
|
|
|
on_linux do
|
|
depends_on "gcc"
|
|
end
|
|
|
|
fails_with :gcc do
|
|
version "6"
|
|
cause "Requires C++17 compatible compiler. See https://github.com/facebook/rocksdb/issues/9388"
|
|
end
|
|
|
|
def install
|
|
base_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
|
|
-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,#{rpath}
|
|
]
|
|
|
|
# build rocksdb_lite
|
|
lite_args = base_args + %w[
|
|
-DROCKSDB_LITE=ON
|
|
-DARTIFACT_SUFFIX=_lite
|
|
-DWITH_CORE_TOOLS=OFF
|
|
-DWITH_TOOLS=OFF
|
|
]
|
|
mkdir "build_lite" do
|
|
system "cmake", "..", *lite_args
|
|
system "make", "install"
|
|
end
|
|
p = lib/"cmake/rocksdb/RocksDB"
|
|
["Targets.cmake", "Targets-release.cmake"].each do |s|
|
|
File.rename "#{p}#{s}", "#{p}_Lite#{s}"
|
|
end
|
|
|
|
# build regular rocksdb
|
|
mkdir "build" do
|
|
system "cmake", "..", *base_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
|
|
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 = []
|
|
if OS.mac?
|
|
extra_args << "-stdlib=libc++"
|
|
extra_args << "-lstdc++"
|
|
end
|
|
system ENV.cxx, "test.cpp", "-o", "db_test", "-v",
|
|
"-std=c++17",
|
|
*extra_args,
|
|
"-lz", "-lbz2",
|
|
"-L#{lib}", "-lrocksdb",
|
|
"-L#{Formula["snappy"].opt_lib}", "-lsnappy",
|
|
"-L#{Formula["lz4"].opt_lib}", "-llz4",
|
|
"-L#{Formula["zstd"].opt_lib}", "-lzstd"
|
|
system "./db_test"
|
|
system ENV.cxx, "test.cpp", "-o", "db_test_lite", "-v",
|
|
"-std=c++17",
|
|
*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_lite"
|
|
|
|
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
|