forked from Ultimaker/CuraEngine
-
Notifications
You must be signed in to change notification settings - Fork 3
/
conanfile.py
140 lines (119 loc) · 5.45 KB
/
conanfile.py
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright (c) 2022 Ultimaker B.V.
# CuraEngine is released under the terms of the AGPLv3 or higher
from os import path
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import AutoPackager, copy, mkdir
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
required_conan_version = ">=1.50.0"
class CuraEngineConan(ConanFile):
name = "curaengine"
license = "AGPL-3.0"
author = "Ultimaker B.V."
url = "https://github.com/Ultimaker/CuraEngine"
description = "Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura."
topics = ("cura", "protobuf", "gcode", "c++", "curaengine", "libarcus", "gcode-generation", "3D-printing")
build_policy = "missing"
exports = "LICENSE*"
settings = "os", "compiler", "build_type", "arch"
python_requires = "umbase/[>=0.1.7]@ultimaker/stable"
python_requires_extend = "umbase.UMBaseConanfile"
options = {
"enable_arcus": [True, False],
"enable_openmp": [True, False],
"enable_testing": [True, False],
"enable_extensive_warnings": [True, False]
}
default_options = {
"enable_arcus": True,
"enable_openmp": True,
"enable_testing": False,
"enable_extensive_warnings": False,
}
scm = {
"type": "git",
"subfolder": ".",
"url": "auto",
"revision": "auto"
}
def set_version(self):
if self.version is None:
self.version = self._umdefault_version()
def config_options(self):
if self.settings.os == "Macos":
del self.options.enable_openmp
def configure(self):
self.options["boost"].header_only = True
self.options["clipper"].shared = True
self.options["fmt"].shared = True
self.options["spdlog"].shared = True
if self.options.enable_arcus:
self.options["arcus"].shared = True
self.options["protobuf"].shared = True
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 20)
if self.version:
if Version(self.version) <= Version("4"):
raise ConanInvalidConfiguration("only versions 5+ are supported")
def build_requirements(self):
if self.options.enable_arcus:
for req in self._um_data()["build_requirements_arcus"]:
self.tool_requires(req)
if self.options.enable_testing:
for req in self._um_data()["build_requirements_testing"]:
self.test_requires(req)
def requirements(self):
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
for req in self._um_data()["requirements"]:
self.requires(req)
if self.options.enable_arcus:
for req in self._um_data()["requirements_arcus"]:
self.requires(req)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["CURA_ENGINE_VERSION"] = self.version
tc.variables["ENABLE_ARCUS"] = self.options.enable_arcus
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
tc.variables["EXTENSIVE_WARNINGS"] = self.options.enable_extensive_warnings
if self.settings.os != "Macos":
tc.variables["ENABLE_OPENMP"] = self.options.enable_openmp
tc.generate()
for dep in self.dependencies.values():
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], self.build_folder)
copy(self, "*.dll", dep.cpp_info.libdirs[0], self.build_folder)
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], self.build_folder)
if self.options.enable_testing:
test_path = path.join(self.build_folder, "tests")
if not path.exists(test_path):
mkdir(self, test_path)
if len(dep.cpp_info.libdirs) > 0:
copy(self, "*.dylib", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
copy(self, "*.dll", dep.cpp_info.libdirs[0], path.join(self.build_folder, "tests"))
if len(dep.cpp_info.bindirs) > 0:
copy(self, "*.dll", dep.cpp_info.bindirs[0], path.join(self.build_folder, "tests"))
def layout(self):
cmake_layout(self)
self.cpp.build.includedirs = ["."] # To package the generated headers
self.cpp.package.libs = ["_CuraEngine"]
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
packager = AutoPackager(self)
packager.run()
copy(self, "CuraEngine*", src = self.build_folder, dst = path.join(self.package_folder, "bin"))
copy(self, "LICENSE*", src = self.source_folder, dst = path.join(self.package_folder, "license"))
def package_info(self):
ext = ".exe" if self.settings.os == "Windows" else ""
if self.in_local_cache:
self.conf_info.define("user.curaengine:curaengine", path.join(self.package_folder, "bin", f"CuraEngine{ext}"))
else:
self.conf_info.define("user.curaengine:curaengine", path.join(self.build_folder, f"CuraEngine{ext}"))