From 2b2d4c954bb6931b04d5841022dbcc86cc3a4e82 Mon Sep 17 00:00:00 2001 From: toge Date: Sat, 4 Feb 2023 08:18:05 +0900 Subject: [PATCH] (#15646) objectbox: add version 0.18.1, support conan v2 * objectbox: add version 0.18.1, support conan v2 * link pthread * remove unused import * link dl since 0.18.0 --- recipes/objectbox/all/CMakeLists.txt | 7 --- recipes/objectbox/all/conandata.yml | 13 ++++- recipes/objectbox/all/conanfile.py | 52 ++++++++----------- .../objectbox/all/test_package/CMakeLists.txt | 7 +-- .../objectbox/all/test_package/conanfile.py | 20 ++++--- .../all/test_v1_package/CMakeLists.txt | 8 +++ .../all/test_v1_package/conanfile.py | 17 ++++++ recipes/objectbox/config.yml | 2 + 8 files changed, 76 insertions(+), 50 deletions(-) delete mode 100644 recipes/objectbox/all/CMakeLists.txt create mode 100644 recipes/objectbox/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/objectbox/all/test_v1_package/conanfile.py diff --git a/recipes/objectbox/all/CMakeLists.txt b/recipes/objectbox/all/CMakeLists.txt deleted file mode 100644 index 46490d668b7230..00000000000000 --- a/recipes/objectbox/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper C) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(source_subfolder) diff --git a/recipes/objectbox/all/conandata.yml b/recipes/objectbox/all/conandata.yml index c17f9834922b31..af3abbeb889483 100644 --- a/recipes/objectbox/all/conandata.yml +++ b/recipes/objectbox/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.18.1": + url: "https://github.com/objectbox/objectbox-c/archive/v0.18.1.tar.gz" + sha256: "108ac7fac843f2962374a12b361bb57b4d114013d16f7716cfedbc7df52feb2e" "0.18.0": url: "https://github.com/objectbox/objectbox-c/archive/v0.18.0.tar.gz" sha256: "e86e921d59c6c36a4a0c0ddc5a2b641789bfa012e0824506c285feb4e9285ae7" @@ -7,9 +10,15 @@ sources: sha256: "3b936b3352ae0c8ea3706cc0a1790d2714a415cdce16007c2caca367ead5af8d" patches: + "0.18.1": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "add sync option, disable tests/examples, support max length of windows path" + patch_type: "conan" "0.18.0": - patch_file: "patches/0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "add sync option, disable tests/examples, support max length of windows path" + patch_type: "conan" "0.17.0": - patch_file: "patches/0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "add sync option, disable tests/examples, support max length of windows path" + patch_type: "conan" diff --git a/recipes/objectbox/all/conanfile.py b/recipes/objectbox/all/conanfile.py index e14e7b0b2f9b4c..c5710cc60873cd 100644 --- a/recipes/objectbox/all/conanfile.py +++ b/recipes/objectbox/all/conanfile.py @@ -1,7 +1,10 @@ -from conans import CMake, ConanFile, tools -import functools +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.scm import Version +import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class ObjectboxCConan(ConanFile): name = "objectbox" @@ -17,46 +20,37 @@ class ObjectboxCConan(ConanFile): default_options = { "with_sync": False, } - generators = "cmake", - - @property - def _source_subfolder(self): - return "source_subfolder" def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + export_conandata_patches(self) - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["OBJECTBOX_WITH_SYNC"] = self.options.with_sync - cmake.configure() - return cmake + def generate(self): + # BUILD_SHARED_LIBS and POSITION_INDEPENDENT_CODE are automatically parsed when self.options.shared or self.options.fPIC exist + tc = CMakeToolchain(self) + tc.variables["OBJECTBOX_WITH_SYNC"] = self.options.with_sync + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = ["objectbox"] if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.append("m") - + self.cpp_info.system_libs.extend(["m", "pthread"]) + if Version(self.version) >= "0.18.0": + self.cpp_info.system_libs.append("dl") diff --git a/recipes/objectbox/all/test_package/CMakeLists.txt b/recipes/objectbox/all/test_package/CMakeLists.txt index 6b823b4c18ea10..8ef573610ef449 100644 --- a/recipes/objectbox/all/test_package/CMakeLists.txt +++ b/recipes/objectbox/all/test_package/CMakeLists.txt @@ -1,12 +1,7 @@ cmake_minimum_required(VERSION 3.1) - project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - -conan_basic_setup(TARGETS) - find_package(objectbox REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} objectbox::objectbox) +target_link_libraries(${PROJECT_NAME} PRIVATE objectbox::objectbox) diff --git a/recipes/objectbox/all/test_package/conanfile.py b/recipes/objectbox/all/test_package/conanfile.py index 38f4483872d47f..a9fbb7f5431620 100644 --- a/recipes/objectbox/all/test_package/conanfile.py +++ b/recipes/objectbox/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +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 = "cmake", "cmake_find_package_multi" + 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) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/objectbox/all/test_v1_package/CMakeLists.txt b/recipes/objectbox/all/test_v1_package/CMakeLists.txt new file mode 100644 index 00000000000000..be00a8c7f57c71 --- /dev/null +++ b/recipes/objectbox/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/objectbox/all/test_v1_package/conanfile.py b/recipes/objectbox/all/test_v1_package/conanfile.py new file mode 100644 index 00000000000000..20d4d2e28d57e0 --- /dev/null +++ b/recipes/objectbox/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/objectbox/config.yml b/recipes/objectbox/config.yml index 5bf98d20ca9eb8..f2cc4d23dcbd0c 100644 --- a/recipes/objectbox/config.yml +++ b/recipes/objectbox/config.yml @@ -1,4 +1,6 @@ versions: + "0.18.1": + folder: all "0.18.0": folder: all "0.17.0":