From 4c23b9a0bece59928af5b9c6bc5434d1a5863d90 Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 1 Nov 2024 04:14:57 +0900 Subject: [PATCH] (#25704) crossdb: add recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * crossdb: add recipe * drop MSVC support * simplify test_package.c * Update recipes/crossdb/all/conanfile.py * make rpath on macOS * Simplify test package * Avoid emojis in the recipe. * Use fix_apple_shared_install_name to fix rpath * Do not enforce CMAKE_MACOSX_RPATH * Import fix_apple_shared_install_name --------- Co-authored-by: Abril Rincón Blanco Co-authored-by: Uilian Ries --- recipes/crossdb/all/conandata.yml | 4 ++ recipes/crossdb/all/conanfile.py | 51 +++++++++++++++++++ .../crossdb/all/test_package/CMakeLists.txt | 7 +++ recipes/crossdb/all/test_package/conanfile.py | 26 ++++++++++ .../crossdb/all/test_package/test_package.c | 9 ++++ recipes/crossdb/config.yml | 3 ++ 6 files changed, 100 insertions(+) create mode 100644 recipes/crossdb/all/conandata.yml create mode 100644 recipes/crossdb/all/conanfile.py create mode 100644 recipes/crossdb/all/test_package/CMakeLists.txt create mode 100644 recipes/crossdb/all/test_package/conanfile.py create mode 100644 recipes/crossdb/all/test_package/test_package.c create mode 100644 recipes/crossdb/config.yml diff --git a/recipes/crossdb/all/conandata.yml b/recipes/crossdb/all/conandata.yml new file mode 100644 index 00000000000000..3b88555a25f068 --- /dev/null +++ b/recipes/crossdb/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.9.0": + url: "https://github.com/crossdb-org/crossdb/archive/refs/tags/0.9.0.tar.gz" + sha256: "04defc43f0b5102cc6a341ba9e328302416982c04cc4c59bc16aef19cc1b020c" diff --git a/recipes/crossdb/all/conanfile.py b/recipes/crossdb/all/conanfile.py new file mode 100644 index 00000000000000..17c406248c117a --- /dev/null +++ b/recipes/crossdb/all/conanfile.py @@ -0,0 +1,51 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.microsoft import is_msvc +from conan.tools.apple import fix_apple_shared_install_name +import os + +required_conan_version = ">=1.53.0" + +class CrossDBConan(ConanFile): + name = "crossdb" + description = "Ultra High-performance Lightweight Embedded and Server OLTP RDBMS" + license = "MPL-2.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/crossdb-org/crossdb" + topics = ("database", "oltp", "embedded") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + + def configure(self): + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"${self.ref} does not support MSVC") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.libs = ["crossdb"] diff --git a/recipes/crossdb/all/test_package/CMakeLists.txt b/recipes/crossdb/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..f725ff69c516e3 --- /dev/null +++ b/recipes/crossdb/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(crossdb REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE crossdb::crossdb) diff --git a/recipes/crossdb/all/test_package/conanfile.py b/recipes/crossdb/all/test_package/conanfile.py new file mode 100644 index 00000000000000..ef5d7042163ecc --- /dev/null +++ b/recipes/crossdb/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/crossdb/all/test_package/test_package.c b/recipes/crossdb/all/test_package/test_package.c new file mode 100644 index 00000000000000..37adfa21e30917 --- /dev/null +++ b/recipes/crossdb/all/test_package/test_package.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +int main () { + printf("Cross DB Version: %s\n", xdb_version()); + return EXIT_SUCCESS; +} diff --git a/recipes/crossdb/config.yml b/recipes/crossdb/config.yml new file mode 100644 index 00000000000000..7dbf8a1dbf4a84 --- /dev/null +++ b/recipes/crossdb/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.0": + folder: all