diff --git a/RocksDB/build.py b/RocksDB/build.py new file mode 100755 index 0000000..3928b97 --- /dev/null +++ b/RocksDB/build.py @@ -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() diff --git a/RocksDB/conanfile.py b/RocksDB/conanfile.py new file mode 100644 index 0000000..54ea100 --- /dev/null +++ b/RocksDB/conanfile.py @@ -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") diff --git a/RocksDB/test_package/CMakeLists.txt b/RocksDB/test_package/CMakeLists.txt new file mode 100644 index 0000000..0ec1548 --- /dev/null +++ b/RocksDB/test_package/CMakeLists.txt @@ -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) diff --git a/RocksDB/test_package/conanfile.py b/RocksDB/test_package/conanfile.py new file mode 100644 index 0000000..bbbe275 --- /dev/null +++ b/RocksDB/test_package/conanfile.py @@ -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) diff --git a/RocksDB/test_package/rocksdb.cpp b/RocksDB/test_package/rocksdb.cpp new file mode 100644 index 0000000..990df8e --- /dev/null +++ b/RocksDB/test_package/rocksdb.cpp @@ -0,0 +1,16 @@ +#include +#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; +}