|
| 1 | +from pathlib import Path |
| 2 | +from conans import ConanFile, CMake, RunEnvironment, tools |
| 3 | + |
| 4 | + |
| 5 | +class CloeComponentClothoidFit(ConanFile): |
| 6 | + name = "cloe-plugin-clothoid-fit" |
| 7 | + url = "https://github.com/eclipse/cloe" |
| 8 | + description = "Cloe component plugin that generates clothoids from given lane boundary point lists." |
| 9 | + license = "Apache-2.0" |
| 10 | + settings = "os", "compiler", "build_type", "arch" |
| 11 | + options = { |
| 12 | + "test": [True, False], |
| 13 | + "pedantic": [True, False], |
| 14 | + } |
| 15 | + default_options = { |
| 16 | + "test": True, |
| 17 | + "pedantic": True, |
| 18 | + } |
| 19 | + generators = "cmake" |
| 20 | + no_copy_source = True |
| 21 | + exports_sources = [ |
| 22 | + "src/*", |
| 23 | + "CMakeLists.txt", |
| 24 | + ] |
| 25 | + requires = [ |
| 26 | + "eigen/[~=3.4.0]", |
| 27 | + ] |
| 28 | + |
| 29 | + _cmake = None |
| 30 | + |
| 31 | + def set_version(self): |
| 32 | + version_file = Path(self.recipe_folder) / "../../VERSION" |
| 33 | + if version_file.exists(): |
| 34 | + self.version = tools.load(version_file).strip() |
| 35 | + else: |
| 36 | + git = tools.Git(folder=self.recipe_folder) |
| 37 | + self.version = git.run("describe --dirty=-dirty")[1:] |
| 38 | + |
| 39 | + def requirements(self): |
| 40 | + self.requires(f"cloe-runtime/{self.version}@cloe/develop") |
| 41 | + self.requires(f"cloe-models/{self.version}@cloe/develop") |
| 42 | + |
| 43 | + def build_requirements(self): |
| 44 | + if self.options.test: |
| 45 | + self.build_requires("gtest/[~1.10]") |
| 46 | + |
| 47 | + def _configure_cmake(self): |
| 48 | + if self._cmake: |
| 49 | + return self._cmake |
| 50 | + self._cmake = CMake(self) |
| 51 | + self._cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True |
| 52 | + self._cmake.definitions["BuildTests"] = self.options.test |
| 53 | + self._cmake.definitions["TargetLintingExtended"] = self.options.pedantic |
| 54 | + self._cmake.configure() |
| 55 | + return self._cmake |
| 56 | + |
| 57 | + def build(self): |
| 58 | + cmake = self._configure_cmake() |
| 59 | + cmake.build() |
| 60 | + if self.options.test: |
| 61 | + with tools.environment_append(RunEnvironment(self).vars): |
| 62 | + cmake.test() |
| 63 | + |
| 64 | + def package(self): |
| 65 | + cmake = self._configure_cmake() |
| 66 | + cmake.install() |
| 67 | + |
| 68 | + def package_id(self): |
| 69 | + del self.info.options.pedantic |
| 70 | + del self.info.options.test |
0 commit comments