mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-05-10 04:20:47 +00:00
parlayhash: add new new recipe (#22638)
* ParlayHash: new recipe * fix linting * Update recipes/parlay_hash/all/conanfile.py Co-authored-by: toge <toge.mail@gmail.com> * fix * fix test_package * Update recipes/parlay_hash/all/test_package/test_package.cpp Co-authored-by: toge <toge.mail@gmail.com> * Update recipes/parlay_hash/all/conanfile.py Co-authored-by: toge <toge.mail@gmail.com> * WOrk for v0.1 * remove temp files * fix * Follow upstream target names * Typo * Cleanups and support specific macos version, remove msvc support * Skip Linux Clang as well Signed-off-by: Uilian Ries <uilianries@gmail.com> --------- Signed-off-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: toge <toge.mail@gmail.com> Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es> Co-authored-by: Uilian Ries <uilianries@gmail.com>
This commit is contained in:

committed by
GitHub

parent
ddf20d53f7
commit
6cdc34101b
4
recipes/parlayhash/all/conandata.yml
Normal file
4
recipes/parlayhash/all/conandata.yml
Normal file
@ -0,0 +1,4 @@
|
||||
sources:
|
||||
"0.1":
|
||||
url: "https://github.com/cmuparlay/parlayhash/archive/refs/tags/v0.1.tar.gz"
|
||||
sha256: "63dd2680de0291c8c4440fc3364490de0ee3cdea94b02b7449900bac18d66f2f"
|
60
recipes/parlayhash/all/conanfile.py
Normal file
60
recipes/parlayhash/all/conanfile.py
Normal file
@ -0,0 +1,60 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.files import get, copy
|
||||
from conan.tools.build import check_min_cppstd, check_max_cppstd
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
|
||||
required_conan_version = ">=2.1"
|
||||
|
||||
|
||||
class ParlayHashConan(ConanFile):
|
||||
name = "parlayhash"
|
||||
description = "A Header-Only Scalable Concurrent Hash Map."
|
||||
license = "MIT"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/cmuparlay/parlayhash"
|
||||
topics = ("unordered_map", "hashmap", "header-only")
|
||||
package_type = "header-library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
no_copy_source = True
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def package_id(self):
|
||||
self.info.clear()
|
||||
|
||||
def validate(self):
|
||||
check_min_cppstd(self, 17)
|
||||
if self.settings.compiler in ["apple-clang", "clang"]:
|
||||
if Version(self.settings.compiler.version) < "15":
|
||||
# error: reference to local binding 'tag' declared in enclosing function 'parlay::parlay_hash::Find'
|
||||
raise ConanInvalidConfiguration(f"Can't be used with {self.settings.compiler} < 15, lacks proper C++17 support")
|
||||
else:
|
||||
# error: no type named 'result_of' in namespace 'std'
|
||||
check_max_cppstd(self, 17)
|
||||
if self.settings.compiler == "msvc":
|
||||
# error C3861: '__builtin_prefetch': identifier not found
|
||||
raise ConanInvalidConfiguration("Can't be used with msvc")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def build(self):
|
||||
pass
|
||||
|
||||
def package(self):
|
||||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
|
||||
copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"), excludes=[".#hash_table.h"])
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.bindirs = []
|
||||
self.cpp_info.libdirs = []
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("pthread")
|
||||
|
||||
# This one is a best-effort guess, as the library is header-only it does not mention a target explicitly
|
||||
self.cpp_info.set_property("cmake_file_name", "parlayhash")
|
||||
self.cpp_info.set_property("cmake_target_name", "parlay")
|
9
recipes/parlayhash/all/test_package/CMakeLists.txt
Normal file
9
recipes/parlayhash/all/test_package/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(test_package LANGUAGES CXX)
|
||||
|
||||
find_package(parlayhash REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE parlay)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
|
26
recipes/parlayhash/all/test_package/conanfile.py
Normal file
26
recipes/parlayhash/all/test_package/conanfile.py
Normal file
@ -0,0 +1,26 @@
|
||||
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 = "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)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
24
recipes/parlayhash/all/test_package/test_package.cpp
Normal file
24
recipes/parlayhash/all/test_package/test_package.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <parlay/parallel.h>
|
||||
#include "parlay_hash/unordered_map.h"
|
||||
|
||||
using K = std::string;
|
||||
using V = unsigned long;
|
||||
using map_type = parlay::parlay_unordered_map<K,V>;
|
||||
|
||||
int main() {
|
||||
map_type my_map(100);
|
||||
my_map.Insert("sue", 1);
|
||||
my_map.Insert("sam", 5);
|
||||
|
||||
std::cout << "value before increment: " << *my_map.Find("sue") << std::endl;
|
||||
auto increment = [] (std::optional<V> v) -> V {return v.has_value() ? 1 + *v : 1;};
|
||||
my_map.Upsert("sue", increment);
|
||||
std::cout << "value after increment: " << *my_map.Find("sue") << std::endl;
|
||||
|
||||
std::cout << "size before remove: " << my_map.size() << std::endl;
|
||||
my_map.Remove("sue");
|
||||
std::cout << "size after remove: " << my_map.size() << std::endl;
|
||||
return 0;
|
||||
}
|
3
recipes/parlayhash/config.yml
Normal file
3
recipes/parlayhash/config.yml
Normal file
@ -0,0 +1,3 @@
|
||||
versions:
|
||||
"0.1":
|
||||
folder: all
|
Reference in New Issue
Block a user