6
0
mirror of https://github.com/Minres/conan-recipes.git synced 2024-12-23 00:38:04 +01:00

Added LevelDB package

This commit is contained in:
Eyck Jentzsch 2018-10-30 17:29:48 +01:00
parent f5b39e0678
commit a7a465e69c
6 changed files with 126 additions and 0 deletions

10
LevelDB/build.py Normal file
View File

@ -0,0 +1,10 @@
from conan.packager import ConanMultiPackager
if __name__ == "__main__":
builder = ConanMultiPackager()
libstd = ['libstdc++11']
types = ['Debug','Release']
configs = [[i,k] for i in libstd for k in types]
for triple in configs:
builder.add(settings={"build_type":triple[1], "compiler.libcxx":triple[0]}, options={}, env_vars={}, build_requires={})
builder.run()

63
LevelDB/conanfile.py Normal file
View File

@ -0,0 +1,63 @@
from conans import ConanFile, CMake, tools
import os
class LevelDBConan(ConanFile):
name = "LevelDB"
version = "1.20"
license = "https://github.com/google/leveldb/blob/master/LICENSE"
url = "https://github.com/Minres/conan-recipes/LevelDB"
use_master = True
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = "shared=True"
generators = "cmake"
exports_sources = "leveldb/*"
@property
def source_subfolder(self):
if self.use_master:
return "leveldb-master"
else:
return "leveldb-%s" % self.version
@property
def download_url(self):
if self.use_master:
return "https://github.com/google/leveldb/archive/master.zip"
else:
return "https://github.com/google/leveldb/archive/v%s.zip" % self.version
def source(self):
tools.download(self.download_url, "leveldb.zip")
tools.unzip("leveldb.zip")
# self.run("git clone https://github.com/google/leveldb.git %s" % self.source_subfolder)
def build(self):
cmake = CMake(self, parallel=True)
cmake.configure(
source_folder=self.source_subfolder,
args=[
"-DBUILD_SHARED_LIBS=ON" if self.options.shared else "-DBUILD_SHARED_LIBS=OFF",
"-DCMAKE_INSTALL_LIBDIR=lib"
]
)
cmake.build()
cmake.install()
# def package(self):
# self.copy("*", dst="include", src="%s/include" % self.zipped_folder, keep_path=True)
# self.copy("*.lib", dst="lib", keep_path=False)
# self.copy("LICENSE", src=self.zipped_folder, dst="", keep_path=False)
# if self.options.shared:
# self.copy("*.dll", dst="bin", keep_path=False)
# self.copy("*.so*", dst="lib", keep_path=False)
# else:
# self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = ["leveldb"]
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")

View File

@ -0,0 +1,8 @@
PROJECT(PackageTest)
cmake_minimum_required(VERSION 2.8.12)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
ADD_EXECUTABLE(example example.cpp)
TARGET_LINK_LIBRARIES(example ${CONAN_LIBS})

View File

@ -0,0 +1,31 @@
from conans import ConanFile, CMake
import os
channel = os.getenv("CONAN_CHANNEL", "stable")
username = os.getenv("CONAN_USERNAME", "minres")
class LeveldbTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = "shared=True"
requires = "LevelDB/1.20@%s/%s" % (username, channel)
generators = "cmake"
def configure(self):
self.options["LevelDB"].shared = self.options.shared
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def imports(self):
self.copy("*.dll", "bin", "bin")
self.copy("*.so", "lib", "bin")
self.copy("*.dylib", "lib", "bin")
def test(self):
os.chdir("bin")
self.run("LD_LIBRARY_PATH=$(pwd) && .%sexample" % os.sep)

View File

@ -0,0 +1,13 @@
#include "leveldb/db.h"
int main() {
leveldb::DB* db;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
if(status.ok()){
return 0;
}
return -1;
}

View File

@ -28,6 +28,7 @@ class SystemcverificationConan(ConanFile):
env_build.cxx_flags = "-std=gnu++98"
env_build.fpic = True
tools.mkdir("build")
env_build.libs.remove('systemc')
with tools.chdir("build"):
env_build.configure(
configure_dir=os.path.join(self.source_folder, self.source_subfolder),