[Mesa-dev] [PATCH 4/6] meson: build gbm

Dylan Baker dylan at pnwbakers.com
Wed Oct 4 00:26:47 UTC 2017


This doesn't include egl support, just dri support.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 meson.build                     | 49 +++++++++++++++++++++-----------
 meson_options.txt               | 14 +++++----
 src/{loader => gbm}/meson.build | 63 ++++++++++++++++++++++++++++-------------
 src/glx/meson.build             | 10 +++----
 src/loader/meson.build          |  2 ++
 src/mesa/meson.build            |  2 +-
 src/meson.build                 |  4 ++-
 7 files changed, 95 insertions(+), 49 deletions(-)
 copy src/{loader => gbm}/meson.build (50%)

diff --git a/meson.build b/meson.build
index ec50e10b38c..185d70509c5 100644
--- a/meson.build
+++ b/meson.build
@@ -54,19 +54,6 @@ with_any_opengl = with_opengl or with_gles1 or with_gles2
 # Only build shared_glapi if at least one OpenGL API is enabled
 with_shared_glapi = get_option('shared-glapi') and with_any_opengl
 
-with_dri3 = get_option('dri3')
-if with_dri3 == 'auto'
-  if host_machine.system() == 'linux'
-    with_dri3 = true
-  else
-    with_dri3 = false
- endif
-elif with_dri3 == 'yes'
-  with_dri3 = true
-else
-  with_dri3 = false
-endif
-
 # TODO: these will need options, but at the moment they just control header
 # installs
 with_osmesa = false
@@ -107,6 +94,27 @@ with_dri_platform = 'drm'
 with_gallium = false
 # TODO: gallium drivers
 
+# TODO: conditionalize libdrm requirement
+dep_libdrm = dependency('libdrm', version : '>= 2.4.75')
+pre_args += '-DHAVE_LIBDRM'
+
+with_dri2 = with_dri and with_dri_platform == 'drm' and dep_libdrm.found()
+with_dri3 = get_option('dri3')
+if with_dri3 == 'auto'
+  if host_machine.system() == 'linux' and with_dri2
+    with_dri3 = true
+  else
+    with_dri3 = false
+ endif
+elif with_dri3 == 'yes'
+  if not with_dri2
+    error('dri3 support requires libdrm')
+  endif
+  with_dri3 = true
+else
+  with_dri3 = false
+endif
+
 # TODO: there are more platforms required for non-vulkan drivers
 with_platform_wayland = false
 with_platform_x11 = false
@@ -117,6 +125,18 @@ if _platforms != ''
   with_platform_wayland = _split.contains('wayland')
 endif
 
+with_gbm = get_option('gbm')
+if with_gbm == 'auto'
+  with_gbm = host_machine.system() == 'linux'
+elif with_gbm == 'yes'
+  if not ['linux', 'bsd'].contains(host_machine.system())
+    error('GBM only supports unix-like platforms')
+  endif
+  with_gbm = true
+else
+  with_gbm = false
+endif
+
 with_glx = get_option('glx')
 if with_glx != 'disabled'
   pre_args += '-DGLX_USE_TLS'
@@ -446,9 +466,6 @@ dep_expat = dependency('expat')
 # its not linux and and wont
 dep_m = cc.find_library('m', required : false)
 
-# TODO: conditionalize libdrm requirement
-dep_libdrm = dependency('libdrm', version : '>= 2.4.75')
-pre_args += '-DHAVE_LIBDRM'
 dep_libdrm_amdgpu = []
 if with_amd_vk
   dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>= 2.4.82')
diff --git a/meson_options.txt b/meson_options.txt
index 130d3962db7..b6d44c44ba9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -32,17 +32,19 @@ option('shader-cache',    type : 'boolean', value : true,
        description : 'Build with on-disk shader cache support')
 option('vulkan-icd-dir', type : 'string',  value : '',
        description : 'Location relative to prefix to put vulkan icds on install. Default: $datadir/vulkan/icd.d')
