OSDN Git Service

Add meson support
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 3 Nov 2017 08:02:25 +0000 (09:02 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Tue, 2 Jan 2018 07:04:59 +0000 (15:04 +0800)
Fixes: #134

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
meson.build [new file with mode: 0644]
meson_options.txt [new file with mode: 0644]
pkgconfig/meson.build [new file with mode: 0644]
va/meson.build [new file with mode: 0644]

diff --git a/meson.build b/meson.build
new file mode 100644 (file)
index 0000000..10d5414
--- /dev/null
@@ -0,0 +1,115 @@
+# libva package version number, (as distinct from shared library version)
+# XXX: we want the package version to remain at 1.0.x for VA-API 0.32.y
+#
+# - major version is automatically generated from VA-API major version
+# - minor version is automatically generated from VA-API minor version
+# - increment micro for any library release
+# - reset micro version to zero when VA-API major or minor version is changed
+project(
+  'libva', 'c',
+  version : '2.0.1.1',
+  meson_version : '>= 0.37.0',
+  default_options : [ 'warning_level=1',
+                      'buildtype=debugoptimized' ])
+
+# VA-API version
+# - increment major for any ABI change
+# - increment minor for any interface change (e.g. new/modified function)
+# - increment micro for any other change (new flag, new codec definition, etc.)
+# - reset micro version to zero when minor version is incremented
+# - reset minor version to zero when major version is incremented
+va_api_major_version = 1
+va_api_minor_version = 0
+va_api_micro_version = 0
+
+va_api_version = '@0@.@1@.@2@'.format(va_api_major_version,
+                                     va_api_minor_version,
+                                     va_api_micro_version)
+
+version_arr = meson.project_version().split('.')
+libva_major_version = version_arr[0]
+libva_minor_version = version_arr[1]
+libva_micro_version = version_arr[2]
+libva_version = '@0@.@1@.@2@'.format(libva_major_version,
+                                    libva_minor_version,
+                                    libva_micro_version)
+if version_arr.length() == 4
+  libva_version = '@0@.pre@1@'.format(libva_version, version_arr[3])
+endif
+
+
+# libva library version number (generated, do not change)
+# XXX: we want the SONAME to remain at libva.so.1 for VA-API major == 0
+#
+# The library name is generated libva.<x>.<y>.0 where
+# <x> = VA-API major version + 1
+# <y> = 100 * VA-API minor version + VA-API micro version
+#
+# For example:
+# VA-API 0.32.0 generates libva.so.1.3200.0
+# VA-API 0.34.1 generates libva.so.1.3401.0
+# VA-API 1.2.13 generates libva.so.2.213.0
+libva_interface_bias = va_api_major_version + 1
+libva_interface_age = 0
+libva_binary_age = 100 * va_api_minor_version + va_api_micro_version - libva_interface_age
+
+libva_lt_current = 100 * va_api_minor_version + va_api_micro_version + libva_interface_bias
+libva_lt_revision = libva_interface_age
+libva_lt_age = libva_binary_age - libva_interface_age
+
+libva_lt_version = '@0@.@1@.@2@'.format(libva_lt_current,
+                                       libva_lt_revision,
+                                       libva_lt_age)
+
+driverdir = get_option('driverdir')
+if driverdir == ''
+  driverdir = '@0@/@1@/@2@'.format(get_option('prefix'), get_option('libdir'), 'dri')
+endif
+
+configinc = include_directories('.')
+
+cc = meson.get_compiler('c')
+dl_dep = cc.find_library('dl', required : false)
+
+libdrm_dep = dependency('libdrm', version : '>= 2.4')
+
+WITH_DRM = not get_option('disable_drm')
+
+WITH_X11 = false
+if get_option('with_x11') != 'no'
+  x11_dep = dependency('x11', required : get_option('with_x11') == 'yes')
+  xext_dep = dependency('xext', required : get_option('with_x11') == 'yes')
+  xfixes_dep = dependency('xfixes', required : get_option('with_x11') == 'yes')
+
+  WITH_X11 = (x11_dep.found() and xext_dep.found() and xfixes_dep.found())
+endif
+
+if not WITH_X11 and get_option('with_glx') == 'yes'
+  error('VA/GLX explicitly enabled, but VA/X11 isn\'t built')
+endif
+
+WITH_GLX = false
+if WITH_X11 and get_option('with_glx') != 'no'
+  gl_dep = dependency('gl', required : get_option('with_glx') == 'yes')
+  WITH_GLX = gl_dep.found()
+endif
+
+WITH_WAYLAND = false
+if get_option('with_wayland') != 'no'
+  wayland_dep = dependency('wayland-client', version : '>= 1.11.0',
+                          required : get_option('with_wayland') == 'yes')
+  if wayland_dep.found()
+    prefix = wayland_dep.get_pkgconfig_variable('prefix')
+    wl_scanner = find_program('wayland-scanner',
+                             prefix + '/bin/wayland-scanner')
+  endif
+  WITH_WAYLAND = wayland_dep.found()
+endif
+
+
+if (not WITH_DRM and not WITH_X11 and not WITH_WAYLAND)
+  error('Please install at least one backend dev files (DRM, X11, Wayland)')
+endif
+
+subdir('va')
+subdir('pkgconfig')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644 (file)
index 0000000..3b9a68a
--- /dev/null
@@ -0,0 +1,5 @@
+option('driverdir', type : 'string', description : 'drivers path')
+option('disable_drm', type : 'boolean', value : false)
+option('with_x11', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
+option('with_glx', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
+option('with_wayland', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
diff --git a/pkgconfig/meson.build b/pkgconfig/meson.build
new file mode 100644 (file)
index 0000000..b7f7015
--- /dev/null
@@ -0,0 +1,39 @@
+pkgconf = configuration_data()
+
+pkgconf.set('prefix', get_option('prefix'))
+pkgconf.set('exec_prefix', '${prefix}')
+pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
+pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
+pkgconf.set('LIBVA_VERSION', libva_version)
+pkgconf.set('VA_API_VERSION', va_api_version)
+pkgconf.set('LIBVA_DRIVERS_PATH', driverdir)
+
+pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))
+
+pkg_files = [ 'libva' ]
+
+if WITH_DRM
+  pkg_files += [ 'libva-drm' ]
+endif
+
+if WITH_X11
+  pkg_files += [ 'libva-x11' ]
+endif
+
+if WITH_GLX
+  pkg_files += [ 'libva-glx' ]
+endif
+
+if WITH_WAYLAND
+  pkg_files += [ 'libva-wayland' ]
+endif
+
+foreach p : pkg_files
+  infile = p + '.pc.in'
+  outfile = p + '.pc'
+  configure_file(
+    input : infile,
+    output : outfile,
+    configuration : pkgconf,
+    install_dir : pkg_install_dir)
+endforeach
diff --git a/va/meson.build b/va/meson.build
new file mode 100644 (file)
index 0000000..eef6acf
--- /dev/null
@@ -0,0 +1,254 @@
+version_cfg = configuration_data()
+version_cfg.set('VA_API_MAJOR_VERSION', va_api_major_version)
+version_cfg.set('VA_API_MINOR_VERSION', va_api_minor_version)
+version_cfg.set('VA_API_MICRO_VERSION', va_api_micro_version)
+version_cfg.set('VA_API_VERSION', va_api_version)
+
+version_file = configure_file(
+  input : 'va_version.h.in',
+  output : 'va_version.h',
+  configuration : version_cfg)
+
+libva_sources = [
+  'va.c',
+  'va_compat.c',
+  'va_fool.c',
+  'va_str.c',
+  'va_trace.c',
+]
+
+libva_headers = [
+  'va.h',
+  'va_backend.h',
+  'va_backend_vpp.h',
+  'va_compat.h',
+  'va_dec_hevc.h',
+  'va_dec_jpeg.h',
+  'va_dec_vp8.h',
+  'va_dec_vp9.h',
+  'va_drmcommon.h',
+  'va_egl.h',
+  'va_enc_hevc.h',
+  'va_enc_h264.h',
+  'va_enc_jpeg.h',
+  'va_enc_vp8.h',
+  'va_fei.h',
+  'va_fei_h264.h',
+  'va_enc_mpeg2.h',
+  'va_enc_vp9.h',
+  'va_str.h',
+  'va_tpi.h',
+  'va_vpp.h',
+  version_file,
+]
+
+libva_headers_priv = [
+  'sysdeps.h',
+  'va_fool.h',
+  'va_internal.h',
+  'va_trace.h',
+]
+
+libva_sym = 'libva.syms'
+libva_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libva_sym)
+
+install_headers(libva_headers, subdir : 'va')
+
+libva = shared_library(
+  'va',
+  sources : libva_sources +
+            libva_headers +
+            libva_headers_priv,
+  soversion : libva_lt_current,
+  version : libva_lt_version,
+  c_args : '-DVA_DRIVERS_PATH="' + driverdir + '"',
+  include_directories : configinc,
+  link_args : '-Wl,-version-script,' + libva_sym_path,
+  link_depends : libva_sym,
+  install : true,
+  dependencies : [ dl_dep ])
+
+libva_dep = declare_dependency(
+  link_with : libva,
+  include_directories : configinc,
+  dependencies : [ dl_dep ])
+
+if WITH_DRM
+  libva_drm_sources = [
+    'drm/va_drm.c',
+    'drm/va_drm_auth.c',
+    'drm/va_drm_utils.c',
+  ]
+
+  libva_drm_headers = [
+    'drm/va_drm.h',
+  ]
+
+  libva_drm_headers_priv = [
+    'drm/va_drm_auth.h',
+    'drm/va_drm_auth_x11.h',
+    'drm/va_drm_utils.h',
+  ]
+
+  deps = [ libdrm_dep ]
+
+  libva_drm_args = []
+  if get_option('with_x11') != 'no' and x11_dep.found()
+    libva_drm_sources += [ 'drm/va_drm_auth_x11.c' ]
+    libva_drm_args += [
+      '-DLIBVA_MAJOR_VERSION=@0@'.format(libva_major_version)
+    ]
+    deps += [ x11_dep ]
+  endif
+
+  install_headers(libva_drm_headers, subdir : 'va')
+
+  libva_drm = shared_library(
+    'va-drm',
+    sources : libva_drm_sources +
+              libva_drm_headers +
+              libva_drm_headers_priv,
+    soversion : libva_lt_current,
+    version : libva_lt_version,
+    install : true,
+    c_args : libva_drm_args,
+    dependencies : deps + [ libva_dep ])
+
+  libva_drm_dep = declare_dependency(
+    link_with : libva_drm,
+    include_directories : configinc,
+    dependencies : deps)
+endif
+
+if WITH_X11
+  libva_x11_sources = [
+    'x11/dri2_util.c',
+    'x11/va_dri2.c',
+    'x11/va_dricommon.c',
+    'x11/va_fglrx.c',
+    'x11/va_nvctrl.c',
+    'x11/va_x11.c',
+  ]
+
+  libva_x11_headers = [
+    'va_x11.h',
+    'x11/va_dri2.h',
+    'x11/va_dricommon.h',
+  ]
+
+  libva_x11_headers_priv = [
+    'x11/va_dri2str.h',
+    'x11/va_dri2tokens.h',
+    'x11/va_fglrx.h',
+    'x11/va_nvctrl.h',
+  ]
+
+  install_headers(libva_x11_headers, subdir : 'va')
+
+  deps = [ libdrm_dep, x11_dep, xext_dep, xfixes_dep, libva_dep ]
+
+  libva_x11 = shared_library(
+    'va-x11',
+    sources : libva_x11_sources +
+              libva_x11_headers +
+              libva_x11_headers_priv,
+    soversion : libva_lt_current,
+    version : libva_lt_version,
+    install : true,
+    dependencies : deps)
+
+  libva_x11_dep = declare_dependency(
+    link_with : libva_x11,
+    include_directories : configinc,
+    dependencies : deps)
+endif
+
+if WITH_GLX
+  libva_glx_sources = [
+    'glx/va_glx.c',
+    'glx/va_glx_impl.c',
+  ]
+
+  libva_glx_headers = [
+    'glx/va_backend_glx.h',
+    'glx/va_glx.h',
+  ]
+
+  libva_glx_headers_priv = [
+    'glx/va_glx_impl.h',
+    'glx/va_glx_private.h',
+  ]
+
+  install_headers(libva_glx_headers, subdir : 'va')
+
+  deps = [ gl_dep, libva_x11_dep ]
+
+  libva_glx = shared_library(
+    'va-glx',
+    sources : libva_glx_sources +
+              libva_glx_headers +
+              libva_glx_headers_priv,
+    soversion : libva_lt_current,
+    version : libva_lt_version,
+    install : true,
+    dependencies : deps)
+
+  libva_glx_dep = declare_dependency(
+    link_with : libva_glx,
+    include_directories : configinc,
+    dependencies : deps)
+endif
+
+if WITH_WAYLAND
+  libva_wayland_sources = [
+    'wayland/va_wayland.c',
+    'wayland/va_wayland_drm.c',
+    'wayland/va_wayland_emgd.c',
+    'drm/va_drm_utils.c',
+  ]
+
+  libva_wayland_headers = [
+    'wayland/va_backend_wayland.h',
+    'wayland/va_wayland.h',
+  ]
+
+  libva_wayland_headers_priv = [
+    'wayland/va_wayland_drm.h',
+    'wayland/va_wayland_emgd.h',
+    'wayland/va_wayland_private.h',
+  ]
+
+  protocol_files = [
+    custom_target(
+      'wayland-drm-client-protocol.c',
+      output : 'wayland-drm-client-protocol.c',
+      input : 'wayland/wayland-drm.xml',
+      command : [wl_scanner, 'code', '@INPUT@', '@OUTPUT@']),
+
+    custom_target(
+      'wayland-drm-client-protocol.h',
+      output : 'wayland-drm-client-protocol.h',
+      input : 'wayland/wayland-drm.xml',
+      command : [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])
+  ]
+
+  install_headers(libva_wayland_headers, subdir : 'va')
+
+  deps = [ libdrm_dep, wayland_dep, libva_dep ]
+
+  libva_wayland = shared_library(
+    'va-wayland',
+    sources : libva_wayland_sources +
+              libva_wayland_headers +
+              libva_wayland_headers_priv +
+              protocol_files,
+    soversion : libva_lt_current,
+    version : libva_lt_version,
+    install : true,
+    dependencies : deps)
+
+  libva_wayland_dep = declare_dependency(
+    link_with : libva_wayland,
+    include_directories : configinc,
+    dependencies : deps)
+endif