Skip to content

Commit

Permalink
feat: add basic rocksdb package
Browse files Browse the repository at this point in the history
fix: url in rocksdb recipe

Update recipes/rocksdb/all/conanfile.py

Co-Authored-By: Uilian Ries <uilianries@gmail.com>

Update recipes/rocksdb/all/conanfile.py

Co-Authored-By: Uilian Ries <uilianries@gmail.com>

Update recipes/rocksdb/all/CMakeLists.txt

Co-Authored-By: Uilian Ries <uilianries@gmail.com>

build: add optional dependencies to rocksdb conanfile

fix: undefined cmake variable in conan file for rocksdb recipe

fix: add missing os import for rocksdb recipe

fix: path to source directory
  • Loading branch information
gocarlos committed Dec 3, 2019
1 parent ca7f1aa commit 03d3556
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 0 deletions.
8 changes: 8 additions & 0 deletions recipes/rocksdb/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.8.12)
PROJECT(conancmakewrapper)

message(STATUS "Conan CMake Wrapper")
include("${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake")
CONAN_BASIC_SETUP()

include("CMakeListsOriginal.cmake")
4 changes: 4 additions & 0 deletions recipes/rocksdb/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"6.4.6":
sha256: 540BBF9369A31E0891FCB4056A36FFA439C59FC179AA0B1F46E3478417F97643
url: https://github.com/facebook/rocksdb/archive/v6.4.6.tar.gz
84 changes: 84 additions & 0 deletions recipes/rocksdb/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from conans import ConanFile, CMake, tools
import os


class RocksDB(ConanFile):
name = "rocksdb"
homepage = "https://github.com/facebook/rocksdb"
license = "GPL-2.0"
url = "https://github.com/conan-io/conan-center-index"
description = "A library that provides an embeddable, persistent key-value store for fast storage"
topics = ("conan", "rocksdb", "database",
"leveldb", "facebook", "key-value")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_gflags": [True, False],
"with_snappy": [True, False],
"with_lz4": [True, False],
"with_zlib": [True, False],
"with_zstd": [True, False]
}
default_options = {
"shared": False,
"fPIC": False,
"with_snappy": False,
"with_lz4": False,
"with_zlib": False,
"with_zstd": False,
"with_gflags": False
}
generators = ["cmake", "cmake_find_package", "cmake_paths"]

@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "rocksdb-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["WITH_TESTS"] = False
cmake.definitions["WITH_GFLAGS"] = self.options.with_gflags
cmake.definitions["WITH_SNAPPY"] = self.options.with_snappy
cmake.definitions["WITH_LZ4"] = self.options.with_lz4
cmake.definitions["WITH_ZLIB"] = self.options.with_zlib
cmake.definitions["WITH_ZSTD"] = self.options.with_zstd
# not available yet in CCI
cmake.definitions["WITH_JEMALLOC"] = False
cmake.configure(source_folder=self._source_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def requirements(self):
if self.options.with_gflags:
self.requires("gflags/2.2.2")
if self.options.with_snappy:
self.requires("snappy/1.1.7")
if self.options.with_lz4:
self.requires("lz4/1.9.2")
if self.options.with_zlib:
self.requires("zlib/1.2.11")
if self.options.with_zstd:
self.requires("zstd/1.3.8")

def package(self):
self.copy(pattern="LICENSE*", dst="licenses",
src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.name = "RocksDB"
self.cpp_info.libs = tools.collect_libs(self)
11 changes: 11 additions & 0 deletions recipes/rocksdb/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/rocksdb/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/rocksdb/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#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, "./testdb", &db);
assert(status.ok());
}
4 changes: 4 additions & 0 deletions recipes/rocksdb/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"6.4.6":
folder: all

0 comments on commit 03d3556

Please sign in to comment.