Mesa (staging/21.3): meson: Add "amber" option for automatic LTS build configuration

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 24 19:56:35 UTC 2022


Module: Mesa
Branch: staging/21.3
Commit: 33818d08adc71d409ec33fcc0bddf57fb3970fab
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=33818d08adc71d409ec33fcc0bddf57fb3970fab

Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Apr 30 14:01:26 2021 -0400

meson: Add "amber" option for automatic LTS build configuration

Setting amber to true changes these defaults:

- glvnd defaults to enabled
- the glvnd vendor name is set to "amber"
- the gallium and vulkan drivers are disabled
- prefer-iris defaults to false
- eglQueryString(EGL_VENDOR) returns "Mesa Project (Amber)"

The megadriver for the classic driver set will be installed to a file
name unique from Mesa main. Beyond that no attempt is made to use
filenames different from main - particularly not if glvnd is explicitly
disabled - so you would still need to configure your install paths
appropriately so things don't collide, if you want them to not collide.
But if you have that problem, consider that glvnd already solves it.

This has a quiet dependency on glapi and gbm's library API remaining
stable. gbm you could fix by linking it statically, glapi is a little
harder. I think the right move for glapi is to use glvnd's gldispatch
more directly, but that's not public API at the moment.

Reviewed-by: Emma Anholt <emma at anholt.net>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10557>

---

 meson.build                      | 38 ++++++++++++++++++++++++++++++++++----
 meson_options.txt                | 23 ++++++++++++++++-------
 src/egl/main/egldefines.h        |  4 ++++
 src/egl/meson.build              |  2 +-
 src/loader/meson.build           | 12 ++++++++++--
 src/mesa/drivers/dri/meson.build |  2 +-
 6 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/meson.build b/meson.build
index 0aea31260bb..07c77e17a65 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,13 @@ if get_option('layout') != 'mirror'
   error('`mirror` is the only build directory layout supported')
 endif
 
+amber = get_option('amber')
+if amber
+  package_version_suffix=' Amber'
+else
+  package_version_suffix=''
+endif
+
 # Arguments for the preprocessor, put these in a separate array from the C and
 # C++ (cpp in meson terminology) arguments since they need to be added to the
 # default arguments for both C and C++.
@@ -46,13 +53,18 @@ pre_args = [
   '-D__STDC_CONSTANT_MACROS',
   '-D__STDC_FORMAT_MACROS',
   '-D__STDC_LIMIT_MACROS',
-  '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
+  '-DPACKAGE_VERSION="@0@@1@"'.format(meson.project_version(), package_version_suffix),
   '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/-/issues"',
 ]
 c_args = []
 cpp_args = []
 
 with_moltenvk_dir = get_option('moltenvk-dir')
+
+if amber
+  pre_args += '-DAMBER'
+endif
+
 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
 with_tests = get_option('build-tests')
 with_aco_tests = get_option('build-aco-tests')
@@ -199,7 +211,9 @@ with_dri = dri_drivers.length() != 0
 
 gallium_drivers = get_option('gallium-drivers')
 if gallium_drivers.contains('auto')
