[PATCH wayland-protocols 1/3] Add meson build system support

Jonas Ådahl jadahl at gmail.com
Wed Oct 11 09:00:11 UTC 2017


Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 meson.build             | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt       |  4 +++
 tests/meson.build       | 13 ++++++++
 wayland-protocols.pc.in |  2 +-
 4 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 tests/meson.build

diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..b7f2a5b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,81 @@
+project('wayland-protocols',
+        version: '1.11',
+        meson_version: '>= 0.36.0')
+wayland_protocols_version = meson.project_version()
+
+stable_protocols = [
+  'stable/presentation-time/presentation-time.xml',
+  'stable/viewporter/viewporter.xml',
+]
+
+unstable_protocols = [
+  'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml',
+  'unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml',
+  'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml',
+  'unstable/text-input/text-input-unstable-v1.xml',
+  'unstable/input-method/input-method-unstable-v1.xml',
+  'unstable/xdg-shell/xdg-shell-unstable-v5.xml',
+  'unstable/xdg-shell/xdg-shell-unstable-v6.xml',
+  'unstable/relative-pointer/relative-pointer-unstable-v1.xml',
+  'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml',
+  'unstable/tablet/tablet-unstable-v1.xml',
+  'unstable/tablet/tablet-unstable-v2.xml',
+  'unstable/xdg-foreign/xdg-foreign-unstable-v1.xml',
+  'unstable/xdg-foreign/xdg-foreign-unstable-v2.xml',
+  'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml',
+  'unstable/xwayland-keyboard-grab/xwayland-keyboard-grab-unstable-v1.xml',
+  'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml',
+  'unstable/xdg-output/xdg-output-unstable-v1.xml',
+]
+
+protocols = stable_protocols + unstable_protocols
+
+# Check that each protocol has a README
+foreach protocol : protocols
+  protocol_components = protocol.split('/')
+  stability = protocol_components[0]
+  protocol_name = protocol_components[1]
+  readme_path = join_paths(meson.source_root(),
+                           stability,
+                           protocol_name,
+                           'README')
+  if run_command('[', '-f', readme_path, ']').returncode() != 0
+    error('Missing README in @0@'.format(protocol))
+  endif
+endforeach
+
+wayland_scanner = find_program('wayland-scanner')
+
+foreach protocol : stable_protocols + unstable_protocols
+  protocol_components = protocol.split('/')
+  stability = protocol_components[0]
+  protocol_name = protocol_components[1]
+  xml_file = protocol_components[2]
+  protocol_install_dir = join_paths(get_option('datadir'),
+                                    'wayland-protocols',
+                                    stability,
+                                    protocol_name)
+  install_data(protocol,
+               install_dir: protocol_install_dir)
+endforeach
+
+pkgconfig_configuration = configuration_data()
+pkgconfig_configuration.set('prefix', get_option('prefix'))
+pkgconfig_configuration.set('datadir', get_option('datadir'))
+pkgconfig_configuration.set('abs_top_srcdir', meson.source_root())
+pkgconfig_configuration.set('PACKAGE', 'wayland-protocols')
+pkgconfig_configuration.set('WAYLAND_PROTOCOLS_VERSION', wayland_protocols_version)
+
+pkg_install_dir = join_paths(get_option('datadir'), 'pkgconfig')
+configure_file(input: 'wayland-protocols.pc.in',
+               output: 'wayland-protocols.pc',
+               configuration: pkgconfig_configuration,
+               install_dir: pkg_install_dir)
+
+configure_file(input: 'wayland-protocols-uninstalled.pc.in',
+               output: 'wayland-protocols-uninstalled.pc',
+               configuration: pkgconfig_configuration)
+
+if get_option('tests')
+  subdir('tests')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..3ce457d
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,4 @@
+option('tests',
+       type: 'boolean',
+       value: true,
+       description: 'Build the tests [default=true]')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..267a36a
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,13 @@
+scan_sh = find_program('scan.sh')
+wayland_scanner = find_program('wayland-scanner')
+
+# Check that each protocol passes through the scanner
+foreach protocol : protocols
+  protocol_path = join_paths(meson.source_root(), protocol)
+  test_name = 'scan- at 0@'.format('protocol_file')
+  test(test_name, scan_sh,
+       args: protocol_path,
+       env: [
+         'SCANNER=@0@'.format(wayland_scanner.path()),
+       ])
+endforeach
diff --git a/wayland-protocols.pc.in b/wayland-protocols.pc.in
index 379be06..bd082e1 100644
--- a/wayland-protocols.pc.in
+++ b/wayland-protocols.pc.in
@@ -1,5 +1,5 @@
 prefix=@prefix@
-datarootdir=@datarootdir@
+datarootdir=${prefix}/@datadir@
 pkgdatadir=${pc_sysrootdir}@datadir@/@PACKAGE@
 
 Name: Wayland Protocols
-- 
2.13.5



More information about the wayland-devel mailing list