2019-12-31 14:36:56 +08:00
|
|
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2015-02-08 14:08:50 +08:00
|
|
|
from spack import *
|
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
import sys
|
|
|
|
|
2016-08-10 16:50:00 +08:00
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
class Mesa(MesonPackage):
|
2017-07-21 03:12:05 +08:00
|
|
|
"""Mesa is an open-source implementation of the OpenGL specification
|
|
|
|
- a system for rendering interactive 3D graphics."""
|
2015-02-08 14:08:50 +08:00
|
|
|
|
|
|
|
homepage = "http://www.mesa3d.org"
|
2020-10-30 23:16:17 +08:00
|
|
|
maintainers = ['chuckatkins', 'v-dobrev']
|
2019-05-02 06:57:33 +08:00
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
git = "https://gitlab.freedesktop.org/mesa/mesa.git"
|
|
|
|
url = "https://archive.mesa3d.org/mesa-20.2.1.tar.xz"
|
2019-05-02 06:57:33 +08:00
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
version('master', tag='master')
|
|
|
|
version('20.2.1', sha256='d1a46d9a3f291bc0e0374600bdcb59844fa3eafaa50398e472a36fc65fd0244a')
|
|
|
|
|
|
|
|
depends_on('meson@0.52:', type='build')
|
2019-06-03 22:55:36 +08:00
|
|
|
|
|
|
|
depends_on('pkgconfig', type='build')
|
|
|
|
depends_on('binutils', when=(sys.platform != 'darwin'), type='build')
|
2019-05-09 19:56:37 +08:00
|
|
|
depends_on('bison', type='build')
|
|
|
|
depends_on('flex', type='build')
|
|
|
|
depends_on('gettext', type='build')
|
2020-10-30 23:16:17 +08:00
|
|
|
depends_on('python@3:', type='build')
|
2019-05-02 06:57:33 +08:00
|
|
|
depends_on('py-mako@0.8.0:', type='build')
|
2020-12-25 12:53:01 +08:00
|
|
|
depends_on('expat')
|
2017-11-10 01:16:52 +08:00
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
# Internal options
|
|
|
|
variant('llvm', default=True, description="Enable LLVM.")
|
2020-10-30 23:16:17 +08:00
|
|
|
variant('swr', default='auto',
|
|
|
|
values=('auto', 'none', 'avx', 'avx2', 'knl', 'skx'),
|
|
|
|
multi=True,
|
2019-05-02 06:57:33 +08:00
|
|
|
description="Enable the SWR driver.")
|
|
|
|
# conflicts('~llvm', when='~swr=none')
|
|
|
|
|
|
|
|
# Front ends
|
|
|
|
variant('osmesa', default=True, description="Enable the OSMesa frontend.")
|
|
|
|
|
|
|
|
is_linux = sys.platform.startswith('linux')
|
|
|
|
variant('glx', default=is_linux, description="Enable the GLX frontend.")
|
|
|
|
|
|
|
|
# TODO: effectively deal with EGL. The implications of this have not been
|
|
|
|
# worked through yet
|
|
|
|
# variant('egl', default=False, description="Enable the EGL frontend.")
|
|
|
|
|
|
|
|
# TODO: Effectively deal with hardware drivers
|
|
|
|
# The implication of this is enabling DRI, among other things, and
|
|
|
|
# needing to check which llvm targets were built (ptx or amdgpu, etc.)
|
|
|
|
|
|
|
|
# Back ends
|
|
|
|
variant('opengl', default=True, description="Enable full OpenGL support.")
|
|
|
|
variant('opengles', default=False, description="Enable OpenGL ES support.")
|
|
|
|
|
|
|
|
# Provides
|
2020-07-24 05:41:48 +08:00
|
|
|
provides('gl@4.5', when='+opengl')
|
|
|
|
provides('glx@1.4', when='+glx')
|
|
|
|
# provides('egl@1.5', when='+egl')
|
2020-10-30 23:16:17 +08:00
|
|
|
provides('osmesa', when='+osmesa')
|
2019-05-02 06:57:33 +08:00
|
|
|
|
|
|
|
# Variant dependencies
|
2020-10-30 23:16:17 +08:00
|
|
|
depends_on('llvm@6:', when='+llvm')
|
2019-05-02 06:57:33 +08:00
|
|
|
depends_on('libx11', when='+glx')
|
|
|
|
depends_on('libxcb', when='+glx')
|
|
|
|
depends_on('libxext', when='+glx')
|
2020-10-30 23:16:17 +08:00
|
|
|
depends_on('libxt', when='+glx')
|
|
|
|
depends_on('xrandr', when='+glx')
|
2019-05-07 02:37:13 +08:00
|
|
|
depends_on('glproto@1.4.14:', when='+glx', type='build')
|
|
|
|
|
2020-11-29 21:37:45 +08:00
|
|
|
# Require at least 1 front-end
|
|
|
|
# TODO: Add egl to this conflict once made available
|
|
|
|
conflicts('~osmesa ~glx')
|
|
|
|
|
|
|
|
# Require at least 1 back-end
|
|
|
|
# TODO: Add vulkan to this conflict once made available
|
|
|
|
conflicts('~opengl ~opengles')
|
|
|
|
|
2020-12-01 06:54:24 +08:00
|
|
|
# OpenGL ES requires OpenGL
|
|
|
|
conflicts('~opengl +opengles')
|
|
|
|
|
2020-12-23 01:39:56 +08:00
|
|
|
def patch(self):
|
|
|
|
filter_file(
|
|
|
|
r"_llvm_method = 'auto'",
|
|
|
|
"_llvm_method = 'config-tool'",
|
|
|
|
"meson.build")
|
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
def meson_args(self):
|
2017-07-21 03:12:05 +08:00
|
|
|
spec = self.spec
|
2019-05-02 06:57:33 +08:00
|
|
|
args = [
|
2020-10-30 23:16:17 +08:00
|
|
|
'-Dvulkan-drivers=',
|
|
|
|
'-Dgallium-vdpau=disabled',
|
|
|
|
'-Dgallium-xvmc=disabled',
|
|
|
|
'-Dgallium-omx=disabled',
|
|
|
|
'-Dgallium-va=disabled',
|
|
|
|
'-Dgallium-xa=disabled',
|
|
|
|
'-Dgallium-nine=false',
|
|
|
|
'-Dgallium-opencl=disabled',
|
|
|
|
'-Dbuild-tests=false',
|
|
|
|
'-Dglvnd=false']
|
2019-05-02 06:57:33 +08:00
|
|
|
args_platforms = []
|
|
|
|
args_gallium_drivers = ['swrast']
|
|
|
|
args_dri_drivers = []
|
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
opt_enable = lambda c, o: '-D%s=%sabled' % (o, 'en' if c else 'dis')
|
|
|
|
opt_bool = lambda c, o: '-D%s=%s' % (o, str(c).lower())
|
2020-01-17 02:21:34 +08:00
|
|
|
if spec.target.family == 'arm' or spec.target.family == 'aarch64':
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dlibunwind=disabled')
|
2019-09-08 11:33:30 +08:00
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
num_frontends = 0
|
|
|
|
if '+osmesa' in spec:
|
|
|
|
num_frontends += 1
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dosmesa=gallium')
|
2017-09-19 02:10:54 +08:00
|
|
|
else:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dosmesa=none')
|
2017-09-19 02:10:54 +08:00
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
if '+glx' in spec:
|
|
|
|
num_frontends += 1
|
2019-06-03 22:55:36 +08:00
|
|
|
if '+egl' in spec:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dglx=dri')
|
2019-06-03 22:55:36 +08:00
|
|
|
else:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dglx=gallium-xlib')
|
2019-05-02 06:57:33 +08:00
|
|
|
args_platforms.append('x11')
|
|
|
|
else:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dglx=disabled')
|
2017-09-19 02:10:54 +08:00
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
if '+egl' in spec:
|
|
|
|
num_frontends += 1
|
2020-10-30 23:16:17 +08:00
|
|
|
args.extend(['-Degl=enabled', '-Dgbm=enabled', '-Ddri3=enabled'])
|
2019-06-03 22:55:36 +08:00
|
|
|
args_platforms.append('surfaceless')
|
2017-09-19 02:10:54 +08:00
|
|
|
else:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.extend(
|
|
|
|
['-Degl=disabled', '-Dgbm=disabled', '-Ddri3=disabled'])
|
2017-07-21 03:12:05 +08:00
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append(opt_bool('+opengl' in spec, 'opengl'))
|
|
|
|
args.append(opt_enable('+opengles' in spec, 'gles1'))
|
|
|
|
args.append(opt_enable('+opengles' in spec, 'gles2'))
|
2017-07-21 03:12:05 +08:00
|
|
|
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append(opt_enable(num_frontends > 1, 'shared-glapi'))
|
2017-09-19 02:10:54 +08:00
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
if '+llvm' in spec:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dllvm=enabled')
|
|
|
|
args.append(opt_enable(
|
|
|
|
'+link_dylib' in spec['llvm'], 'shared-llvm'))
|
2019-05-02 06:57:33 +08:00
|
|
|
else:
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dllvm=disabled')
|
2019-05-02 06:57:33 +08:00
|
|
|
|
|
|
|
args_swr_arches = []
|
2020-10-30 23:16:17 +08:00
|
|
|
if 'swr=auto' in spec:
|
|
|
|
if 'avx' in spec.target:
|
|
|
|
args_swr_arches.append('avx')
|
|
|
|
if 'avx2' in spec.target:
|
|
|
|
args_swr_arches.append('avx2')
|
|
|
|
if 'avx512f' in spec.target:
|
|
|
|
if 'avx512er' in spec.target:
|
|
|
|
args_swr_arches.append('knl')
|
|
|
|
if 'avx512bw' in spec.target:
|
|
|
|
args_swr_arches.append('skx')
|
|
|
|
else:
|
|
|
|
if 'swr=avx' in spec:
|
|
|
|
args_swr_arches.append('avx')
|
|
|
|
if 'swr=avx2' in spec:
|
|
|
|
args_swr_arches.append('avx2')
|
|
|
|
if 'swr=knl' in spec:
|
|
|
|
args_swr_arches.append('knl')
|
|
|
|
if 'swr=skx' in spec:
|
|
|
|
args_swr_arches.append('skx')
|
|
|
|
|
2019-05-02 06:57:33 +08:00
|
|
|
if args_swr_arches:
|
|
|
|
if '+llvm' not in spec:
|
|
|
|
raise SpecError('Variant swr requires +llvm')
|
|
|
|
args_gallium_drivers.append('swr')
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dswr-arches=' + ','.join(args_swr_arches))
|
2019-05-02 06:57:33 +08:00
|
|
|
|
|
|
|
# Add the remaining list args
|
2020-10-30 23:16:17 +08:00
|
|
|
args.append('-Dplatforms=' + ','.join(args_platforms))
|
|
|
|
args.append('-Dgallium-drivers=' + ','.join(args_gallium_drivers))
|
|
|
|
args.append('-Ddri-drivers=' + ','.join(args_dri_drivers))
|
2019-05-02 06:57:33 +08:00
|
|
|
|
|
|
|
return args
|
2020-03-28 18:30:05 +08:00
|
|
|
|
|
|
|
@property
|
2020-07-24 05:41:48 +08:00
|
|
|
def libs(self):
|
2020-10-30 23:16:17 +08:00
|
|
|
spec = self.spec
|
|
|
|
libs_to_seek = set()
|
|
|
|
|
|
|
|
if '+osmesa' in spec:
|
|
|
|
libs_to_seek.add('libOSMesa')
|
|
|
|
|
|
|
|
if '+glx' in spec:
|
|
|
|
libs_to_seek.add('libGL')
|
|
|
|
|
|
|
|
if '+opengl' in spec:
|
|
|
|
libs_to_seek.add('libGL')
|
|
|
|
|
|
|
|
if '+opengles' in spec:
|
|
|
|
libs_to_seek.add('libGLES')
|
|
|
|
libs_to_seek.add('libGLES2')
|
|
|
|
|
|
|
|
if libs_to_seek:
|
|
|
|
return find_libraries(list(libs_to_seek),
|
|
|
|
root=self.spec.prefix,
|
|
|
|
recursive=True)
|
|
|
|
return LibraryList()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def osmesa_libs(self):
|
|
|
|
return find_libraries('libOSMesa',
|
|
|
|
root=self.spec.prefix,
|
|
|
|
recursive=True)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def glx_libs(self):
|
|
|
|
return find_libraries('libGL',
|
|
|
|
root=self.spec.prefix,
|
|
|
|
recursive=True)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def gl_libs(self):
|
|
|
|
return find_libraries('libGL',
|
|
|
|
root=self.spec.prefix,
|
|
|
|
recursive=True)
|