From abd2aa13d8a1aa00cf3ef970260128f7e9c807cf Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:22:01 +0200 Subject: [PATCH] Update: metall 0.28 (#13) --- .../workflows/publish-conan-branch-package.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .gitignore | 4 +++- CMakeLists.txt | 16 ++++++---------- conanfile.py | 16 +++++++++++----- src/dice/ffi/metall.cpp | 4 ++++ src/dice/ffi/metall.h | 9 +++++++++ src/dice/ffi/metall_internal.hpp | 3 ++- test_package/example.cpp | 4 ++++ tests/tests_Sanity.cpp | 4 ++++ 10 files changed, 45 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish-conan-branch-package.yml b/.github/workflows/publish-conan-branch-package.yml index 10966d1..ad5a309 100644 --- a/.github/workflows/publish-conan-branch-package.yml +++ b/.github/workflows/publish-conan-branch-package.yml @@ -13,7 +13,7 @@ jobs: os: ubuntu-22.04 compiler: clang-15 cmake-version: 3.22.6 - conan-version: 2.0.13 + conan-version: 2.3.0 conan-options: -o boost/*:header_only=True secrets: CONAN_USER: ${{ secrets.CONAN_USER }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 3773eaa..b7ce28c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,7 +19,7 @@ jobs: os: ubuntu-22.04 compiler: clang-15 cmake-version: 3.22.6 - conan-version: 2.0.13 + conan-version: 2.3.0 conan-options: -o boost/*:header_only=True secrets: CONAN_USER: ${{ secrets.CONAN_USER }} diff --git a/.gitignore b/.gitignore index b3ee570..c9222b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea/ cmake-build* test_package/build/ -test_package/CMakeUserPresets.json \ No newline at end of file +test_package/CMakeUserPresets.json +conan_provider.cmake +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index c7fc8d1..7c36a49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,16 +4,12 @@ project(metall-ffi VERSION 0.2.3) include(cmake/boilerplate_init.cmake) boilerplate_init() -OPTION(USE_CONAN "If available, use conan to retrieve dependencies." ON) -if (IS_TOP_LEVEL AND USE_CONAN) - include(cmake/conan_cmake.cmake) - if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING) - set(CONAN_HYPERTRIE_WITH_TEST_DEPS "True") - else() - set(CONAN_HYPERTRIE_WITH_TEST_DEPS "False") - endif() - set(CONAN_OPTIONS "with_test_deps=${CONAN_HYPERTRIE_WITH_TEST_DEPS}") - install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS};boost:header_only=True") +if (PROJECT_IS_TOP_LEVEL) + set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=boost/*:header_only=True") + + if (BUILD_TESTING) + set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=&:with_test_deps=True") + endif () endif () find_package(Metall REQUIRED) diff --git a/conanfile.py b/conanfile.py index af396c6..68d36bc 100644 --- a/conanfile.py +++ b/conanfile.py @@ -16,15 +16,22 @@ class Recipe(ConanFile): # Binary configuration settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False], "with_test_deps": [True, False]} - default_options = {"shared": False, "fPIC": True, "with_test_deps": False} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_test_deps": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_test_deps": False, + } exports = "LICENSE", exports_sources = "src/*", "CMakeLists.txt", "cmake/*" generators = "CMakeDeps", "CMakeToolchain" def requirements(self): - self.requires("metall/0.23.1", transitive_headers=True) - self.requires("boost/1.83.0", transitive_headers=True, force=True) + self.requires("metall/0.28", transitive_headers=True) if self.options.with_test_deps: self.requires("doctest/2.4.11") @@ -64,5 +71,4 @@ def package_info(self): self.cpp_info.set_property("cmake_target_name", f"{self.name}::{self.name}") self.cpp_info.requires = [ "metall::metall", - "boost::headers", ] diff --git a/src/dice/ffi/metall.cpp b/src/dice/ffi/metall.cpp index 4261058..cb8edcb 100644 --- a/src/dice/ffi/metall.cpp +++ b/src/dice/ffi/metall.cpp @@ -47,6 +47,10 @@ metall_manager *metall_create(char const *path) { return reinterpret_cast(manager); } +bool metall_is_read_only(metall_manager const *manager) { + return reinterpret_cast(manager)->read_only(); +} + bool metall_snapshot(metall_manager *manager, char const *dst_path) { return reinterpret_cast(manager)->snapshot(dst_path); } diff --git a/src/dice/ffi/metall.h b/src/dice/ffi/metall.h index 8fb232a..c84d152 100644 --- a/src/dice/ffi/metall.h +++ b/src/dice/ffi/metall.h @@ -4,6 +4,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -35,6 +37,13 @@ metall_manager *metall_open_read_only(char const *path); */ metall_manager *metall_create(char const *path); +/** + * @brief Returns true if the metall manager was opened as read-only + * @param manager manager to check + * @return true if the given manager was openened as read-only + */ +bool metall_is_read_only(metall_manager const *manager); + /** * @brief Creates a snapshot of the metall datastore of manager and places it at dst_path * @param manager manager to perform snapshot diff --git a/src/dice/ffi/metall_internal.hpp b/src/dice/ffi/metall_internal.hpp index 563810b..d3dcdfc 100644 --- a/src/dice/ffi/metall_internal.hpp +++ b/src/dice/ffi/metall_internal.hpp @@ -1,6 +1,7 @@ #ifndef DICE_METALLFFI_METALLINTERNAL_HPP #define DICE_METALLFFI_METALLINTERNAL_HPP +#define METALL_LOGGER_EXTERN_C 1 #include namespace dice::metall_ffi::internal { @@ -8,7 +9,7 @@ namespace dice::metall_ffi::internal { * @brief The metall manager type used internally. * This object type is whats actually behind the opaque ::metall_manager * in the interface */ - using metall_manager = metall::basic_manager; + using metall_manager = metall::manager; } // namespace #endif//DICE_METALLFFI_METALLINTERNAL_HPP diff --git a/test_package/example.cpp b/test_package/example.cpp index 20f6b9b..9d06265 100644 --- a/test_package/example.cpp +++ b/test_package/example.cpp @@ -1,5 +1,9 @@ #include +extern "C" void metall_log(metall_log_level, char const *, size_t, char const *) { + // noop +} + int main() { metall_open("/tmp/test"); } diff --git a/tests/tests_Sanity.cpp b/tests/tests_Sanity.cpp index b17393f..ac9394f 100644 --- a/tests/tests_Sanity.cpp +++ b/tests/tests_Sanity.cpp @@ -6,6 +6,10 @@ #include #include +extern "C" void metall_log(metall_log_level lvl, char const *file, size_t line, char const *msg) { + std::cerr << lvl << " " << file << ":" << line << ": " << msg << std::endl; +} + TEST_SUITE("metall-ffi") { TEST_CASE("sanity check") { char const *obj_name = "obj";