-  if system_has_kms_drm
+  if amber
+    gallium_drivers = []
+  elif system_has_kms_drm
     # TODO: PPC, Sparc
     if ['x86', 'x86_64'].contains(host_machine.cpu_family())
       gallium_drivers = [
@@ -262,7 +276,9 @@ endif
 _vulkan_drivers = get_option('vulkan-drivers')
 if _vulkan_drivers.contains('auto')
   if system_has_kms_drm
-    if host_machine.cpu_family().startswith('x86')
+    if amber
+      _vulkan_drivers = []
+    elif host_machine.cpu_family().startswith('x86')
       _vulkan_drivers = ['amd', 'intel', 'swrast']
     elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
       _vulkan_drivers = ['swrast']
@@ -531,8 +547,22 @@ if with_glx != 'disabled'
   endif
 endif
 
-with_glvnd = get_option('glvnd')
+_glvnd = get_option('glvnd')
+if _glvnd == 'true' or _glvnd == 'enabled' or (amber and _glvnd == 'auto')
+  with_glvnd = true
+else
+  with_glvnd = false
+endif
+
 glvnd_vendor_name = get_option('glvnd-vendor-name')
+if glvnd_vendor_name == 'auto'
+  if amber
+    glvnd_vendor_name = 'amber'
+  else
+    glvnd_vendor_name = 'mesa'
+  endif
+endif
+
 if with_glvnd
   if with_platform_windows
     error('glvnd cannot be used on Windows')
diff --git a/meson_options.txt b/meson_options.txt
index 32c7593ee8e..6889646594f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -302,8 +302,9 @@ option(
 )
 option(
   'glvnd',
-  type : 'boolean',
-  value : false,
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false', 'enabled', 'disabled'],
   description : 'Enable GLVND support.'
 )
 option(
@@ -321,7 +322,7 @@ option(
 option(
   'glvnd-vendor-name',
   type : 'string',
-  value : 'mesa',
+  value : 'auto',
   description : 'Vendor name string to use for glvnd libraries'
 )
 option(
@@ -457,14 +458,16 @@ option(
 )
 option(
   'prefer-iris',
-  type : 'boolean',
-  value : true,
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
   description : 'Prefer new Intel iris driver over older i965 driver'
 )
 option(
   'prefer-crocus',
-  type : 'boolean',
-  value : false,
+  type : 'combo',
+  value : 'auto',
+  choices : ['auto', 'true', 'false'],
   description : 'Prefer new crocus driver over older i965 driver for gen4-7'
 )
 option('egl-lib-suffix',
@@ -530,3 +533,9 @@ option(
   value : false,
   description : 'Build gallium VMware/svga driver with mksGuestStats instrumentation.'
 )
+option(
+  'amber',
+  type : 'boolean',
+  value : false,
+  description : 'Configure LTS build to coexist with Mesa >= 22.0'
+)
diff --git a/src/egl/main/egldefines.h b/src/egl/main/egldefines.h
index c925e0ca553..791f4435439 100644
--- a/src/egl/main/egldefines.h
+++ b/src/egl/main/egldefines.h
@@ -46,7 +46,11 @@ extern "C" {
 #define _EGL_MAX_PBUFFER_WIDTH 4096
 #define _EGL_MAX_PBUFFER_HEIGHT 4096
 
+#ifdef AMBER
+#define _EGL_VENDOR_STRING "Mesa Project (Amber)"
+#else
 #define _EGL_VENDOR_STRING "Mesa Project"
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/src/egl/meson.build b/src/egl/meson.build
index 65faf607705..b6f7d1cf3d4 100644
--- a/src/egl/meson.build
+++ b/src/egl/meson.build
@@ -165,7 +165,7 @@ else
   files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
   files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
   glvnd_config = configuration_data()
-  glvnd_config.set('glvnd_vendor_name', get_option('glvnd-vendor-name'))
+  glvnd_config.set('glvnd_vendor_name', glvnd_vendor_name)
   configure_file(
     configuration: glvnd_config,
     input : 'main/50_mesa.json',
diff --git a/src/loader/meson.build b/src/loader/meson.build
index 927f4af11f1..15818c070fa 100644
--- a/src/loader/meson.build
+++ b/src/loader/meson.build
@@ -41,11 +41,19 @@ loader_c_args = [
   '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_search_path),
 ]
 
-if get_option('prefer-iris')
+_prefer_iris = get_option('prefer-iris')
+if _prefer_iris == 'auto'
+  _prefer_iris = amber ? 'false' : 'true'
+endif
+if _prefer_iris == 'true'
   loader_c_args += ['-DPREFER_IRIS']
 endif
 
-if get_option('prefer-crocus')
+_prefer_crocus = get_option('prefer-crocus')
+if _prefer_crocus == 'auto'
+  _prefer_crocus = 'false'
+endif
+if _prefer_crocus == 'true'
   loader_c_args += ['-DPREFER_CROCUS']
 endif
 
diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build
index 239ca962c2a..b4d22a61c3d 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -51,7 +51,7 @@ endif
 
 if _dri_drivers != []
   libmesa_dri_drivers = shared_library(
-    'mesa_dri_drivers',
+    '@0 at _dri_drivers'.format(glvnd_vendor_name),
     [],
     link_whole : _dri_drivers,
     link_with : [



More information about the mesa-commit mailing list