-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconanfile.py
More file actions
114 lines (96 loc) · 3.96 KB
/
conanfile.py
File metadata and controls
114 lines (96 loc) · 3.96 KB
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
# Copyright 2026 Madeline Schneider and the libhal contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain, CMakeDeps
from conan.tools.files import copy
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from pathlib import Path
required_conan_version = ">=2.2.0"
class scatter_span_conan(ConanFile):
name = "scatter-span"
license = "Apache-2.0"
homepage = "https://github.com/libhal/scatter-span"
description = ("A data structure library for housing arrays of unowned data.")
topics = ("span", "scatter", "data-structures", "non-owning", "view")
settings = "compiler", "build_type", "os", "arch"
exports_sources = "modules/*", "tests/*", "CMakeLists.txt", "LICENSE"
package_type = "static-library"
shared = False
@property
def _min_cppstd(self):
return "23"
@property
def _compilers_minimum_version(self):
return {
"gcc": ("14", "GCC 14+ required for scatter-span"),
"clang": ("19", "Clang 19+ required for scatter-span"),
"apple-clang": ("19.0.0", "Apple Clang 19+ for scatter-span"),
"msvc": ("193.4", "MSVC 14.34+ (Visual Studio 17.4+) for scatter-span"),
}
def _validate_compiler_version(self):
compiler = str(self.settings.compiler)
version = str(self.settings.compiler.version)
compiler_key = "msvc" if compiler == "Visual Studio" else compiler
min_versions = self._compilers_minimum_version
if compiler_key not in min_versions:
raise ConanInvalidConfiguration(
f"Compiler {compiler} is not supported for C++20 modules")
min_version, error_msg = min_versions[compiler_key]
if Version(version) < min_version:
raise ConanInvalidConfiguration(error_msg)
def set_version(self):
if not self.version:
self.version = "latest"
def validate(self):
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, self._min_cppstd)
self._validate_compiler_version()
def build_requirements(self):
self.tool_requires("cmake/[^4.0.0]")
self.tool_requires("ninja/[^1.3.0]")
self.test_requires("boost-ext-ut/2.3.1")
self.tool_requires("libhal-cmake-util/[^5.0.5]")
def requirements(self):
pass
def layout(self):
build_path = Path("build") / (
str(self.settings.arch) + "-" +
str(self.settings.os) + "-" +
str(self.settings.compiler) + "-" +
str(self.settings.compiler.version)
)
cmake_layout(self, build_folder=str(build_path))
def generate(self):
tc = CMakeToolchain(self)
tc.generator = "Ninja"
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if not self.conf.get("tools.build:skip_test", default=False):
cmake.ctest(["--output-on-failure"])
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "LICENSE",
dst=Path(self.package_folder) / "licenses",
src=self.source_folder)
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs.append("lib/cmake")