-option('shared-glapi',   type : 'boolean', value : true,
+option('shared-glapi',    type : 'boolean', value : true,
        description : 'Whether to build a shared or static glapi')
-option('gles1',          type : 'boolean', value : true,
+option('gles1',           type : 'boolean', value : true,
        description : 'Build support for OpenGL ES 1.x')
-option('gles2',          type : 'boolean', value : true,
+option('gles2',           type : 'boolean', value : true,
        description : 'Build support for OpenGL ES 2.x and 3.x')
-option('opengl',         type : 'boolean', value : true,
+option('opengl',          type : 'boolean', value : true,
        description : 'Build support for OpenGL (all versions)')
-option('glx',            type : 'combo',   value : 'auto', choices : ['auto', 'disabled', 'dri', 'xlib', 'gallium-xlib'],
+option('gbm',             type : 'combo',   value : 'auto', choices : ['auto', 'yes', 'no'],
+       description : 'Build support for gbm platform')
+option('glx',             type : 'combo',   value : 'auto', choices : ['auto', 'disabled', 'dri', 'xlib', 'gallium-xlib'],
        description : 'Build support for GLX platform')
-option('glvnd',          type : 'boolean', vaule : false,
+option('glvnd',           type : 'boolean', value : false,
        description : 'Enable GLVND support.')
 option('asm',            type : 'boolean', value : true,
        description : 'Build assembly code if possible')
diff --git a/src/loader/meson.build b/src/gbm/meson.build
similarity index 50%
copy from src/loader/meson.build
copy to src/gbm/meson.build
index 2c2af7a3d59..45b71a5a6f6 100644
--- a/src/loader/meson.build
+++ b/src/gbm/meson.build
@@ -18,25 +18,50 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-if with_platform_x11 and with_dri3
-  libloader_dri3_helper = static_library(
-    'loader_dri3_helper',
-    ['loader_dri3_helper.c', 'loader_dri3_helper.h'],
-    c_args : c_vis_args,
-    include_directories : inc_include,
-    dependencies : [dep_xcb_dri3, dep_libdrm],
-    build_by_default : false,
-  )
-else
-  libloader_dri3_helper = []
+files_gbm = files(
+  'main/backend.c',
+  'main/backend.h',
+  'main/gbm.c',
+  'main/gbm.h',
+  'main/gbmint.h',
+)
+deps_gbm = []
+args_gbm = []
+links_gbm = []
+
+if with_dri2
+  files_gbm += files('backends/dri/gbm_dri.c', 'backends/dri/gbm_driint.h')
+  deps_gbm += [dep_libdrm, dep_thread]
+  args_gbm += '-DDEFAULT_DRIVER_DIR="@0@"'.format(dri_driver_dir)
 endif
 
-libloader = static_library(
-  'loader',
-  ['loader.c', 'loader.h', 'pci_id_driver_map.c', 'pci_id_driver_map.h',
-   xmlpool_options_h],
-  c_args : [c_vis_args, '-DUSE_DRICONF'],
-  include_directories : [inc_include, inc_src, inc_util],
-  dependencies : dep_libdrm,
-  build_by_default : false,
+# TODO: wayland support (requires egl)
+
+libgbm = shared_library(
+  'gbm',
+  files_gbm,
+  include_directories : [
+    include_directories('main'), inc_include, inc_src, inc_loader],
+  c_args : args_gbm,
+  link_args : [ld_args_gc_sections],
+  link_with : [libloader, libmesa_util, libxmlconfig],
+  dependencies : [deps_gbm, dep_dl],
+  version : '1.0',
+  install : true,
+)
+
+install_headers('main/gbm.h')
+
+pkg.generate(
+  name : 'gbm',
+  filebase : 'gbm',
+  description : 'Mesa gbm library',
+  version : meson.project_version(),
+  libraries : libgbm,
+  #libraries_private : [dep_dl],  # FIXME: autotools lists this a incomplete
 )
+
+if with_tests
+  gbm_symbols_check = find_program('gbm-symbols-check')
+  test('gbm-symbols-check', gbm_symbols_check)
+endif
diff --git a/src/glx/meson.build b/src/glx/meson.build
index 6b6e9095740..8c1b29a9ff8 100644
--- a/src/glx/meson.build
+++ b/src/glx/meson.build
@@ -106,8 +106,6 @@ elif with_windowsdri
   #]
 endif
 
-# TODO: libglvnd
-
 dri_driver_dir = join_paths(get_option('prefix'), with_dri_drivers_path)
 if not with_glvnd
   gl_lib_name = 'GL'
@@ -137,8 +135,8 @@ libglx = static_library(
   [files_libglx, glx_indirect_c, glx_indirect_h, glx_indirect_init_c,
    glx_indirect_size_c, glx_indirect_size_h],
   include_directories : [
-    inc_common, inc_glapi,
-    include_directories('../loader', '../../include/GL/internal')
+    inc_common, inc_glapi, inc_loader,
+    include_directories('../../include/GL/internal')
   ],
   c_args : [c_vis_args, gl_lib_cargs,
             '-DGL_LIB_NAME="lib at 0@.so. at 1@"'.format(gl_lib_name, gl_lib_version)],
@@ -159,8 +157,8 @@ if with_glx == 'dri'
     gl_lib_name,
     dummy_c,  # workaround for bug #2180
     include_directories : [
-      inc_common, inc_glapi, 
-      include_directories('../loader', '../../include/GL/internal')
+      inc_common, inc_glapi, inc_loader,
+      include_directories('../../include/GL/internal')
     ],
     link_with : [libglapi_static, libglapi],
     link_whole : libglx,
diff --git a/src/loader/meson.build b/src/loader/meson.build
index 2c2af7a3d59..425620372aa 100644
--- a/src/loader/meson.build
+++ b/src/loader/meson.build
@@ -18,6 +18,8 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
+inc_loader = include_directories('.')
+
 if with_platform_x11 and with_dri3
   libloader_dri3_helper = static_library(
     'loader_dri3_helper',
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index 68f1a463fee..d9081829f2b 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -570,7 +570,7 @@ libmesa_classic = static_library(
    main_api_exec_c, main_enums_c, format_fallback_c, format_info_h,
    format_pack_c, format_unpack_c, get_hash_h, main_marshal_generated_c,
    main_marshal_generated_h, main_dispatch_h, ir_expression_operation_h,
-   nir_opcodes_h, main_remap_helper_h, matypes_h],
+   nir_opcodes_h, main_remap_helper_h, matypes_h, sha1_h],
   c_args : [c_vis_args, c_msvc_compat_args],
   cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
   include_directories : [inc_common, include_directories('main')],
diff --git a/src/meson.build b/src/meson.build
index f49ad9e0e7e..544d831ea63 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -54,6 +54,8 @@ subdir('intel')
 subdir('mesa')
 subdir('loader')
 subdir('glx')
-# TODO: dri_glx
+if with_gbm
+  subdir('gbm')
+endif
 # TODO: egl
 # TODO: gallium
-- 
2.14.1



More information about the mesa-dev mailing list