From 3d47a3a27efc6db89e0c466fbfd737aaa983c366 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:17:41 +0200 Subject: [PATCH 01/13] update to metall 0.28 --- conanfile.py | 2 +- src/dice/ffi/metall_internal.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index af396c6..b09b50c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,7 +23,7 @@ class Recipe(ConanFile): generators = "CMakeDeps", "CMakeToolchain" def requirements(self): - self.requires("metall/0.23.1", transitive_headers=True) + self.requires("metall/0.28", transitive_headers=True) self.requires("boost/1.83.0", transitive_headers=True, force=True) if self.options.with_test_deps: diff --git a/src/dice/ffi/metall_internal.hpp b/src/dice/ffi/metall_internal.hpp index 563810b..8074110 100644 --- a/src/dice/ffi/metall_internal.hpp +++ b/src/dice/ffi/metall_internal.hpp @@ -8,7 +8,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::basic_manager; } // namespace #endif//DICE_METALLFFI_METALLINTERNAL_HPP From 657c959d743f7f017c5084e9a460b68732ad1352 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:23:05 +0200 Subject: [PATCH 02/13] version bump --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7439dd9..cf2406c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.22) -project(metall-ffi VERSION 0.2.2) +project(metall-ffi VERSION 0.2.4) include(cmake/boilerplate_init.cmake) boilerplate_init() From a1e03ec0fcd3c02b5f8198ad44ac43e9238b1bde Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:58:44 +0200 Subject: [PATCH 03/13] logger extern c in conan --- CMakeLists.txt | 10 ++++++++++ conanfile.py | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf2406c..fb38248 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,8 @@ if (IS_TOP_LEVEL AND USE_CONAN) install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS};boost:header_only=True") endif () +option(LOGGER_EXTERN_C "Do not define the metall_log function" OFF) + find_package(Metall REQUIRED) add_library(metall-ffi @@ -24,6 +26,14 @@ add_library(metall-ffi add_library(metall-ffi::metall-ffi ALIAS metall-ffi) +if (LOGGER_EXTERN_C) + target_compile_definitions( + metall-ffi + PUBLIC + "METALL_LOGGER_EXTERN_C=1" + ) +endif () + target_include_directories( metall-ffi PUBLIC diff --git a/conanfile.py b/conanfile.py index b09b50c..c5ba54e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -16,8 +16,18 @@ 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], + "logger_extern_c": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_test_deps": False, + "logger_extern_c": False, + } exports = "LICENSE", exports_sources = "src/*", "CMakeLists.txt", "cmake/*" generators = "CMakeDeps", "CMakeToolchain" @@ -44,7 +54,7 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.configure(variables={"USE_CONAN": False}) + self._cmake.configure(variables={"USE_CONAN": False, "LOGGER_EXTERN_C": self.options.logger_extern_c}) return self._cmake From 9cc7d383c6f38c6403c226120e7ff61b6042516c Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:03:00 +0200 Subject: [PATCH 04/13] fix --- conanfile.py | 1 - src/dice/ffi/metall.h | 2 ++ tests/tests_Sanity.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index c5ba54e..e9b2198 100644 --- a/conanfile.py +++ b/conanfile.py @@ -34,7 +34,6 @@ class Recipe(ConanFile): def requirements(self): self.requires("metall/0.28", transitive_headers=True) - self.requires("boost/1.83.0", transitive_headers=True, force=True) if self.options.with_test_deps: self.requires("doctest/2.4.11") diff --git a/src/dice/ffi/metall.h b/src/dice/ffi/metall.h index 8fb232a..b351008 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 diff --git a/tests/tests_Sanity.cpp b/tests/tests_Sanity.cpp index b17393f..4557a5c 100644 --- a/tests/tests_Sanity.cpp +++ b/tests/tests_Sanity.cpp @@ -19,7 +19,7 @@ TEST_SUITE("metall-ffi") { } { - auto *ptr = static_cast(metall_malloc(manager, obj_name, sizeof(size_t))); + auto *ptr = static_cast(metall_malloc(manager, obj_name, sizeof(size_t) * 2)); CHECK_NE(ptr, nullptr); CHECK_EQ(reinterpret_cast(ptr) % alignof(size_t), 0); From 7c8ec685fc7f511c48f9941e44e4800dc3e37690 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:05:02 +0200 Subject: [PATCH 05/13] fix --- conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index e9b2198..59591ba 100644 --- a/conanfile.py +++ b/conanfile.py @@ -73,5 +73,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", ] From 7584cb9509be69ff706516eec410840c8db7afc8 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:30:28 +0200 Subject: [PATCH 06/13] test conan define --- conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conanfile.py b/conanfile.py index 59591ba..f00a9ff 100644 --- a/conanfile.py +++ b/conanfile.py @@ -74,3 +74,8 @@ def package_info(self): self.cpp_info.requires = [ "metall::metall", ] + + if self.options.logger_extern_c: + self.cpp_info.defines = [ + "METALL_LOGGER_EXTERN_C=1" + ] From 3b1b569b3f5453c9c1d22b6c677bb5a8920e4281 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:34:41 +0200 Subject: [PATCH 07/13] always extern logger --- CMakeLists.txt | 10 ---------- conanfile.py | 9 +-------- src/dice/ffi/metall_internal.hpp | 1 + 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb38248..cf2406c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,6 @@ if (IS_TOP_LEVEL AND USE_CONAN) install_packages_via_conan("${CMAKE_SOURCE_DIR}/conanfile.py" "${CONAN_OPTIONS};boost:header_only=True") endif () -option(LOGGER_EXTERN_C "Do not define the metall_log function" OFF) - find_package(Metall REQUIRED) add_library(metall-ffi @@ -26,14 +24,6 @@ add_library(metall-ffi add_library(metall-ffi::metall-ffi ALIAS metall-ffi) -if (LOGGER_EXTERN_C) - target_compile_definitions( - metall-ffi - PUBLIC - "METALL_LOGGER_EXTERN_C=1" - ) -endif () - target_include_directories( metall-ffi PUBLIC diff --git a/conanfile.py b/conanfile.py index f00a9ff..68d36bc 100644 --- a/conanfile.py +++ b/conanfile.py @@ -20,13 +20,11 @@ class Recipe(ConanFile): "shared": [True, False], "fPIC": [True, False], "with_test_deps": [True, False], - "logger_extern_c": [True, False], } default_options = { "shared": False, "fPIC": True, "with_test_deps": False, - "logger_extern_c": False, } exports = "LICENSE", exports_sources = "src/*", "CMakeLists.txt", "cmake/*" @@ -53,7 +51,7 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.configure(variables={"USE_CONAN": False, "LOGGER_EXTERN_C": self.options.logger_extern_c}) + self._cmake.configure(variables={"USE_CONAN": False}) return self._cmake @@ -74,8 +72,3 @@ def package_info(self): self.cpp_info.requires = [ "metall::metall", ] - - if self.options.logger_extern_c: - self.cpp_info.defines = [ - "METALL_LOGGER_EXTERN_C=1" - ] diff --git a/src/dice/ffi/metall_internal.hpp b/src/dice/ffi/metall_internal.hpp index 8074110..1234209 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 { From 2e5014f6b0ae5cb76a9a2164d23db85f07aba630 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:37:18 +0200 Subject: [PATCH 08/13] fix --- test_package/example.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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"); } From fa45c4d81bc4b4fa7a6f5c3dd70799bf36ad1bbc Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:11:03 +0200 Subject: [PATCH 09/13] fix tests --- tests/tests_Sanity.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/tests_Sanity.cpp b/tests/tests_Sanity.cpp index 4557a5c..7c40f76 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"; From 4b435db9c54669392f5f6844844a9dcd1617bbbe Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:07:24 +0200 Subject: [PATCH 10/13] add read only accessor --- src/dice/ffi/metall.cpp | 4 ++++ src/dice/ffi/metall.h | 7 +++++++ 2 files changed, 11 insertions(+) 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 b351008..c84d152 100644 --- a/src/dice/ffi/metall.h +++ b/src/dice/ffi/metall.h @@ -37,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 From 04ba1732d637d2c4620348ce672cd40de99cfb06 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:12:27 +0200 Subject: [PATCH 11/13] update to conan 2 --- .gitignore | 4 +++- CMakeLists.txt | 16 ++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) 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 cf2406c..28d2366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,16 +4,12 @@ project(metall-ffi VERSION 0.2.4) 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) From e4dba6bb4a10d12fb7067a392bcb88e896b12ead Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:14:44 +0200 Subject: [PATCH 12/13] conan version --- .github/workflows/publish-conan-branch-package.yml | 2 +- .github/workflows/publish-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 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 }} From c3ca4e665b268ccd7447fbd133ba179f0de814c5 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:03:15 +0200 Subject: [PATCH 13/13] revert manager to default settings --- src/dice/ffi/metall_internal.hpp | 2 +- tests/tests_Sanity.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dice/ffi/metall_internal.hpp b/src/dice/ffi/metall_internal.hpp index 1234209..d3dcdfc 100644 --- a/src/dice/ffi/metall_internal.hpp +++ b/src/dice/ffi/metall_internal.hpp @@ -9,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/tests/tests_Sanity.cpp b/tests/tests_Sanity.cpp index 7c40f76..ac9394f 100644 --- a/tests/tests_Sanity.cpp +++ b/tests/tests_Sanity.cpp @@ -23,7 +23,7 @@ TEST_SUITE("metall-ffi") { } { - auto *ptr = static_cast(metall_malloc(manager, obj_name, sizeof(size_t) * 2)); + auto *ptr = static_cast(metall_malloc(manager, obj_name, sizeof(size_t))); CHECK_NE(ptr, nullptr); CHECK_EQ(reinterpret_cast(ptr) % alignof(size_t), 0);