Add RocksDB receipt

This commit is contained in:
Eyck Jentzsch 2020-04-05 12:40:20 +02:00
parent cf92cbca9a
commit 3117dadcfe
5 changed files with 135 additions and 0 deletions

15
RocksDB/build.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager(username="minres")
cxxstds = ['11','14']
libstdcxx = ['libstdc++', 'libstdc++11']
shared = [True, False]
for triple in [[c,l] for c in cxxstds for l in libstdcxx]:
builder.add(
settings={"compiler.libcxx":triple[1]},
options={"stdcxx" : triple[0], "fPIC":True},
env_vars={},
build_requires={})
builder.run()

64
RocksDB/conanfile.py Normal file
View File

@ -0,0 +1,64 @@
from conans import ConanFile, CMake, tools
import os
class RocksDBConan(ConanFile):
name = "rocksdb"
version = "6.6.4"
license = "Apache 2.0 License"
url = "https://github.com/facebook/rocksdb/"
description = "A library that provides an embeddable, persistent key-value store for fast storage."
settings = "os", "compiler", "build_type", "arch"
options = {"stdcxx":[11,14], "fPIC":[True, False]}
default_options = "stdcxx=14", "fPIC=True"
generators = ["cmake", "cmake_find_package", "cmake_paths"]
source_subfolder = "rocksdb-%s"% version
exports_sources = "rocksdb/*"
source_tgz = "https://github.com/facebook/rocksdb/archive/v%s.tar.gz" % version
requires = (
"zlib/1.2.11",
"bzip2/1.0.8",
"lz4/1.8.0@bincrafters/stable",
"gflags/2.2.2"
#"zlib/1.2.11@conan/stable",
#"bzip2/1.0.8@conan/stable",
#"lz4/1.8.0@bincrafters/stable",
#"gflags/2.2.2@bincrafters/stable"
# TODO snappy, zstandard
)
def source(self):
self.output.info("Downloading %s" %self.source_tgz)
tools.download(self.source_tgz, "rocksdb.tar.gz")
tools.unzip("rocksdb.tar.gz")
os.remove("rocksdb.tar.gz")
def build(self):
cmake = CMake(self, parallel=True)
cmake.configure(
source_folder=self.source_subfolder,
args=[
'-DCMAKE_CXX_FLAGS:="-D_GLIBCXX_USE_CXX11_ABI=%d"' % (0 if self.settings.compiler.libcxx == 'libstdc++' else 1),
#'-DROCKSDB_BUILD_SHARED=%s' % ('ON' if self.options.shared else 'OFF'),
'-DCMAKE_POSITION_INDEPENDENT_CODE=%s' % ('ON' if self.options.fPIC else 'OFF'),
'-DCMAKE_CXX_STANDARD=%s' % self.options.stdcxx,
'-DWITH_LZ4=ON -DWITH_ZLIB=ON -DWITH_BZ2=ON -DDISABLE_STALL_NOTIF=ON -DWITH_TESTS=OFF',
#'-DWITH_LZ4=ON -DWITH_ZLIB=ON -DWITH_BZ2=ON -DDISABLE_STALL_NOTIF=ON -DWITH_TOOLS=OFF -DWITH_TESTS=OFF',
#'-DWITH_BENCHMARK_TOOLS=OFF -DWITH_CORE_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_TESTS=OFF'
]
)
cmake.build(target='rocksdb')
#cmake.install()
def package(self):
self.copy("LICENSE.Apache", src=self.source_subfolder, keep_path=False)
self.copy("LICENSE.leveldb", src=self.source_subfolder, keep_path=False)
self.copy("*.h", dst="include", src=("%s/include" % self.source_subfolder))
self.copy("librocksdb.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = ["rocksdb"]
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")

View File

@ -0,0 +1,12 @@
project(PackageTest CXX)
cmake_minimum_required(VERSION 3.12)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(rocks_sample rocksdb.cpp)
target_link_libraries(rocks_sample CONAN_PKG::rocksdb)
target_link_libraries(rocks_sample CONAN_PKG::gflags)

View File

@ -0,0 +1,28 @@
from conans import ConanFile, CMake
import os
class RocksdbTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
options = {"stdcxx":[11,14], "fPIC":[True, False]}
default_options = "stdcxx=14", "fPIC=True"
generators = "cmake"
def configure(self):
self.options["rocksdb"].stdcxx = self.options.stdcxx
self.options["rocksdb"].fPIC = self.options.fPIC
def build(self):
cmake = CMake(self)
cmake.definitions["CMAKE_CXX_STANDARD"] = self.options["rocksdb"].stdcxx
cmake.definitions["CMAKE_CXX_FLAGS"]="-D_GLIBCXX_USE_CXX11_ABI=%d" %(0 if self.settings.compiler.libcxx == 'libstdc++' else 1)
cmake.configure()
cmake.build()
def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')
def test(self):
os.chdir("bin")
self.run(".%srocks_sample" % os.sep)

View File

@ -0,0 +1,16 @@
#include <cassert>
#include "rocksdb/db.h"
int main()
{
rocksdb::DB * db;
rocksdb::Options options;
options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testrocksdb", &db);
assert(status.ok());
return 0;
}