|
| 1 | +# mypy: ignore-errors |
| 2 | +# pylint: skip-file |
| 3 | + |
| 4 | +from pathlib import Path |
| 5 | +from conan import ConanFile |
| 6 | +from conan.tools import cmake, files, scm |
| 7 | + |
| 8 | +class CloeSimulatorESMini(ConanFile): |
| 9 | + name = "cloe-plugin-esmini" |
| 10 | + url = "https://github.com/esmini/esmini" |
| 11 | + description = "Cloe ESMini simulator plugin." |
| 12 | + license = "Apache-2.0" |
| 13 | + settings = "os", "compiler", "build_type", "arch" |
| 14 | + options = { |
| 15 | + "pedantic": [True, False], |
| 16 | + } |
| 17 | + default_options = { |
| 18 | + "pedantic": True, |
| 19 | + } |
| 20 | + generators = "CMakeDeps", "VirtualRunEnv" |
| 21 | + exports_sources = [ |
| 22 | + "src/*", |
| 23 | + "CMakeLists.txt", |
| 24 | + ] |
| 25 | + no_copy_source = True |
| 26 | + |
| 27 | + def set_version(self): |
| 28 | + version_file = Path(self.recipe_folder) / "../../VERSION" |
| 29 | + if version_file.exists(): |
| 30 | + self.version = files.load(self, version_file).strip() |
| 31 | + else: |
| 32 | + git = scm.Git(self, self.recipe_folder) |
| 33 | + self.version = git.run("describe --dirty=-dirty")[1:] |
| 34 | + |
| 35 | + def requirements(self): |
| 36 | + self.requires("eigen/3.4.0") |
| 37 | + self.requires(f"esmini/[~2.24.0]@cloe/stable") |
| 38 | + self.requires(f"cloe-runtime/{self.version}@cloe/develop") |
| 39 | + self.requires(f"cloe-models/{self.version}@cloe/develop") |
| 40 | + self.requires(f"cloe-osi/{self.version}@cloe/develop") |
| 41 | + |
| 42 | + def build_requirements(self): |
| 43 | + self.test_requires("gtest/1.13.0") |
| 44 | + |
| 45 | + def layout(self): |
| 46 | + cmake.cmake_layout(self) |
| 47 | + |
| 48 | + def generate(self): |
| 49 | + tc = cmake.CMakeToolchain(self) |
| 50 | + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True |
| 51 | + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version |
| 52 | + tc.cache_variables["TargetLintingExtended"] = self.options.pedantic |
| 53 | + tc.generate() |
| 54 | + |
| 55 | + def build(self): |
| 56 | + cm = cmake.CMake(self) |
| 57 | + if self.should_configure: |
| 58 | + cm.configure() |
| 59 | + if self.should_build: |
| 60 | + cm.build() |
| 61 | + if self.should_test: |
| 62 | + cm.test() |
| 63 | + |
| 64 | + def package(self): |
| 65 | + cm = cmake.CMake(self) |
| 66 | + if self.should_install: |
| 67 | + cm.install() |
| 68 | + |
| 69 | + def package_id(self): |
| 70 | + del self.info.options.pedantic |
| 71 | + |
| 72 | + def package_info(self): |
| 73 | + self.cpp_info.set_property("cmake_find_mode", "both") |
| 74 | + self.cpp_info.set_property("cmake_file_name", self.name) |
| 75 | + self.cpp_info.set_property("pkg_config_name", self.name) |
| 76 | + |
| 77 | + if not self.in_local_cache: # editable mode |
| 78 | + libdir = Path(self.build_folder) / "lib" |
| 79 | + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) |
0 commit comments