-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
174 lines (154 loc) · 6.92 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
required_conan_version = ">=1.33.0"
class MoltenVKConan(ConanFile):
name = "moltenvk"
description = "MoltenVK is a Vulkan Portability implementation. It " \
"layers a subset of the high-performance, industry-standard " \
"Vulkan graphics and compute API over Apple's Metal " \
"graphics framework, enabling Vulkan applications to run " \
"on iOS and macOS."
license = "Apache-2.0"
topics = ("moltenvk", "khronos", "vulkan", "metal")
homepage = "https://github.com/KhronosGroup/MoltenVK"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_spirv_tools": [True, False],
"tools": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_spirv_tools": True,
"tools": True,
}
generators = "cmake", "cmake_find_package_multi"
_cmake = None
@property
def _source_subfolder(self):
return "source_subfolder"
def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])
def configure(self):
if self.options.shared:
del self.options.fPIC
def requirements(self):
self.requires("cereal/1.3.0")
self.requires("glslang/11.6.0")
self.requires("spirv-cross/{}".format(self._spirv_cross_version))
self.requires("vulkan-headers/{}".format(self._vulkan_headers_version))
if self.options.with_spirv_tools:
self.requires("spirv-tools/2021.3")
if tools.Version(self.version) < "1.1.0":
raise ConanInvalidConfiguration("MoltenVK < 1.1.0 requires vulkan-portability, not yet available in CCI")
self.requires("vulkan-portability/0.2")
@property
def _spirv_cross_version(self):
return {
"1.1.5": "cci.20210823",
"1.1.4": "cci.20210621",
"1.1.1": "20210115", # can't compile with spirv-cross < 20210115
"1.1.0": "20200917", # compiles only with spirv-cross 20200917
"1.0.44": "20200917", # compiles only with spirv-cross 20200917
"1.0.43": "20200519", # compiles only with spirv-cross 20200519
"1.0.42": "20200519", # compiles only with spirv-cross 20200519
"1.0.41": "20200519", # compiles only with spirv-cross 20200403 or 20200519
"1.0.40": "20200519", # compiles only with spirv-cross 20200403 or 20200519
"1.0.39": "20200519", # compiles only with spirv-cross 20200403 or 20200519
}[self.version]
@property
def _vulkan_headers_version(self):
return {
"1.1.5": "1.2.189",
"1.1.4": "1.2.182",
"1.1.1": "1.2.162.0",
"1.1.0": "1.2.154.0",
"1.0.44": "1.2.148.0",
"1.0.43": "1.2.141.0",
"1.0.42": "1.2.141.0",
"1.0.41": "1.2.135.0",
"1.0.40": "1.2.131.1",
"1.0.39": "1.1.130.0",
"1.0.38": "1.1.126.0",
"1.0.37": "1.1.121.0",
"1.0.36": "1.1.114.0",
"1.0.35": "1.1.108.0",
"1.0.34": "1.1.106.0",
"1.0.33": "1.1.101.0",
"1.0.32": "1.1.97.0",
"1.0.31": "1.1.97.0",
"1.0.30": "1.1.92.0",
"1.0.29": "1.1.92.0",
"1.0.28": "1.1.92.0",
"1.0.27": "1.1.92.0",
"1.0.26": "1.1.85.0",
"1.0.25": "1.1.85.0",
"1.0.24": "1.1.85.0",
"1.0.23": "1.1.85.0",
"1.0.22": "1.1.82.0",
"1.0.21": "1.1.82.0",
"1.0.20": "1.1.82.0",
"1.0.19": "1.1.82.0",
"1.0.18": "1.1.82.0",
"1.0.17": "1.1.82.0",
}[self.version]
def package_id(self):
# MoltenVK >=1.O.42 requires at least XCode 12.0 (11.4 actually) at build
# time but can be consumed by older compiler versions
if tools.Version(self.version) >= "1.0.42":
if tools.Version(self.settings.compiler.version) < "12.0":
compatible_pkg = self.info.clone()
compatible_pkg.settings.compiler.version = "12.0"
self.compatible_packages.append(compatible_pkg)
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)
if self.settings.os not in ["Macos", "iOS", "tvOS"]:
raise ConanInvalidConfiguration("MoltenVK only supported on MacOS, iOS and tvOS")
if self.settings.compiler != "apple-clang":
raise ConanInvalidConfiguration("MoltenVK requires apple-clang")
if tools.Version(self.version) >= "1.0.42":
if tools.Version(self.settings.compiler.version) < "12.0":
raise ConanInvalidConfiguration("MoltenVK {} requires XCode 12.0 or higher at build time".format(self.version))
def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["MVK_VERSION"] = self.version
self._cmake.definitions["MVK_WITH_SPIRV_TOOLS"] = self.options.with_spirv_tools
self._cmake.definitions["MVK_BUILD_SHADERCONVERTER_TOOL"] = self.options.tools
self._cmake.configure()
return self._cmake
def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = ["MoltenVK"]
self.cpp_info.frameworks = ["Metal", "Foundation", "QuartzCore", "IOSurface", "CoreGraphics"]
if self.settings.os == "Macos":
self.cpp_info.frameworks.extend(["AppKit", "IOKit"])
elif self.settings.os in ["iOS", "tvOS"]:
self.cpp_info.frameworks.append("UIKit")
if self.options.shared:
moltenvk_icd_path = os.path.join(self.package_folder, "lib", "MoltenVK_icd.json")
self.output.info("Appending VK_ICD_FILENAMES environment variable: {}".format(moltenvk_icd_path))
self.env_info.VK_ICD_FILENAMES.append(moltenvk_icd_path)
if self.options.tools:
bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(bin_path)