generated from bincrafters/template-default
-
Notifications
You must be signed in to change notification settings - Fork 1
/
conanfile.py
354 lines (319 loc) · 14.6 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
from conans import ConanFile, Meson, tools
from conan.errors import ConanInvalidConfiguration
import os
import shutil
dri_list = ['i915', 'i965', 'r100', 'r200', 'nouveau']
vk_list = ['amd', 'freedreno', 'intel']
gallium_list = ['kmsro', 'radeonsi', 'r300', 'r600', 'nouveau', 'freedreno',\
'swrast', 'v3d', 'vc4', 'etnaviv', 'tegra', 'i915', 'svga', 'virgl',\
'swr', 'panfrost', 'iris', 'lima', 'zink']
swr_list = ['avx', 'avx2', 'knl', 'skx']
tools_list = ['drm-shim', 'etnaviv', 'freedreno', 'glsl', 'intel', 'intel-ui', 'nir', 'nouveau', 'xvmc', 'lima']
class LibnameConan(ConanFile):
name = "mesa"
description = "Mesa is an OpenGL compatible 3D graphics library"
topics = ("conan", "mesa", "OpenGL")
url = "https://github.com/bincrafters/conan-mesa"
homepage = "https://mesa.freedesktop.org"
license = "MIT"
generators = "pkg_config"
# Options may need to change depending on the packaged library
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"opengl": [True, False],
"egl": [True, False],
"gles1": [True, False],
"gles2": [True, False],
'vk_intel': [True, False],
'vk_amd': [True, False],
'vk_freedreno': [True, False],
'gallium_vdpau': [True, False],
'gallium_xvmc': [True, False],
'gallium_va': [True, False],
'gallium_xa': [True, False],
'gallium_nine': [True, False],
'gallium_extra_hud': [True, False],
'gallium_omx':['disabled', 'bellagio', 'tizonia'],
'gallium_opencl': ['icd', 'standalone', 'disabled'],
'opencl_spirv' : [True, False],
'valgrind': [True, False],
'libunwind': [True, False],
'selinux': [True, False],
'shader_cache': [True, False],
'vulkan_overlay_layer': [True, False],
'gbm': [True, False],
'glvnd': [True, False],
'glx_read_only_text': [True, False],
'osmesa': ['none', 'classic', 'gallium'],
'osmesa_bits': [8, 16, 32],
'power8': [True, False],
'glx_direct': [True, False],
'dri_search_path': 'ANY'
}
options.update({"dri_%s" % driver: [True, False] for driver in dri_list})
options.update({"vk_%s" % driver: [True, False] for driver in vk_list})
options.update({"gallium_%s" % driver: [True, False] for driver in gallium_list})
options.update({"swr_%s" % arch: [True, False] for arch in swr_list})
options.update({"tool_%s" % tool: [True, False] for tool in tools_list})
default_options = {
"fPIC": True,
"opengl": True,
"egl": True,
"gles1": False,
"gles2": False,
'gallium_vdpau': False,
'gallium_xvmc': False,
'gallium_va': False,
'gallium_xa': False,
'gallium_nine': False,
'gallium_extra_hud': False,
'gallium_omx':'disabled',
'gallium_opencl':'disabled',
'opencl_spirv' : False,
'valgrind': False,
'libunwind': True,
'selinux': False,
'shader_cache': True,
'vulkan_overlay_layer': False,
'gbm': True,
'glvnd': False,
'glx_read_only_text': False,
'osmesa': 'none',
'osmesa_bits': 8,
'power8': False,
'glx_direct': 'True',
'libxcb:shared': True,
'libx11:shared': True,
'dri_search_path': None
}
default_options.update({"dri_%s" % driver: True for driver in dri_list})
default_options.update({"vk_%s" % driver: (driver not in ['freedreno', 'amd']) for driver in vk_list})
default_options.update({"gallium_%s" % driver: (driver == 'swrast') for driver in gallium_list})
default_options.update({"swr_%s" % arch: (arch in ['avx', 'avx2']) for arch in swr_list})
default_options.update({"tool_%s" % tool: False for tool in tools_list})
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
requires = (
"zlib/1.2.13",
)
# TODO - Packages required but not listed in this recipe
# wayland-scanner (libwayland-dev on Ubuntu)
# wayland-protocols (wayland-protocols on Ubuntu)
# wayland-egl-backend (libwayland-egl-backend-dev on Ubuntu)
# Python module mako
@property
def _with_any_opengl(self):
return self.options.opengl or self.options.gles1 or self.options.gles2
@property
def _with_dri(self):
for driver in dri_list:
if getattr(self.options, 'dri_%s' % driver):
return True
return False
@property
def _with_any_vk(self):
for driver in vk_list:
if getattr(self.options, 'vk_%s' % driver):
return True
return False
@property
def _with_gallium(self):
for driver in gallium_list:
if getattr(self.options, 'gallium_%s' % driver):
return True
return False
@property
def _with_dri_platform (self):
if tools.is_apple_os(self.settings.os):
return 'apple'
elif self.settings.os == 'Windows':
return 'windows'
elif self._with_any_vk:
return 'drm'
else:
return 'none'
@property
def _system_has_kms_drm(self):
return self.settings.os in ['Linux', 'FreeBSD', 'SunOS']
@property
def _with_dri2(self):
return (self._with_dri or self._with_any_vk) and (self._with_dri_platform == 'drm')
@property
def _with_dri3(self):
return self._system_has_kms_drm and self._with_dri2
@property
def _platforms(self):
if self._system_has_kms_drm:
return ['x11', 'drm', 'surfaceless'] #, 'wayland' TODO: Create package
elif tools.is_apple_os(self.settings.os):
return ['surfaceless'] # TODO: 'x11' when conan-x11 will be available and apple
elif self.settings.os == 'Windows':
return ['windows']
else:
raise ConanInvalidConfiguration('Unknown OS. Patches gladly accepted to fix this.')
@property
def _with_glx(self):
if self._with_dri:
return 'dri'
elif self.settings.os == 'Windows':
return 'disabled'
elif self._with_gallium:
# Even when building just gallium drivers the user probably wants dri
return 'dri'
elif 'x11' in self._platforms and self._with_any_opengl and not self._with_any_vk:
# The automatic behavior should not be to turn on xlib based glx when
# building only vulkan drivers
return 'xlib'
else:
return 'disabled'
@property
def _with_xlib_lease(self):
return 'x11' in self._platforms and 'drm' in self._platforms
def build_requirements(self):
if not tools.which("meson"):
self.build_requires("meson/0.59.3")
if not tools.which('pkg-config'):
self.build_requires('pkgconf/1.7.4')
if self._with_any_opengl:
if not tools.which("bison"):
self.build_requires("bison/3.5.3")
if not tools.which("flex"):
self.build_requires("flex/2.6.4")
def configure(self):
if self.settings.os not in ["Linux", "FreeBSD"]:
self.options.libunwind = False
if not self._system_has_kms_drm:
self.options.gbm = False
self.options.gallium_vdpau = False
self.options.gallium_xvmc = False
self.options.gallium_omx = 'disabled'
self.options.gallium_va = False
self.options.gallium_xa = False
if self.settings.os == 'Windows':
self.options.shader_cache = False
if tools.is_apple_os(self.settings.os) or self.settings.os == 'Windows':
self.options.egl = False
if 'windows' in self._platforms:
self.options.glvnd = False
if 'x11' not in self._platforms:
self.options.gallium_vdpau = False
self.options.gallium_xvmc = False
def requirements(self):
if self.settings.os != 'Windows':
self.requires("expat/2.2.10")
if self.options.gallium_xvmc:
self.requires('libxvmc/1.0.11@bincrafters/stable')
self.requires('libxv/1.0.11@bincrafters/stable')
if self._with_dri2 or self._with_dri3:
self.requires("libdrm/2.4.109")
if self.options.vk_amd or self.options.gallium_radeonsi or self.options.gallium_opencl:
self.requires("libelf/0.8.13")
if self.options.libunwind:
self.requires('libunwind/1.3.1')
if self.options.selinux:
self.requires('selinux/2.9@bincrafters/stable')
if 'x11' in self._platforms:
if self._with_glx == 'xlib' or self._with_glx == 'gallium-xlib':
self.requires("libx11/1.6.8@bincrafters/stable")
self.requires("libxext/1.3.4@bincrafters/stable")
self.requires("libxcb/1.13.1@bincrafters/stable")
elif self._with_glx == 'dri':
self.requires("libx11/1.6.8@bincrafters/stable")
self.requires("libxext/1.3.4@bincrafters/stable")
self.requires("libxdamage/1.1.5@bincrafters/stable")
self.requires("libxfixes/5.0.3@bincrafters/stable")
self.requires("libxcb/1.13.1@bincrafters/stable")
if self._with_any_vk or self._with_glx == 'dri' or self.options.egl or \
self.options.gallium_vdpau or self.options.gallium_xvmc or self.options.gallium_va or \
self.options.gallium_omx != 'disabled':
self.requires("libxcb/1.13.1@bincrafters/stable")
if self._with_any_vk or self.options.egl or (self._with_glx == 'dri' and self._with_dri_platform == 'drm'):
self.requires("libxcb/1.13.1@bincrafters/stable")
if self._with_dri3:
self.requires("libxshmfence/1.3@bincrafters/stable")
if self._with_glx == 'dri' or self._with_glx == 'gallium-xlib':
pass#self.requires('glproto/1.4.17@bincrafters/stable') TODO: create package in conan-x11
if self._with_glx == 'dri':
if self._with_dri_platform == 'drm':
#self.requires('dri2proto/2.8@bincrafters/stable') TODO: create package in conan-x11
self.requires("libxxf86vm/1.1.4@bincrafters/stable")
if self.options.egl or \
self.options.gallium_vdpau or self.options.gallium_xvmc or self.options.gallium_xa or\
self.options.gallium_omx != 'disabled':
self.requires("libxcb/1.13.1@bincrafters/stable")
if self._with_xlib_lease:
self.requires('libxrandr/1.5.2@bincrafters/stable')
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_meson(self):
for package in self.deps_cpp_info.deps:
if package != 'libunwind':
lib_path = self.deps_cpp_info[package].rootpath
for dirpath, _, filenames in os.walk(lib_path):
for filename in filenames:
if filename.endswith('.pc'):
shutil.copyfile(os.path.join(dirpath, filename), filename)
tools.replace_prefix_in_pc_file(filename, lib_path)
meson = Meson(self)
defs={
'llvm': 'false',
'platforms': self._platforms,
'valgrind': 'true' if self.options.valgrind else 'false',
'libunwind': 'true' if self.options.libunwind else 'false',
'dri3': 'true' if self._with_dri3 else 'false',
'dri-drivers': [driver for driver in dri_list if getattr(self.options, 'dri_' + driver)],
'gallium-drivers': [driver for driver in gallium_list if getattr(self.options, 'gallium_' + driver)],
'gallium-vdpau': 'true' if self.options.gallium_vdpau else 'false',
'gallium-xvmc': 'true' if self.options.gallium_xvmc else 'false',
'gallium-omx': self.options.gallium_omx,
'gallium-va': 'true' if self.options.gallium_va else 'false',
'gallium-xa': 'true' if self.options.gallium_xa else 'false',
'gallium-nine': 'true' if self.options.gallium_nine else 'false',
'gallium-opencl': self.options.gallium_opencl,
'opencl-spirv': 'true' if self.options.opencl_spirv else 'false',
'gallium-extra-hud': 'true' if self.options.gallium_extra_hud else 'false',
"vulkan-drivers": [driver for driver in vk_list if getattr(self.options, 'vk_' + driver)],
'gles1': 'true' if self.options.gles1 else 'false',
'gles2': 'true' if self.options.gles2 else 'false',
'opengl': 'true' if self.options.opengl else 'false',
'glx': self._with_glx,
'egl': 'true' if self.options.egl else 'false',
'xlib-lease': 'true' if self._with_xlib_lease else 'false',
'shader-cache': 'true' if self.options.shader_cache else 'false',
'vulkan-overlay-layer': 'true' if self.options.vulkan_overlay_layer else 'false',
'gbm': 'true' if self.options.gbm else 'false',
'glvnd': 'true' if self.options.glvnd else 'false',
'glx-read-only-text': 'true' if self.options.glx_read_only_text else 'false',
'osmesa': self.options.osmesa,
'osmesa-bits': self.options.osmesa_bits,
'swr-arches': [arch for arch in swr_list if getattr(self.options, 'swr_' + arch)],
'tools': [tool for tool in tools_list if getattr(self.options, 'tool_' + tool)],
'power8': 'true' if self.options.power8 else 'false',
'glx-direct': 'true' if self.options.glx_direct else 'false',
}
if self.options.dri_search_path:
defs['dri-search-path']=str(self.options.dri_search_path)
meson.configure(
defs=defs,
source_folder=self._source_subfolder,
build_folder=self._build_subfolder)
return meson
def build(self):
tools.check_min_cppstd(self, "11")
meson = self._configure_meson()
meson.build()
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
meson = self._configure_meson()
meson.install()
def package_id(self):
del self.info.settings.compiler.cppstd
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.env_info.LIBGL_DRIVERS_PATH = os.path.join(self.package_folder, 'lib', 'dri')