Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
liss-h authored Nov 14, 2023
2 parents ce8f859 + ca46c9d commit f7e6d2f
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/publish-conan-branch-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
compiler: clang-15
cmake-version: 3.22.6
conan-options: -o boost:header_only=True
conan-version: 2.0.13
conan-options: -o boost/*:header_only=True
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
with:
public_artifactory: true
os: ubuntu-22.04
compiler: clang-14
compiler: clang-15
cmake-version: 3.22.6
conan-version: 1.59
conan-options: -o boost:header_only=True
conan-version: 2.0.13
conan-options: -o boost/*:header_only=True
secrets:
CONAN_USER: ${{ secrets.CONAN_USER }}
CONAN_PW: ${{ secrets.CONAN_PW }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea/
cmake-build*
test_package/build/
test_package/CMakeUserPresets.json
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.17)
project(metall-ffi VERSION 0.2.1)
cmake_minimum_required(VERSION 3.22)
project(metall-ffi VERSION 0.2.2)

include(cmake/boilerplate_init.cmake)
boilerplate_init()
Expand Down
22 changes: 12 additions & 10 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import re

from conan.tools.cmake import CMake

from conan import ConanFile

from conan.tools.cmake import CMake
from conan.tools.files import load, copy, rmdir


Expand All @@ -15,25 +12,23 @@ class Recipe(ConanFile):
author = "https://github.com/dice-group/metall-ffi"
url = "https://github.com/dice-group/metall-ffi"
description = "FFI for the metall libary"
topics = ("FFI", "persistent memory")
topics = "FFI", "persistent memory"

# 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}
exports = "LICENSE",
exports_sources = "src/*", "CMakeLists.txt", "cmake/*"

generators = ("CMakeDeps", "CMakeToolchain")
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires("metall/0.21")
self.requires("boost/1.81.0") # override to fix dependencies
self.requires("metall/0.26", 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")


def set_version(self):
if not hasattr(self, 'version') or self.version is None:
cmake_file = load(self, os.path.join(self.recipe_folder, "CMakeLists.txt"))
Expand Down Expand Up @@ -64,3 +59,10 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["metall-ffi"]
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", self.name)
self.cpp_info.set_property("cmake_target_name", f"{self.name}::{self.name}")
self.cpp_info.requires = [
"metall::metall",
"boost::headers",
]
6 changes: 3 additions & 3 deletions src/dice/ffi/metall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool metall_remove(char const *path) {
}

void *metall_malloc(metall_manager *manager, char const *name, size_t size) {
auto *ptr = reinterpret_cast<metall_manager_t *>(manager)->construct<char>(name)[size]();
auto *ptr = reinterpret_cast<metall_manager_t *>(manager)->construct<unsigned char>(name)[size]();
if (ptr == nullptr) {
errno = ENOMEM;
}
Expand All @@ -69,7 +69,7 @@ void *metall_malloc(metall_manager *manager, char const *name, size_t size) {
}

void *metall_find(metall_manager *manager, char const *name) {
auto *ptr = reinterpret_cast<metall_manager_t *>(manager)->find<char>(name).first;
auto *ptr = reinterpret_cast<metall_manager_t *>(manager)->find<unsigned char>(name).first;
if (ptr == nullptr) {
errno = ENOENT;
}
Expand All @@ -78,7 +78,7 @@ void *metall_find(metall_manager *manager, char const *name) {
}

bool metall_free(metall_manager *manager, char const *name) {
auto const res = reinterpret_cast<metall_manager_t *>(manager)->destroy<char>(name);
auto const res = reinterpret_cast<metall_manager_t *>(manager)->destroy<unsigned char>(name);
if (!res) {
errno = ENOENT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dice/ffi/metall_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t, (1ULL << 28ULL)>;
using metall_manager = metall::basic_manager<uint32_t>;
} // namespace

#endif//DICE_METALLFFI_METALLINTERNAL_HPP
17 changes: 17 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

find_package(metall-ffi REQUIRED)

add_executable(example example.cpp)

target_link_libraries(example PUBLIC
metall-ffi::metall-ffi
)

set_target_properties(
example PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
27 changes: 27 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout

required_conan_version = ">=1.59"


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

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):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
5 changes: 5 additions & 0 deletions test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <dice/ffi/metall.h>

int main() {
metall_open("/tmp/test");
}
2 changes: 1 addition & 1 deletion tests/tests_Sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
TEST_SUITE("metall-ffi") {
TEST_CASE("sanity check") {
char const *obj_name = "obj";
std::string const path = "/tmp/" + std::to_string(std::random_device{}());
std::string const path = "/tmp/metall-ffi" + std::to_string(std::random_device{}());
std::string const snap_path = path + "-snap";

{
Expand Down

0 comments on commit f7e6d2f

Please sign in to comment.