From: Emmanuele Bassi <eba...@gnome.org>

Meson is a next generation build system, and various projects in the
larger Linux ecosystem already moved to it — for instance:

  - the X11 server
  - the X11 protocols repository
  - Mesa
  - libdrm

The added benefit for adding Meson support is that projects using Meson
and depending on wayland-protocols can use the subproject functionality
to always pull the latest version of the protocols without necessarily
updating their build environment.
---
 meson.build       | 89 +++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt |  5 +++
 2 files changed, 94 insertions(+)
 create mode 100644 meson.build
 create mode 100644 meson_options.txt

diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c078ff3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,89 @@
+project('wayland-protocols', 'c',
+  version: '1.13',
+  license: 'MIT',
+  meson_version: '>= 0.45.0',
+)
+
+wayland_scanner_dep = dependency('wayland-scanner', required: false)
+wayland_scanner_opt = get_option('wayland_scanner')
+wayland_scanner_bin = ['wayland-scanner']
+
+if wayland_scanner_opt != ''
+  wayland_scanner_bin += wayland_scanner_opt
+endif
+
+if wayland_scanner_dep.found()
+  wayland_scanner_bin += 
wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner')
+endif
+
+wayland_scanner = find_program(wayland_scanner_bin)
+
+pkgdatadir = join_paths(get_option('datadir'), meson.project_name())
+
+protocol_files = []
+
+# name, [version, ...]
+unstable_protocols = [
+  [ 'pointer-gestures', ['v1',], ],
+  [ 'fullscreen-shell', ['v1',], ],
+  [ 'linux-dmabuf', ['v1',], ],
+  [ 'text-input', ['v1',], ],
+  [ 'input-method', ['v1',], ],
+  [ 'xdg-shell', ['v5', 'v6',], ],
+  [ 'relative-pointer', ['v1',], ],
+  [ 'pointer-constraints', ['v1',], ],
+  [ 'tablet', ['v1', 'v2',], ],
+  [ 'xdg-foreign', ['v1', 'v2',], ],
+  [ 'idle-inhibit', ['v1',], ],
+  [ 'xwayland-keyboard-grab', ['v1',], ],
+  [ 'keyboard-shortcuts-inhibit', ['v1',], ],
+  [ 'xdg-output', ['v1',], ],
+  [ 'input-timestamps', ['v1',], ],
+]
+
+foreach p: unstable_protocols
+  p_name = p[0]
+  p_versions = p[1]
+  foreach version: p_versions
+    xml_file = join_paths('unstable', p_name, 
'@0@-unstable-@1@.xml'.format(p_name, version))
+    protocol_files += [[p_name, files(xml_file)]]
+    install_data(xml_file, install_dir: join_paths(pkgdatadir, 'unstable', 
p_name))
+  endforeach
+endforeach
+
+stable_protocols = [
+  'presentation-time',
+  'viewporter',
+  'xdg-shell',
+]
+
+foreach p_name: stable_protocols
+  xml_file = join_paths('stable', p_name, '@0@.xml'.format(p_name))
+  protocol_files += [[p_name, files(xml_file)]]
+  install_data(xml_file, install_dir: join_paths(pkgdatadir, 'stable', p_name))
+endforeach
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(
+  name: meson.project_name(),
+  description: 'Wayland protocol files',
+  version: meson.project_version(),
+  variables: [
+    'datarootdir=${prefix}/@0@'.format(get_option('datadir')),
+    
'pkgdatadir=${pc_sysrootdir}${datarootdir}/@0@'.format(meson.project_name()),
+  ],
+  install_dir: join_paths(get_option('datadir'), 'pkgconfig'),
+)
+
+scan_test = find_program('tests/scan.sh')
+foreach p: protocol_files
+  p_name = p[0]
+  p_file = p[1]
+  test('verify ' + p_name,
+    scan_test,
+    args: [ p_file, ],
+    env: [
+      'SCANNER=@0@'.format(wayland_scanner.path()),
+    ],
+  )
+endforeach
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..09a8618
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('wayland_scanner',
+  description: 'The wayland-scanner binary to use',
+  type: 'string',
+  value: ''
+)
-- 
2.17.0

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to