|
| 1 | +from conans import ConanFile, CMake, tools |
| 2 | +from conans.errors import ConanInvalidConfiguration |
| 3 | +import os |
| 4 | + |
| 5 | +required_conan_version = ">=1.43.0" |
| 6 | + |
| 7 | + |
| 8 | +class RotorConan(ConanFile): |
| 9 | + name = "rotor" |
| 10 | + license = "MIT" |
| 11 | + homepage = "https://github.com/basiliscos/cpp-rotor" |
| 12 | + url = "https://github.com/conan-io/conan-center-index" |
| 13 | + description = ( |
| 14 | + "Event loop friendly C++ actor micro-framework, supervisable" |
| 15 | + ) |
| 16 | + topics = ("concurrency", "actor-framework", "actors", "actor-model", "erlang", "supervising", "supervisor") |
| 17 | + |
| 18 | + settings = "os", "arch", "compiler", "build_type" |
| 19 | + options = { |
| 20 | + "fPIC": [True, False], |
| 21 | + "boost_asio": [True, False], |
| 22 | + "thread": [True, False], |
| 23 | + } |
| 24 | + default_options = { |
| 25 | + "fPIC": True, |
| 26 | + "boost_asio": True, |
| 27 | + "thread": True, |
| 28 | + } |
| 29 | + |
| 30 | + exports_sources = ["CMakeLists.txt"] |
| 31 | + generators = "cmake" |
| 32 | + _cmake = None |
| 33 | + |
| 34 | + @property |
| 35 | + def _source_subfolder(self): |
| 36 | + return "source_subfolder" |
| 37 | + |
| 38 | + @property |
| 39 | + def _build_subfolder(self): |
| 40 | + return "build_subfolder" |
| 41 | + |
| 42 | + def config_options(self): |
| 43 | + if self.settings.os == "Windows": |
| 44 | + del self.options.fPIC |
| 45 | + |
| 46 | + def requirements(self): |
| 47 | + self.requires("boost/1.69.0") |
| 48 | + |
| 49 | + |
| 50 | + def validate(self): |
| 51 | + minimal_cpp_standard = "17" |
| 52 | + if self.settings.compiler.get_safe("cppstd"): |
| 53 | + tools.check_min_cppstd(self, minimal_cpp_standard) |
| 54 | + minimal_version = { |
| 55 | + "gcc": "7", |
| 56 | + "clang": "6", |
| 57 | + "apple-clang": "10", |
| 58 | + "Visual Studio": "15" |
| 59 | + } |
| 60 | + compiler = str(self.settings.compiler) |
| 61 | + if compiler not in minimal_version: |
| 62 | + self.output.warn( |
| 63 | + "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) |
| 64 | + self.output.warn( |
| 65 | + "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) |
| 66 | + return |
| 67 | + |
| 68 | + version = tools.Version(self.settings.compiler.version) |
| 69 | + if version < minimal_version[compiler]: |
| 70 | + raise ConanInvalidConfiguration("%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) |
| 71 | + |
| 72 | + def _configure_cmake(self): |
| 73 | + if self._cmake: |
| 74 | + return self._cmake |
| 75 | + |
| 76 | + self._cmake = CMake(self) |
| 77 | + self._cmake.definitions["BUILD_BOOST_ASIO"] = self.options.boost_asio |
| 78 | + self._cmake.definitions["BUILD_THREAD"] = self.options.thread |
| 79 | + self._cmake.configure(build_folder=self._build_subfolder) |
| 80 | + return self._cmake |
| 81 | + |
| 82 | + def build(self): |
| 83 | + cmake = self._configure_cmake() |
| 84 | + cmake.build() |
| 85 | + |
| 86 | + def source(self): |
| 87 | + tools.get(**self.conan_data["sources"][self.version], |
| 88 | + destination=self._source_subfolder, strip_root=True) |
| 89 | + |
| 90 | + def package(self): |
| 91 | + cmake = self._configure_cmake() |
| 92 | + cmake.install() |
| 93 | + self.copy("license*", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False) |
| 94 | + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) |
| 95 | + |
| 96 | + def package_info(self): |
| 97 | + self.cpp_info.components["core"].libs = ["rotor-core"] |
| 98 | + self.cpp_info.components["core"].requires = ["boost::date_time", "boost::system", "boost::regex"] |
| 99 | + |
| 100 | + self.cpp_info.components["asio"].libs = ["rotor-asio"] |
| 101 | + self.cpp_info.components["asio"].requires = ["core"] |
| 102 | + |
| 103 | + self.cpp_info.components["thread"].libs = ["rotor-thread"] |
| 104 | + self.cpp_info.components["thread"].requires = ["core"] |
| 105 | + |
| 106 | + # TODO: to remove in conan v2 once cmake_find_package* generators removed |
| 107 | + self.cpp_info.names["cmake_find_package"] = "rotor" |
| 108 | + self.cpp_info.names["cmake_find_package_multi"] = "rotor" |
| 109 | + |
0 commit comments