Skip to content

Commit

Permalink
Update to metall 0.28 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
liss-h authored Aug 7, 2024
1 parent cb7caa9 commit f41f481
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-conan-branch-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea/
cmake-build*
test_package/build/
test_package/CMakeUserPresets.json
test_package/CMakeUserPresets.json
conan_provider.cmake
CMakeUserPresets.json
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
]
4 changes: 4 additions & 0 deletions src/dice/ffi/metall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ metall_manager *metall_create(char const *path) {
return reinterpret_cast<metall_manager *>(manager);
}

bool metall_is_read_only(metall_manager const *manager) {
return reinterpret_cast<metall_manager_t const *>(manager)->read_only();
}

bool metall_snapshot(metall_manager *manager, char const *dst_path) {
return reinterpret_cast<metall_manager_t *>(manager)->snapshot(dst_path);
}
Expand Down
9 changes: 9 additions & 0 deletions src/dice/ffi/metall.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdbool.h>
#include <stddef.h>

#include <metall/logger_interface.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/dice/ffi/metall_internal.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#ifndef DICE_METALLFFI_METALLINTERNAL_HPP
#define DICE_METALLFFI_METALLINTERNAL_HPP

#define METALL_LOGGER_EXTERN_C 1
#include <metall/metall.hpp>

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<uint32_t, 1ULL << 28>;
using metall_manager = metall::manager;
} // namespace

#endif//DICE_METALLFFI_METALLINTERNAL_HPP
4 changes: 4 additions & 0 deletions test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <dice/ffi/metall.h>

extern "C" void metall_log(metall_log_level, char const *, size_t, char const *) {
// noop
}

int main() {
metall_open("/tmp/test");
}
4 changes: 4 additions & 0 deletions tests/tests_Sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <string>
#include <random>

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";
Expand Down

0 comments on commit f41f481

Please sign in to comment.