-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
152 lines (126 loc) · 5.4 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import load
from conan.tools.system.package_manager import Apt
required_conan_version = ">=1.60.0 <2.0 || >=2.0.5"
class superflowRecipe(ConanFile):
name = "superflow"
package_type = "library"
license = "MIT"
author = "FFI"
homepage = "https://github.com/ffi-no/superflow"
url = homepage
description = "An efficient processing framework for modern C++"
topics = ("c++")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"all": [False, True],
"curses": [False, True],
"loader": [False, True],
"yaml": [False, True],
"shared": [False, True],
"tests": [False, True],
}
default_options = {
"all": False,
"shared": False,
"tests": False,
}
exports_sources = (
"CMakeLists.txt",
"LICENSE",
"cmake/*",
"core/*",
"curses/*",
"loader/*",
"yaml/*",
)
def set_version(self):
import re
import os
self.version = re.search(r"project\(\S+ VERSION (\d+(\.\d+){1,3})",
load(self, os.path.join(self.recipe_folder, "CMakeLists.txt"))).group(1).strip()
def validate(self):
if self.settings.os == "Windows" and self.options.curses:
raise ConanInvalidConfiguration("Windows not supported for module 'curses'")
def config_options(self):
pass
def configure(self):
if self.options.all:
self.options.curses = True
self.options.loader = True
self.options.yaml = True
if self.options.loader:
self.options.yaml = True
for lib_name in ['curses', 'loader', 'yaml']:
if not getattr(self.options, lib_name):
setattr(self.options, lib_name, False)
opts = sorted(self.options._package_options._data)
width = len(max(opts, key=len)) + 1
self.output.info("superflow options configured:\n" + "\n".join([f" {o: <{width}}: {str(getattr(self.options, o))}" for o in opts]))
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["BUILD_TESTS"] = self.options.tests
tc.variables["BUILD_all"] = self.options.all
tc.variables["BUILD_curses"] = self.options.curses
tc.variables["BUILD_loader"] = self.options.loader
tc.variables["BUILD_yaml"] = self.options.yaml
tc.generate()
def requirements(self):
if self.options.curses:
self.requires("ncursescpp/1.0.0")
if self.options.loader:
self.requires("boost/1.76.0", transitive_headers=True)
if self.options.yaml:
self.requires("yaml-cpp/0.8.0", transitive_headers=True)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if self.options.tests:
self.run(f"ctest --output-on-failure --output-junit report.xml")
def build_requirements(self):
self.tool_requires("cmake/3.27.4")
def package(self):
cmake = CMake(self)
cmake.install()
def layout(self):
cmake_layout(self)
def package_info(self):
for lib_name in ['core', 'curses', 'loader', 'yaml']:
if lib_name == 'core' or getattr(self.options, lib_name):
self.output.info("adding component '{}'".format(lib_name))
self.cpp_info.components[lib_name].set_property("cmake_target_name", f"{self.name}::{lib_name}")
self.cpp_info.components[lib_name].set_property("cmake_file_name", f"{self.name}-{lib_name}")
self.cpp_info.components[lib_name].libs = ['superflow-' + lib_name]
if lib_name != 'core':
self.cpp_info.components[lib_name].requires.append('core')
if self.settings.os == "Linux":
self.cpp_info.components['core'].system_libs = ["pthread"]
if self.options.curses:
self.cpp_info.components['curses'].requires.append('ncursescpp::ncursescpp')
if self.options.loader:
self.cpp_info.components['loader'].requires.append('boost::boost')
if self.options.yaml:
self.cpp_info.components['loader'].requires.append('yaml')
if self.settings.os == "Linux":
self.cpp_info.components['loader'].system_libs.append('dl')
if self.options.yaml:
self.cpp_info.components['yaml'].requires.append('yaml-cpp::yaml-cpp')
self.cpp_info.components['yaml'].defines = [
'LOADER_ADAPTER_HEADER=\"superflow/yaml/yaml_property_list.h\"',
'LOADER_ADAPTER_NAME=YAML',
'LOADER_ADAPTER_TYPE=flow::yaml::YAMLPropertyList',
]
if self.settings.build_type == "Debug":
for component in self.cpp_info.components.values():
for i, lib in enumerate(component.libs):
component.libs[i] = lib + 'd'
for k, v in self.cpp_info.components.items():
self.output.info("{:<11} -> {}".format("{} libs".format(k), v.libs))
self.output.info("{:<11} -> {}".format("{} requires".format(k), v.requires))