-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathconanfile.py
101 lines (79 loc) · 2.97 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import re
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.build.cppstd import check_min_cppstd
def read_version():
try:
with open("./include/libfork/core/macro.hpp", "r") as file:
raw = file.read()
regex = "#define [A-Z_0-9]*{} ([0-9]*)"
major = re.search(regex.format("VERSION_MAJOR"), raw)
minor = re.search(regex.format("VERSION_MINOR"), raw)
patch = re.search(regex.format("VERSION_PATCH"), raw)
return f"{major.group(1)}.{minor.group(1)}.{patch.group(1)}"
except Exception as e:
# Post export this will fail as the file is not present.
return None
class libfork(ConanFile):
# Mandatory fields
name = "libfork"
version = read_version()
package_type = "header-library"
# Optional metadata
license = "MPL-2.0"
author = "C. J. Williams"
homepage = "https://github.com/ConorWilliams/libfork"
url = homepage
description = "A bleeding-edge, lock-free, wait-free, continuation-stealing fork-join library built on C++20's coroutines."
topics = (
"multithreading",
"fork-join",
"parallelism",
"coroutine",
"continuation-stealing",
"lock-free",
"wait-free",
)
settings = "os", "compiler", "build_type", "arch"
# Optimization for header only libs.
no_copy_source = True
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "include/**", "cmake/*", "LICENSE.md"
def validate(self):
# We need coroutine support.
check_min_cppstd(self, "20")
def build_requirements(self):
# Some traits like build=True, etc.. will be automatically inferred.
self.tool_requires("cmake/3.28.1")
# Optional dependencies that boost performance.
self.requires("hwloc/2.9.3")
def layout(self):
cmake_layout(self)
# Mimic the packageConfig files written by the library.
# For header-only packages, libdirs and bindirs are not used.
# so it's necessary to set those as empty.
self.cpp.package.includedirs = [f"include/libfork-{self.version}"]
self.cpp.package.bindirs = []
self.cpp.package.libdirs = []
# By default, this package will be exported as libfork::libfork
def generate(self):
deps = CMakeDeps(self)
deps.generate()
# Generate build system.
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
# Because this is a header-only library.
def package_id(self):
self.info.clear()
def package_info(self):
# Let libfork know about the optional dependencies.
self.cpp_info.defines = [
"LF_USE_HWLOC",
]