Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stlab: several fixes #21274

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
78 changes: 40 additions & 38 deletions recipes/stlab/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from conan.tools.build import check_min_cppstd, cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.scm import Version

required_conan_version = ">=1.52.0"
Expand All @@ -29,7 +28,7 @@ class Stlab(ConanFile):
default_options = {
"with_boost": False,
"no_std_coroutines": True,
"future_coroutines": False
"future_coroutines": False,
# Handle default value for `thread_system` in `config_options` method
# Handle default value for `task_system` in `config_options` method
}
Expand All @@ -50,27 +49,39 @@ def _minimum_cpp_standard(self):

@property
def _compilers_minimum_version(self):
return {"gcc": "9",
"clang": "8",
"apple-clang": "13"}
return {
"gcc": "9",
"clang": "8",
"apple-clang": "13",
"msvc": "192",
"Visual Studio": "16",
}

def layout(self):
cmake_layout(self, src_folder="src")

def build_requirements(self):
self.tool_requires("cmake/[>=3.23.3]")

def requirements(self):
if self.options.with_boost:
self.requires("boost/1.82.0")
self.requires("boost/1.83.0")

# On macOS, it is not necessary to use the libdispatch conan package, because the library is
# included in the OS.
if self.options.task_system == "libdispatch" and self.settings.os != "Macos":
self.requires("libdispatch/5.3.2")

def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
def package_id(self):
# TODO: stlab is header only but needs a header modified by cmake based on OS and options
# (and also threading model which might depend on compiler).
# Just remove build_type, requires and conf from package id for the moment
del self.info.settings.build_type
self.info.requires.clear()
try:
# Only conan v2
self.info.conf.clear()
except AttributeError:
pass
# Hack to force KB-H014 to consider stlab as header-only
# self.info.header_only()

def _validate_task_system(self):
if self.options.task_system == "libdispatch":
Expand Down Expand Up @@ -99,20 +110,16 @@ def _validate_boost_components(self):
f"so we will use boost::optional and boost::variant instead. Try -o {self.ref}:with_boost=True.")

def _validate_min_compiler_version(self):
if is_msvc(self):
check_min_vs(self, "192")
else:
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if not minimum_version:
self.output.warn(f"{self.ref} requires C++{self._minimum_cpp_standard}. "
f"Your compiler is unknown. Assuming it supports C++{self._minimum_cpp_standard}.")
elif Version(str(self.settings.compiler.version)) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, "
f"which your compiler does not support.")
if self.settings.compiler == "clang" and str(self.settings.compiler.version) in ("13", "14"):
raise ConanInvalidConfiguration(
f"{self.ref} currently does not work with Clang {self.settings.compiler.version} on CCI, it enters "
f"in an infinite build loop (smells like a compiler bug). Contributions are welcomed!")
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler))
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support."
)

if self.settings.compiler == "clang" and str(self.settings.compiler.version) in ("13", "14"):
raise ConanInvalidConfiguration(
f"{self.ref} currently does not work with Clang {self.settings.compiler.version} on CCI, it enters "
f"in an infinite build loop (smells like a compiler bug). Contributions are welcomed!")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
Expand All @@ -123,12 +130,11 @@ def validate(self):
self._validate_thread_system()
self._validate_boost_components()

def configure(self):
self.output.info("STLab With Boost: {}.".format(self.options.with_boost))
self.output.info("STLab Future Coroutines: {}.".format(self.options.future_coroutines))
self.output.info("STLab No Standard Coroutines: {}.".format(self.options.no_std_coroutines))
self.output.info("STLab Task System: {}.".format(self.options.task_system))
self.output.info("STLab Thread System: {}.".format(self.options.thread_system))
def build_requirements(self):
self.tool_requires("cmake/[>=3.23.3 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
Expand Down Expand Up @@ -159,15 +165,11 @@ def package(self):
rm(self, "concrt*.dll", os.path.join(self.package_folder, "bin"))
rm(self, "vcruntime*.dll", os.path.join(self.package_folder, "bin"))

def package_id(self):
# TODO: is header only but needs a header modified by cmake
# self.info.settings.clear()
# self.info.header_only()
pass

def package_info(self):
future_coroutines_value = 1 if self.options.future_coroutines else 0
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

future_coroutines_value = 1 if self.options.future_coroutines else 0
self.cpp_info.defines = [
'STLAB_FUTURE_COROUTINES={}'.format(future_coroutines_value)
]
Expand Down