Discussion:
[PATCH wayland v4 2/5] Support running tests from different build directories
Daniel Stone
2018-08-28 22:19:16 UTC
Permalink
From: Emmanuele Bassi <***@gnome.org>

The tests that run exec-fd-leak-checker expect the binary to be located
in the current directory. This is not always the case; for instance, the
binaries could be built under `tests`, but be invoked under the
top-level build directory.

We can use an environment variable to control what's the location of the
test binaries, and fall back to the current directory if the variable is
unset.

Reviewed-by: Daniel Stone <***@collabora.com>
---
tests/test-helpers.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/test-helpers.c b/tests/test-helpers.c
index b2189d8e..20b66903 100644
--- a/tests/test-helpers.c
+++ b/tests/test-helpers.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
@@ -67,11 +68,19 @@ count_open_fds(void)
void
exec_fd_leak_check(int nr_expected_fds)
{
- const char *exe = "./exec-fd-leak-checker";
+ const char *exe = "exec-fd-leak-checker";
char number[16] = { 0 };
+ const char *test_build_dir = getenv("TEST_BUILD_DIR");
+ char exe_path[256] = { 0 };
+
+ if (test_build_dir == NULL || test_build_dir[0] == 0) {
+ test_build_dir = ".";
+ }
+
+ snprintf(exe_path, sizeof exe_path - 1, "%s/%s", test_build_dir, exe);

snprintf(number, sizeof number - 1, "%d", nr_expected_fds);
- execl(exe, exe, number, (char *)NULL);
+ execl(exe_path, exe, number, (char *)NULL);
assert(0 && "execing fd leak checker failed");
}
--
2.17.1
Daniel Stone
2018-08-28 22:19:18 UTC
Permalink
From: Emmanuele Bassi <***@gnome.org>

Add a script which generates the desired Doxygen configuration for our
various output formats and executes it using that configuration.

[daniels: Properly install into mandir/man3 via some gross
paramaterisation, generate real stamp files.]

Reviewed-by: Daniel Stone <***@collabora.com>
---
doc/doxygen/.gitignore | 1 +
doc/doxygen/gen-doxygen.py | 105 ++++++++++++++++++++++++++++++++
doc/doxygen/meson.build | 115 ++++++++++++++++++++++++++++++++++++
doc/doxygen/xml/meson.build | 18 ++++++
doc/meson.build | 6 +-
5 files changed, 240 insertions(+), 5 deletions(-)
create mode 100755 doc/doxygen/gen-doxygen.py
create mode 100644 doc/doxygen/meson.build
create mode 100644 doc/doxygen/xml/meson.build

diff --git a/doc/doxygen/.gitignore b/doc/doxygen/.gitignore
index a85e6c0d..5c544d6c 100644
--- a/doc/doxygen/.gitignore
+++ b/doc/doxygen/.gitignore
@@ -2,3 +2,4 @@ doxygen_sqlite3.db
html/
wayland.doxygen
xml/
+!xml/meson.build
diff --git a/doc/doxygen/gen-doxygen.py b/doc/doxygen/gen-doxygen.py
new file mode 100755
index 00000000..1bb07e57
--- /dev/null
+++ b/doc/doxygen/gen-doxygen.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+
+import argparse
+import datetime
+import errno
+import os
+import subprocess
+import sys
+
+# Custom configuration for each documentation format
+doxygen_templates = {
+ 'xml': [
+ 'GENERATE_XML=YES\n',
+ 'XML_OUTPUT={format}/{section}\n',
+ 'INPUT= {files}\n',
+ ],
+ 'html': [
+ 'GENERATE_HTML=YES\n',
+ 'HTML_OUTPUT={format}/{section}\n',
+ 'PROJECT_NAME=\"Wayland {section} API\"\n',
+ 'INPUT= {files}\n',
+ ],
+ 'man': [
+ 'GENERATE_MAN=YES\n',
+ 'MAN_OUTPUT={format}\n',
+ 'MAN_SUBDIR=.\n',
+ 'JAVADOC_AUTOBRIEF=NO\n',
+ 'INPUT= {files}\n',
+ ],
+}
+
+def load_doxygen_file(doxyfile):
+ with open(doxyfile, 'r') as f:
+ res = f.readlines()
+ return res
+
+def get_template(outformat):
+ for (k,v) in doxygen_templates.items():
+ if outformat.startswith(k):
+ return v
+
+def gen_doxygen_file(data, outformat, section, files):
+ for l in get_template(outformat):
+ data.append(l.format(format=outformat, section=section, files=' '.join(files)))
+ return data
+
+parser = argparse.ArgumentParser(description='Generate docs with Doxygen')
+parser.add_argument('doxygen_file',
+ help='The doxygen file to use')
+parser.add_argument('files',
+ help='The list of files to parse',
+ metavar='FILES',
+ nargs='+')
+parser.add_argument('--builddir',
+ help='The build directory',
+ metavar='DIR',
+ default='.')
+parser.add_argument('--section',
+ help='The section to build',
+ metavar='NAME',
+ default='Client')
+parser.add_argument('--output-format',
+ help='The output format: xml, html, man',
+ metavar='FORMAT',
+ default='xml')
+parser.add_argument('--stamp',
+ help='Stamp file to output',
+ metavar='STAMP_FILE',
+ nargs='?',
+ type=argparse.FileType('w'))
+
+args = parser.parse_args()
+
+# Merge the doxyfile with our custom templates
+conf = load_doxygen_file(args.doxygen_file)
+conf = gen_doxygen_file(conf, args.output_format, args.section, args.files)
+
+# Doxygen is not clever enough to create the directories it
+# needs beforehand
+try:
+ os.makedirs(os.path.join(args.builddir, args.output_format))
+except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise e
+
+# Run Doxygen with the generated doxyfile
+cmd = subprocess.Popen(['doxygen', '-'], stdin=subprocess.PIPE)
+cmd.stdin.write(''.join(conf).encode('utf-8'))
+cmd.stdin.close()
+if cmd.wait() != 0:
+ sys.exit(1)
+
+# This is a bit of a hack; Doxygen will generate way more files than we
+# want to install, but there's no way to know how many at configuration
+# time. Since we want to install only the wl_* man pages anyway, we can
+# delete the other files and let Meson install the whole man3 subdirectory
+if args.output_format.startswith('man'):
+ manpath = os.path.join(args.builddir, args.output_format)
+ for filename in os.listdir(manpath):
+ full_path = os.path.join(manpath, filename)
+ if not filename.startswith('wl_'):
+ os.remove(full_path)
+
+if args.stamp:
+ args.stamp.write(str(datetime.datetime.now()))
diff --git a/doc/doxygen/meson.build b/doc/doxygen/meson.build
new file mode 100644
index 00000000..68523631
--- /dev/null
+++ b/doc/doxygen/meson.build
@@ -0,0 +1,115 @@
+# Here be dragons
+doxygen = find_program('doxygen')
+
+dot = find_program('dot')
+dot_gv = [
+ [ 'wayland-architecture', files('dot/wayland-architecture.gv') ],
+ [ 'x-architecture', files('dot/x-architecture.gv') ],
+]
+
+# This is a workaround for Meson's custom_target() directive, which
+# currently does not support outputs pointing to a sub-directory
+dot_png = []
+dot_map = []
+subdir('xml')
+
+doxygen = configuration_data()
+doxygen.set('VERSION', meson.project_version())
+doxygen.set('top_builddir', meson.build_root())
+wayland_doxygen = configure_file(
+ input: 'wayland.doxygen.in',
+ output: 'wayland.doxygen',
+ configuration: doxygen,
+)
+
+shared_files = files([
+ '../../src/wayland-util.h',
+])
+
+client_files = files([
+ '../../src/wayland-client.c',
+ '../../src/wayland-client.h',
+ '../../src/wayland-client-core.h',
+])
+
+server_files = files([
+ '../../src/event-loop.c',
+ '../../src/wayland-server.c',
+ '../../src/wayland-server.h',
+ '../../src/wayland-server-core.h',
+ '../../src/wayland-shm.c',
+])
+
+extra_client_files = [
+ 'mainpage.dox',
+ wayland_client_protocol_h,
+]
+
+extra_server_files = [
+ 'mainpage.dox',
+ wayland_server_protocol_h,
+]
+
+# formats = [ format_name, [ [ section_name, files ] ] ]
+formats = [
+ [
+ 'xml', [
+ [ 'Client', shared_files + client_files, ],
+ [ 'Server', shared_files + server_files, ],
+ ]
+ ],
+ [
+ 'html', [
+ [ 'Client', shared_files + client_files + extra_client_files, ],
+ [ 'Server', shared_files + server_files + extra_server_files, ],
+ ]
+ ],
+]
+
+gen_doxygen = find_program('gen-doxygen.py')
+foreach f: formats
+ f_name = f[0]
+ sections = f[1]
+
+ foreach s: sections
+ s_name = s[0]
+ s_files = s[1]
+ t_name = '@0@-@1@-doc'.format(f_name, s_name)
+
+ # We do not really need an output file, but Meson
+ # will complain if one is not set, so we use a
+ # dummy 'stamp' file
+ custom_target(t_name,
+ command: [
+ gen_doxygen,
+ '--builddir=@OUTDIR@',
+ '--section=@0@'.format(s_name),
+ '--output-format=@0@'.format(f_name),
+ '--stamp=doc/doxygen/@***@.stamp'.format(t_name),
+ wayland_doxygen,
+ '@INPUT@',
+ ],
+ input: s_files,
+ output: '@***@.stamp'.format(t_name),
+ depends: [dot_png, dot_map],
+ build_by_default: true,
+ )
+ endforeach
+endforeach
+
+man_files = shared_files + client_files + server_files
+custom_target('man-pages-3',
+ command: [
+ gen_doxygen,
+ '--builddir=@OUTDIR@',
+ '--output-format=man3',
+ '--stamp=doc/doxygen/man3.stamp',
+ wayland_doxygen,
+ '@INPUT@',
+ ],
+ input: man_files,
+ output: 'man3',
+ build_by_default: true,
+ install: true,
+ install_dir: join_paths(get_option('prefix'), get_option('mandir')),
+)
diff --git a/doc/doxygen/xml/meson.build b/doc/doxygen/xml/meson.build
new file mode 100644
index 00000000..58826c51
--- /dev/null
+++ b/doc/doxygen/xml/meson.build
@@ -0,0 +1,18 @@
+# dot_png: list of PNG targets
+# dot_map: list of MAP targets
+foreach gv: dot_gv
+ name = gv[0]
+ infile = gv[1]
+
+ dot_png += custom_target(name + '.png',
+ command: [ dot, '-Tpng', '-***@OUTPUT@', '@INPUT@' ],
+ input: infile,
+ output: name + '.png',
+ )
+
+ dot_map += custom_target(name + '.map',
+ command: [ dot, '-Tcmapx_np', '-***@OUTPUT@', '@INPUT@' ],
+ input: infile,
+ output: name + '.map',
+ )
+endforeach
diff --git a/doc/meson.build b/doc/meson.build
index 8c743fe9..f05c57b3 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -1,5 +1 @@
-xsltproc = find_program('xsltproc', required: false)
-doxygen = find_program('doxygen')
-xmlto = find_program('xmlto')
-dot = find_program('dot')
-
+subdir('doxygen')
--
2.17.1
Pekka Paalanen
2018-08-30 14:31:40 UTC
Permalink
On Tue, 28 Aug 2018 23:19:18 +0100
Post by Daniel Stone
Add a script which generates the desired Doxygen configuration for our
various output formats and executes it using that configuration.
[daniels: Properly install into mandir/man3 via some gross
paramaterisation, generate real stamp files.]
---
doc/doxygen/.gitignore | 1 +
doc/doxygen/gen-doxygen.py | 105 ++++++++++++++++++++++++++++++++
doc/doxygen/meson.build | 115 ++++++++++++++++++++++++++++++++++++
doc/doxygen/xml/meson.build | 18 ++++++
doc/meson.build | 6 +-
5 files changed, 240 insertions(+), 5 deletions(-)
create mode 100755 doc/doxygen/gen-doxygen.py
create mode 100644 doc/doxygen/meson.build
create mode 100644 doc/doxygen/xml/meson.build
Hi,

I read through this whole ordeal, and there is only one thing I can
complain about: it doesn't actually install the docs. I mean the
$prefix/share/doc directory where at the end of the dungeon should be
the HTML docs.

The contortions to get this even building are so nasty that the end
result is impressively clean. I'm ok with all the code here so far.
Once the docs get installed, I could diff the installed files.

Mind, autotools builddir=srcdir 'make distclean' will wipe
doc/doxygen/xml/meson.build.


Thanks,
pq

Daniel Stone
2018-08-28 22:19:19 UTC
Permalink
From: Emmanuele Bassi <***@gnome.org>

There are ancillary man pages not built by Doxygen that we need to
generate an install.
---
doc/man/meson.build | 64 +++++++++++++++++++++++++++++++++++++++++++++
doc/meson.build | 1 +
2 files changed, 65 insertions(+)
create mode 100644 doc/man/meson.build

diff --git a/doc/man/meson.build b/doc/man/meson.build
new file mode 100644
index 00000000..211dc203
--- /dev/null
+++ b/doc/man/meson.build
@@ -0,0 +1,64 @@
+xsltproc = find_program('xsltproc', required: false)
+
+manpage_xsl = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
+man_pages = []
+
+if xsltproc.found()
+ cmd = run_command([xsltproc, '--nonet', manpage_xsl])
+ have_manpage_xsl = cmd.returncode() == 0
+else
+ warning('No docbook stylesheet found for generating man pages')
+ have_manpage_xsl = false
+endif
+
+if have_manpage_xsl
+ # man section, [ [ xml_file, name, alias ] ]
+ man_pages += [
+ [
+ '3', [
+ [ 'wl_display_connect.xml', 'wl_display_connect', 'wl_display_connect_to_fd' ],
+ ],
+ ]
+ ]
+endif
+
+xsltproc_opts = [
+ '--nonet',
+ '--stringparam', 'man.authors.section.enabled', '0',
+ '--stringparam', 'man.copyright.section.enabled', '0',
+ '--stringparam', 'funcsynopsis.style', 'ansi',
+ '--stringparam', 'man.output.quietly', '1',
+]
+
+foreach section: man_pages
+ section_number = section[0]
+ pages = section.get(1, [])
+
+ foreach page: pages
+ xml_input = page[0]
+ name = page[1]
+ alias = page.get(2, '')
+
+ man_output = name + '.' + section_number
+ if alias != ''
+ alias_output = alias + '.' + section_number
+ else
+ alias_output = []
+ endif
+
+ man_page = custom_target(name + '-man',
+ command: [
+ xsltproc,
+ xsltproc_opts,
+ '-o', '@OUTPUT0@',
+ manpage_xsl,
+ '@INPUT@',
+ ],
+ input: xml_input,
+ output: [ man_output, alias_output ],
+ install: true,
+ install_dir: join_paths(get_option('prefix'), get_option('mandir'), 'man' + section_number),
+ build_by_default: true,
+ )
+ endforeach
+endforeach
diff --git a/doc/meson.build b/doc/meson.build
index f05c57b3..a1928800 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -1 +1,2 @@
subdir('doxygen')
+subdir('man')
--
2.17.1
Daniel Stone
2018-08-28 22:19:17 UTC
Permalink
From: Emmanuele Bassi <***@gnome.org>

Meson is a next generation build system, simpler than Autotools and,
more importantly, faster and more portable. While the latter
consideration is of lesser importance for Wayland, being easier to
understand and faster are pretty much key reasons to switch.

This is mostly a mechanical port of Wayland to the Meson build system.

The goal is to maintain feature parity of the Meson build with the
Autotools build, until such time when we can drop the latter.

[daniels: Changed to bump version, use GitLab issues URL, remove header
checks not used in any code, remove pre-pkg-config Expat
support, added missing include paths to wayland-egl and
cpp-compile-test, added GitLab CI.
Bumped version, removed unnecessary pkg-config paths.]

Reviewed-by: Daniel Stone <***@collabora.com>
Acked-by: Emre Ucan <***@de.adit-jv.com>
Acked-by: Peter Hutterer <***@who-t.net>
---
.gitlab-ci.yml | 24 +++++-
cursor/meson.build | 29 +++++++
doc/meson.build | 5 ++
egl/meson.build | 43 ++++++++++
meson.build | 94 +++++++++++++++++++++
meson_options.txt | 20 +++++
src/meson.build | 200 +++++++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 180 ++++++++++++++++++++++++++++++++++++++++
8 files changed, 593 insertions(+), 2 deletions(-)
create mode 100644 cursor/meson.build
create mode 100644 doc/meson.build
create mode 100644 egl/meson.build
create mode 100644 meson.build
create mode 100644 meson_options.txt
create mode 100644 src/meson.build
create mode 100644 tests/meson.build

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 24896659..1d0018b1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,10 +9,11 @@ before_script:
- echo '#!/bin/sh' > /usr/sbin/policy-rc.d
- echo 'exit 101' >> /usr/sbin/policy-rc.d
- chmod +x /usr/sbin/policy-rc.d
+ - echo 'deb http://deb.debian.org/debian stretch-backports main' >> /etc/apt/sources.list
- apt-get update
- - apt-get -y --no-install-recommends install build-essential automake autoconf libtool pkg-config libexpat1-dev libffi-dev libxml2-dev doxygen graphviz xmlto xsltproc docbook-xsl
+ - apt-get -y --no-install-recommends install build-essential automake autoconf libtool pkg-config libexpat1-dev libffi-dev libxml2-dev doxygen graphviz xmlto xsltproc docbook-xsl meson/stretch-backports

-build-native:
+build-native-autotools:
stage: build
script:
- export BUILD_ID="wayland-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
@@ -34,3 +35,22 @@ build-native:
- build-*/wayland*/_build/sub/*.log
- build-*/*.log
- prefix-*
+
+build-native-meson:
+ stage: build
+ script:
+ - export BUILD_ID="wayland-$CI_JOB_NAME_$CI_COMMIT_SHA-$CI_JOB_ID"
+ - export PREFIX="$(pwd)/prefix-$BUILD_ID"
+ - export BUILDDIR="$(pwd)/build-$BUILD_ID"
+ - export MAKEFLAGS="-j4"
+ - mkdir "$BUILDDIR" "$PREFIX"
+ - cd "$BUILDDIR"
+ - meson --prefix="$PREFIX" -Dicon_directory=/usr/share/X11/icons ..
+ - ninja -k0 test
+ - ninja clean
+ artifacts:
+ name: wayland-meson-$CI_COMMIT_SHA-$CI_JOB_ID
+ when: always
+ paths:
+ - build-meson/meson-logs
+ - prefix-*
diff --git a/cursor/meson.build b/cursor/meson.build
new file mode 100644
index 00000000..036b7152
--- /dev/null
+++ b/cursor/meson.build
@@ -0,0 +1,29 @@
+icondir = get_option('icon_directory')
+if icondir == ''
+ icondir = join_paths(get_option('prefix'), get_option('datadir'), 'icons')
+endif
+
+wayland_cursor = library(
+ 'wayland-cursor',
+ sources: [
+ 'wayland-cursor.c',
+ 'os-compatibility.c',
+ 'xcursor.c',
+ ],
+ version: '0.0.0',
+ dependencies: [ wayland_client_dep ],
+ c_args: [
+ '-DICONDIR="@0@"'.format(icondir),
+ ],
+ install: true,
+)
+
+install_headers('wayland-cursor.h')
+
+pkgconfig.generate(
+ name: 'Wayland Cursor',
+ description: 'Wayland cursor helper library',
+ version: meson.project_version(),
+ libraries: wayland_cursor,
+ filebase: 'wayland-cursor',
+)
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 00000000..8c743fe9
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,5 @@
+xsltproc = find_program('xsltproc', required: false)
+doxygen = find_program('doxygen')
+xmlto = find_program('xmlto')
+dot = find_program('dot')
+
diff --git a/egl/meson.build b/egl/meson.build
new file mode 100644
index 00000000..5ae9805e
--- /dev/null
+++ b/egl/meson.build
@@ -0,0 +1,43 @@
+wayland_egl = library(
+ 'wayland-egl',
+ sources: [
+ 'wayland-egl.c',
+ wayland_client_protocol_h,
+ ],
+ include_directories: src_inc,
+ version: '1.0.0',
+ install: true,
+)
+
+executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c')
+
+nm_path = find_program('nm').path()
+
+test(
+ 'wayland-egl symbols check',
+ find_program('wayland-egl-symbols-check'),
+ env: [
+ 'WAYLAND_EGL_LIB=@0@'.format(wayland_egl.full_path()),
+ 'NM=@0@'.format(nm_path),
+ ],
+)
+
+install_headers([
+ 'wayland-egl.h',
+ 'wayland-egl-core.h',
+ 'wayland-egl-backend.h',
+])
+
+pkgconfig.generate(
+ name: 'wayland-egl',
+ description: 'Frontend wayland-egl library',
+ version: '18.1.0',
+ requires: 'wayland-client',
+ libraries: wayland_egl,
+)
+
+pkgconfig.generate(
+ name: 'wayland-egl-backend',
+ description: 'Backend wayland-egl library',
+ version: '3',
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..6d90625a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,94 @@
+project('wayland', 'c', 'cpp',
+ version: '1.16.90',
+ license: 'MIT',
+ meson_version: '>= 0.45.0',
+ default_options: [
+ 'warning_level=2',
+ 'buildtype=debugoptimized',
+ ])
+
+config_h = configuration_data()
+config_h.set_quoted('PACKAGE', meson.project_name())
+config_h.set_quoted('PACKAGE_NAME', meson.project_name())
+config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
+config_h.set_quoted('VERSION', meson.project_version())
+config_h.set_quoted('PACKAGE_URL', 'http://wayland.freedesktop.org')
+config_h.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/wayland/wayland/issues/')
+
+cc = meson.get_compiler('c')
+
+compiler_flags = cc.get_supported_arguments([
+ '-Wno-unused-parameter',
+ '-Wstrict-prototypes',
+ '-Wmissing-prototypes',
+ '-fvisibility=hidden',
+])
+
+add_project_arguments(compiler_flags, language: 'c')
+
+foreach h: [ 'sys/prctl.h' ]
+ config_h.set('HAVE_' + h.underscorify().to_upper(), cc.has_header(h))
+endforeach
+
+foreach f: [ 'accept4', 'mkostemp', 'posix_fallocate', 'prctl', ]
+ config_h.set('HAVE_' + f.underscorify().to_upper(), cc.has_function(f))
+endforeach
+
+if get_option('libraries')
+ ffi_dep = dependency('libffi')
+
+ decls = [
+ [ 'sys/signalfd.h', 'SFD_CLOEXEC' ],
+ [ 'sys/timerfd.h', 'TFD_CLOEXEC' ],
+ [ 'time.h', 'CLOCK_MONOTONIC' ],
+ ]
+
+ foreach d: decls
+ if not cc.has_header_symbol(d[0], d[1])
+ error('@0@ is needed to compile Wayland libraries'.format(d[1]))
+ endif
+ endforeach
+endif
+
+expat_dep = dependency('expat', required: false)
+
+if get_option('dtd_validation')
+ libxml2_dep = dependency('libxml-2.0')
+ config_h.set('HAVE_LIBXML', 1)
+endif
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+
+add_project_arguments([ '-DHAVE_CONFIG_H' ], language: 'c')
+
+pkgconfig = import('pkgconfig')
+
+root_inc = include_directories('.')
+protocol_inc = include_directories('protocol')
+src_inc = include_directories('src')
+
+subdir('src')
+
+if get_option('libraries')
+ subdir('cursor')
+ subdir('egl')
+ subdir('tests')
+endif
+
+if get_option('documentation')
+ subdir('doc')
+endif
+
+install_data([
+ 'wayland-scanner.mk',
+ 'protocol/wayland.xml',
+ 'protocol/wayland.dtd',
+])
+
+install_data(
+ [ 'wayland-scanner.m4' ],
+ install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'aclocal'),
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..78e9f9f9
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,20 @@
+option('libraries',
+ description: 'Compile Wayland libraries',
+ type: 'boolean',
+ value: 'true')
+option('host_scanner',
+ description: 'Use wayland-scanner from PATH during build',
+ type: 'boolean',
+ value: 'false')
+option('documentation',
+ description: 'Build the documentation (requires Doxygen)',
+ type: 'boolean',
+ value: 'true')
+option('dtd_validation',
+ description: 'Validate the protocol DTD (requires libxml2)',
+ type: 'boolean',
+ value: 'true')
+option('icon_directory',
+ description: 'Location used to look for cursors (defaults to ${datadir}/icons if unset)',
+ type: 'string',
+ value: '')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 00000000..388ccebe
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,200 @@
+wayland_version = meson.project_version().split('.')
+wayland_version_h = configuration_data()
+wayland_version_h.set('WAYLAND_VERSION', meson.project_version())
+wayland_version_h.set('WAYLAND_VERSION_MAJOR', wayland_version[0].to_int())
+wayland_version_h.set('WAYLAND_VERSION_MINOR', wayland_version[1].to_int())
+wayland_version_h.set('WAYLAND_VERSION_MICRO', wayland_version[2].to_int())
+configure_file(
+ input: 'wayland-version.h.in',
+ output: 'wayland-version.h',
+ configuration: wayland_version_h,
+ install: true,
+ install_dir: join_paths(get_option('prefix'), get_option('includedir')),
+)
+
+wayland_util = static_library(
+ 'wayland-util',
+ sources: 'wayland-util.c',
+)
+
+wayland_util_dep = declare_dependency(
+ link_with: wayland_util,
+ include_directories: include_directories('.'),
+)
+
+if get_option('host_scanner')
+ wayland_scanner = find_program('wayland-scanner')
+ wayland_scanner_code_arg = 'code'
+else
+ configure_file(
+ input: '../protocol/wayland.dtd',
+ output: 'wayland.dtd.embed',
+ configuration: configuration_data(),
+ )
+
+ wayland_scanner = executable(
+ 'wayland-scanner',
+ 'scanner.c',
+ 'dtddata.S',
+ include_directories: [ root_inc, protocol_inc ],
+ dependencies: [ expat_dep, libxml2_dep, wayland_util_dep, ],
+ install: true,
+ )
+ wayland_scanner_code_arg = 'public-code'
+
+ pkgconfig.generate(
+ name: 'Wayland Scanner',
+ description: 'Wayland scanner',
+ version: meson.project_version(),
+ variables: [
+ 'bindir=${prefix}/@0@'.format(get_option('bindir')),
+ 'datarootdir=${prefix}/@0@'.format(get_option('datadir')),
+ 'pkgdatadir=${prefix}/@0@/@1@'.format(get_option('datadir'), meson.project_name()),
+ 'wayland_scanner=${bindir}/wayland-scanner',
+ ],
+ filebase: 'wayland-scanner',
+ )
+endif
+
+if get_option('libraries')
+ mathlib_dep = cc.find_library('m', required: false)
+ rt_dep = dependency('threads', required: false)
+
+ wayland_protocol_xml = files('../protocol/wayland.xml')
+
+ wayland_private = static_library(
+ 'wayland-private',
+ sources: [
+ 'connection.c',
+ 'wayland-os.c',
+ ],
+ dependencies: [ ffi_dep, ],
+ )
+
+ wayland_private_dep = declare_dependency(
+ link_with: wayland_private,
+ include_directories: include_directories('.'),
+ )
+
+ generated_headers = [
+ [ 'server header', ['server-header'], 'wayland-server-protocol.h', true, ],
+ [ 'core server header', ['server-header', '-c'], 'wayland-server-protocol-core.h', false, ],
+ [ 'client header', ['client-header'], 'wayland-client-protocol.h', true, ],
+ [ 'core client header', ['client-header', '-c'], 'wayland-client-protocol-core.h', false, ],
+ ]
+
+ foreach gen: generated_headers
+ target_name = gen[0]
+ scanner_args = gen[1]
+ output_file = gen[2]
+ install_file = gen[3]
+ install_dir = join_paths(get_option('prefix'), get_option('includedir'))
+ var_name = output_file.underscorify()
+
+ target = custom_target(
+ target_name,
+ command: [
+ wayland_scanner, scanner_args, '@INPUT@', '@OUTPUT@',
+ ],
+ input: wayland_protocol_xml,
+ output: output_file,
+ install: install_file,
+ install_dir: install_dir,
+ )
+
+ set_variable(var_name, target)
+ endforeach
+
+ wayland_protocol_c = custom_target('protocol source',
+ command: [
+ wayland_scanner, wayland_scanner_code_arg, '@INPUT@', '@OUTPUT@',
+ ],
+ input: wayland_protocol_xml,
+ output: 'wayland-protocol.c',
+ )
+
+ wayland_server = library(
+ 'wayland-server',
+ sources: [
+ wayland_server_protocol_core_h,
+ wayland_server_protocol_h,
+ wayland_protocol_c,
+ 'wayland-server.c',
+ 'wayland-shm.c',
+ 'event-loop.c',
+ ],
+ version: '0.1.0',
+ dependencies: [
+ ffi_dep,
+ wayland_private_dep,
+ wayland_util_dep,
+ mathlib_dep,
+ rt_dep,
+ ],
+ include_directories: root_inc,
+ install: true,
+ )
+
+ wayland_server_dep = declare_dependency(
+ link_with: wayland_server,
+ include_directories: [ root_inc, include_directories('.') ],
+ dependencies: [ ffi_dep, mathlib_dep, rt_dep, ],
+ sources: [
+ wayland_server_protocol_core_h,
+ wayland_server_protocol_h,
+ ],
+ )
+
+ pkgconfig.generate(
+ name: 'Wayland Server',
+ description: 'Server side implementation of the Wayland protocol',
+ version: meson.project_version(),
+ libraries: wayland_server,
+ filebase: 'wayland-server',
+ )
+
+ wayland_client = library(
+ 'wayland-client',
+ sources: [
+ wayland_client_protocol_core_h,
+ wayland_client_protocol_h,
+ wayland_protocol_c,
+ 'wayland-client.c',
+ ],
+ version: '0.3.0',
+ dependencies: [
+ ffi_dep,
+ wayland_private_dep,
+ wayland_util_dep,
+ mathlib_dep,
+ rt_dep,
+ ],
+ include_directories: root_inc,
+ install: true,
+ )
+
+ pkgconfig.generate(
+ name: 'Wayland Client',
+ description: 'Wayland client side library',
+ version: meson.project_version(),
+ libraries: wayland_client,
+ filebase: 'wayland-client',
+ )
+
+ wayland_client_dep = declare_dependency(
+ link_with: wayland_client,
+ include_directories: [ root_inc, include_directories('.') ],
+ sources: [
+ wayland_client_protocol_core_h,
+ wayland_client_protocol_h,
+ ],
+ )
+
+ install_headers([
+ 'wayland-util.h',
+ 'wayland-server.h',
+ 'wayland-server-core.h',
+ 'wayland-client.h',
+ 'wayland-client-core.h',
+ ])
+endif
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 00000000..4c737aed
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,180 @@
+test_runner = static_library(
+ 'test-runner',
+ sources: [
+ 'test-runner.c',
+ 'test-helpers.c',
+ 'test-compositor.c',
+ ],
+ include_directories: [ root_inc, src_inc ],
+ dependencies: [
+ cc.find_library('dl', required: false),
+ dependency('threads'),
+ ffi_dep,
+ wayland_util_dep,
+ wayland_private_dep,
+ wayland_client_dep,
+ wayland_server_dep,
+ ],
+)
+
+test_runner_dep = declare_dependency(
+ link_with: test_runner,
+ include_directories: [ src_inc ],
+ dependencies: [
+ dependency('threads'),
+ cc.find_library('dl', required: false),
+ ],
+)
+
+tests_protocol_xml = files('../protocol/tests.xml')
+
+tests_server_protocol_h = custom_target(
+ 'test server protocol header',
+ command: [ wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@' ],
+ input: tests_protocol_xml,
+ output: 'tests-server-protocol.h',
+)
+
+tests_client_protocol_c = custom_target(
+ 'test client protocol header',
+ command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
+ input: tests_protocol_xml,
+ output: 'tests-client-protocol.h',
+)
+
+tests_protocol_c = custom_target(
+ 'test protocol source',
+ command: [ wayland_scanner, wayland_scanner_code_arg, '@INPUT@', '@OUTPUT@' ],
+ input: tests_protocol_xml,
+ output: 'tests-protocol.c',
+)
+
+benchmark(
+ 'fixed-benchmark',
+ executable(
+ 'fixed-benchmark',
+ 'fixed-benchmark.c',
+ dependencies: test_runner_dep,
+ ),
+)
+
+executable(
+ 'exec-fd-leak-checker',
+ 'exec-fd-leak-checker.c',
+ dependencies: test_runner_dep,
+)
+
+test(
+ 'cpp-compile-test',
+ executable('cpp-compile-test',
+ 'cpp-compile-test.cpp',
+ wayland_server_protocol_core_h,
+ include_directories: src_inc,
+ )
+)
+
+sed_path = find_program('sed').path()
+
+test(
+ 'scanner-test',
+ find_program('scanner-test.sh'),
+ env: [
+ 'TEST_DATA_DIR=@0@/data'.format(meson.current_source_dir()),
+ 'TEST_OUTPUT_DIR=@0@/output'.format(meson.current_build_dir()),
+ 'SED=@0@'.format(sed_path),
+ 'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()),
+ ],
+)
+
+# test name, extra sources, extra dependencies
+tests = [
+ [ 'array-test' ],
+ [ 'client-test', [
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'display-test', [
+ tests_server_protocol_h,
+ tests_client_protocol_c,
+ tests_protocol_c,
+ ],
+ ],
+ [ 'connection-test', [
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'event-loop-test', [
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'fixed-test' ],
+ [ 'interface-test', [
+ wayland_client_protocol_h,
+ ]
+ ],
+ [ 'list-test' ],
+ [ 'map-test' ],
+ [ 'sanity-test', [
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'socket-test', [
+ wayland_client_protocol_h,
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'queue-test', [
+ wayland_client_protocol_h,
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'signal-test', [
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'newsignal-test', [
+ files('../src/wayland-server.c'),
+ wayland_server_protocol_h,
+ ],
+ ],
+ [ 'resources-test', [
+ wayland_server_protocol_core_h,
+ ],
+ ],
+ [ 'message-test', [
+ wayland_client_protocol_h,
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'compositor-introspection-test', [
+ wayland_client_protocol_h,
+ wayland_server_protocol_h,
+ ]
+ ],
+ [ 'protocol-logger-test', [
+ wayland_server_protocol_core_h,
+ wayland_client_protocol_core_h,
+ ],
+ ],
+ [ 'headers-test', [
+ 'headers-protocol-test.c',
+ 'headers-protocol-core-test.c',
+ wayland_server_protocol_core_h,
+ wayland_client_protocol_core_h,
+ ],
+ ],
+ [ 'os-wrappers-test' ],
+]
+
+foreach t: tests
+ t_name = t.get(0)
+ t_sources = [ t_name + '.c' ] + t.get(1, [])
+ t_deps = [test_runner_dep] + t.get(2, [])
+ bin = executable(t_name, t_sources, dependencies: t_deps)
+ test(t_name, bin,
+ env: [
+ 'TEST_SRC_DIR=@0@'.format(meson.current_source_dir()),
+ 'TEST_BUILD_DIR=@0@'.format(meson.current_build_dir()),
+ ],
+ )
+endforeach
--
2.17.1
Daniel Stone
2018-08-28 22:23:20 UTC
Permalink
Hi,
Post by Daniel Stone
Meson is a next generation build system, simpler than Autotools and,
more importantly, faster and more portable. While the latter
consideration is of lesser importance for Wayland, being easier to
understand and faster are pretty much key reasons to switch.
This is mostly a mechanical port of Wayland to the Meson build system.
The goal is to maintain feature parity of the Meson build with the
Autotools build, until such time when we can drop the latter.
[daniels: Changed to bump version, use GitLab issues URL, remove header
checks not used in any code, remove pre-pkg-config Expat
support, added missing include paths to wayland-egl and
cpp-compile-test, added GitLab CI.
Bumped version, removed unnecessary pkg-config paths.]
Apparently it only takes two weeks of GitLab reviews for Weston for me
to forget that I need to pass --compose to git-send-email.

Patch 1/5 is unchanged since it was sent out as part of a two-part
'autotools fixes' series before the release. Patch 2/5 has had
indentation fixed, as pointed out by Peter. Patch 3/5 has had the
changes listed above. Patches 4/5 and 5/5 have had manpage build and
installation fixed.

I think this should basically be good to go now.

Cheers,
Daniel
Pekka Paalanen
2018-08-29 11:33:50 UTC
Permalink
On Tue, 28 Aug 2018 23:19:17 +0100
Post by Daniel Stone
Meson is a next generation build system, simpler than Autotools and,
more importantly, faster and more portable. While the latter
consideration is of lesser importance for Wayland, being easier to
understand and faster are pretty much key reasons to switch.
This is mostly a mechanical port of Wayland to the Meson build system.
The goal is to maintain feature parity of the Meson build with the
Autotools build, until such time when we can drop the latter.
[daniels: Changed to bump version, use GitLab issues URL, remove header
checks not used in any code, remove pre-pkg-config Expat
support, added missing include paths to wayland-egl and
cpp-compile-test, added GitLab CI.
Bumped version, removed unnecessary pkg-config paths.]
---
.gitlab-ci.yml | 24 +++++-
cursor/meson.build | 29 +++++++
doc/meson.build | 5 ++
egl/meson.build | 43 ++++++++++
meson.build | 94 +++++++++++++++++++++
meson_options.txt | 20 +++++
src/meson.build | 200 +++++++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 180 ++++++++++++++++++++++++++++++++++++++++
8 files changed, 593 insertions(+), 2 deletions(-)
create mode 100644 cursor/meson.build
create mode 100644 doc/meson.build
create mode 100644 egl/meson.build
create mode 100644 meson.build
create mode 100644 meson_options.txt
create mode 100644 src/meson.build
create mode 100644 tests/meson.build
Hi Daniel,

I see that the doc stuff comes as follow-up. This all looks quite good,
but I had a bunch of comments below.
Post by Daniel Stone
diff --git a/egl/meson.build b/egl/meson.build
new file mode 100644
index 00000000..5ae9805e
--- /dev/null
+++ b/egl/meson.build
@@ -0,0 +1,43 @@
+wayland_egl = library(
+ 'wayland-egl',
+ sources: [
+ 'wayland-egl.c',
+ wayland_client_protocol_h,
+ ],
+ include_directories: src_inc,
+ version: '1.0.0',
+ install: true,
+)
+
+executable('wayland-egl-abi-check', 'wayland-egl-abi-check.c')
+
+nm_path = find_program('nm').path()
+
+test(
+ 'wayland-egl symbols check',
+ find_program('wayland-egl-symbols-check'),
+ env: [
+ ],
+)
Oddly enough, autotools build does run wayland-egl-abi-check during
'make check'. It comes via the variable built_test_programs. It is
explicitly assigned to check_PROGRAMS which are not run by default, so
that probably confused.

The Meson build does not run it, but I think it should.
Post by Daniel Stone
+
+install_headers([
+ 'wayland-egl.h',
+ 'wayland-egl-core.h',
+ 'wayland-egl-backend.h',
+])
+
+pkgconfig.generate(
+ name: 'wayland-egl',
+ description: 'Frontend wayland-egl library',
+ version: '18.1.0',
+ requires: 'wayland-client',
+ libraries: wayland_egl,
+)
+
+pkgconfig.generate(
+ name: 'wayland-egl-backend',
+ description: 'Backend wayland-egl library',
This should be "interface", not "library", to match autotools build.
Post by Daniel Stone
+ version: '3',
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..6d90625a
--- /dev/null
+++ b/meson.build
+
+if get_option('libraries')
+ ffi_dep = dependency('libffi')
+
+ decls = [
+ [ 'sys/signalfd.h', 'SFD_CLOEXEC' ],
+ [ 'sys/timerfd.h', 'TFD_CLOEXEC' ],
+ [ 'time.h', 'CLOCK_MONOTONIC' ],
+ ]
+
+ foreach d: decls
+ if not cc.has_header_symbol(d[0], d[1])
+ endif
+ endforeach
+endif
+
+expat_dep = dependency('expat', required: false)
If the scanner gets built, how will we get a nice dependency failure
for expat?

Or, if we do get that failure already, then...
Post by Daniel Stone
+
+if get_option('dtd_validation')
+ libxml2_dep = dependency('libxml-2.0')
...there is no way to build without libxml too, if dtd_validation
is disabled, because src/meson.build has:

+ dependencies: [ expat_dep, libxml2_dep, wayland_util_dep, ],
Post by Daniel Stone
+ config_h.set('HAVE_LIBXML', 1)
+endif
+
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 00000000..388ccebe
--- /dev/null
+++ b/src/meson.build
+
+ pkgconfig.generate(
+ name: 'Wayland Scanner',
+ description: 'Wayland scanner',
+ version: meson.project_version(),
+ variables: [
+ 'wayland_scanner=${bindir}/wayland-scanner',
+ ],
+ filebase: 'wayland-scanner',
+ )
+endif
+
+if get_option('libraries')
+ mathlib_dep = cc.find_library('m', required: false)
Why not required?
Post by Daniel Stone
+ rt_dep = dependency('threads', required: false)
Why not required?
Does this not confuse -lrt with -pthread?

-lrt was added to ensure clock_gettime() is resolved.
Post by Daniel Stone
+
+ wayland_protocol_xml = files('../protocol/wayland.xml')
+
+ wayland_private = static_library(
+ 'wayland-private',
+ sources: [
+ 'connection.c',
+ 'wayland-os.c',
+ ],
+ dependencies: [ ffi_dep, ],
+ )
+
+ wayland_private_dep = declare_dependency(
+ link_with: wayland_private,
+ include_directories: include_directories('.'),
+ )
+
+ generated_headers = [
+ [ 'server header', ['server-header'], 'wayland-server-protocol.h', true, ],
+ [ 'core server header', ['server-header', '-c'], 'wayland-server-protocol-core.h', false, ],
+ [ 'client header', ['client-header'], 'wayland-client-protocol.h', true, ],
+ [ 'core client header', ['client-header', '-c'], 'wayland-client-protocol-core.h', false, ],
+ ]
+
+ foreach gen: generated_headers
+ target_name = gen[0]
+ scanner_args = gen[1]
+ output_file = gen[2]
+ install_file = gen[3]
+ install_dir = join_paths(get_option('prefix'), get_option('includedir'))
+ var_name = output_file.underscorify()
+
+ target = custom_target(
+ target_name,
+ command: [
+ ],
+ input: wayland_protocol_xml,
+ output: output_file,
+ install: install_file,
+ install_dir: install_dir,
+ )
+
+ set_variable(var_name, target)
+ endforeach
+
+ wayland_protocol_c = custom_target('protocol source',
+ command: [
+ ],
+ input: wayland_protocol_xml,
+ output: 'wayland-protocol.c',
+ )
+
+ wayland_server = library(
+ 'wayland-server',
+ sources: [
+ wayland_server_protocol_core_h,
+ wayland_server_protocol_h,
+ wayland_protocol_c,
+ 'wayland-server.c',
+ 'wayland-shm.c',
+ 'event-loop.c',
+ ],
+ version: '0.1.0',
+ dependencies: [
+ ffi_dep,
+ wayland_private_dep,
+ wayland_util_dep,
+ mathlib_dep,
+ rt_dep,
+ ],
+ include_directories: root_inc,
+ install: true,
+ )
+
+ wayland_server_dep = declare_dependency(
+ link_with: wayland_server,
+ include_directories: [ root_inc, include_directories('.') ],
+ dependencies: [ ffi_dep, mathlib_dep, rt_dep, ],
Are these dependencies here actually needed?
Those libs are already linked to wayland_server, why should the user
link to those as well, or have I misunderstood how this works in Meson?

ffi, math or rt are not present in the public API or ABI of
libwayland-server as far as I recall.
Post by Daniel Stone
+ sources: [
+ wayland_server_protocol_core_h,
+ wayland_server_protocol_h,
+ ],
+ )
+
+ pkgconfig.generate(
+ name: 'Wayland Server',
+ description: 'Server side implementation of the Wayland protocol',
+ version: meson.project_version(),
+ libraries: wayland_server,
+ filebase: 'wayland-server',
+ )
+
+ wayland_client = library(
+ 'wayland-client',
+ sources: [
+ wayland_client_protocol_core_h,
+ wayland_client_protocol_h,
+ wayland_protocol_c,
+ 'wayland-client.c',
+ ],
+ version: '0.3.0',
+ dependencies: [
+ ffi_dep,
+ wayland_private_dep,
+ wayland_util_dep,
+ mathlib_dep,
+ rt_dep,
+ ],
+ include_directories: root_inc,
+ install: true,
+ )
+
+ pkgconfig.generate(
+ name: 'Wayland Client',
+ description: 'Wayland client side library',
+ version: meson.project_version(),
+ libraries: wayland_client,
+ filebase: 'wayland-client',
+ )
Comparing autotools and meson produced files:

--- wayland-autotools/lib64/pkgconfig/wayland-client.pc 2018-08-29 14:03:40.625422118 +0300
+++ wayland-meson/lib64/pkgconfig/wayland-client.pc 2018-08-29 14:07:01.478089180 +0300
@@ -1,12 +1,11 @@
prefix=/home/pq/install/wayland
-exec_prefix=${prefix}
-datarootdir=${prefix}/share
-pkgdatadir=${datarootdir}/wayland
-libdir=${exec_prefix}/lib
+libdir=${prefix}/lib64
includedir=${prefix}/include

Name: Wayland Client
Description: Wayland client side library
Version: 1.16.90
-Cflags: -I${includedir}
+Requires.private: libffi
Libs: -L${libdir} -lwayland-client
+Libs.private: -L${libdir} -lwayland-private -lwayland-util -lm -pthread
+Cflags: -I${includedir}

Could missing exec_prefix, datarootdir, and pkgdatadir cause problems?

The addition of Requires.private and Libs.private are harmless I think,
they are only used if we installed static libraries, right?

Don't mind the lib vs. lib64 difference, autotools installed into lib
and I just renamed it to lib64 to diff.
Post by Daniel Stone
+
+ wayland_client_dep = declare_dependency(
+ link_with: wayland_client,
+ include_directories: [ root_inc, include_directories('.') ],
+ sources: [
+ wayland_client_protocol_core_h,
+ wayland_client_protocol_h,
+ ],
+ )
+
+ install_headers([
+ 'wayland-util.h',
+ 'wayland-server.h',
+ 'wayland-server-core.h',
+ 'wayland-client.h',
+ 'wayland-client-core.h',
+ ])
+endif
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 00000000..4c737aed
--- /dev/null
+++ b/tests/meson.build
+
+sed_path = find_program('sed').path()
+
+test(
+ 'scanner-test',
+ find_program('scanner-test.sh'),
+ env: [
Could be

'TEST_OUTPUT_DIR=' + join_paths(meson.current_build_dir(), 'output')

but I don't care about portability that much.
Post by Daniel Stone
+ ],
+)
+
+# test name, extra sources, extra dependencies
+tests = [
Thanks,
pq
Pekka Paalanen
2018-08-29 08:57:47 UTC
Permalink
On Tue, 28 Aug 2018 23:19:15 +0100
Make considers a variable called VPATH when trying to satisfy
dependencies, e.g. for a target 'foo', it will consider the target
extant if VPATH is '../../bar' and '../../bar/foo' exists.
Part of the doc build, the '$(alldirs)' target, exists to create the
target directories if they do not exist. For example, before generating
xml/wayland-architecture.png, it will ensure the 'xml' target is
considered up-to-date thanks to the target dependency.
Creating $(srcdir)/doc/doxygen/xml thus means that the 'xml' dependency
will be satisfied, so we'll never create the output directory, and the
doc build will fail.
Change the alldirs target list to be absolute paths, so VPATH will not
be consulted and defeat the entire point of what we're trying to do.
This fixes the Meson build, where we later create
doc/doxygen/xml/meson.build.
---
doc/doxygen/Makefile.am | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Hi Daniel,

this makes sense to me, so even though I didn't test:

Reviewed-by: Pekka Paalanen <***@collabora.co.uk>


Thanks,
pq
diff --git a/doc/doxygen/Makefile.am b/doc/doxygen/Makefile.am
index f8b0b3aa..31d953c0 100644
--- a/doc/doxygen/Makefile.am
+++ b/doc/doxygen/Makefile.am
@@ -53,20 +53,21 @@ diagram_maps := $(patsubst $(diagramsdir)/%,xml/%,$(diagramssrc:.gv=.map))
dist_man3_MANS = $(shell test -d man && find man/man3 -name "wl_*.3" -printf "man/man3/%P\n")
# Listing various directories that might need to be created.
-alldirs := xml xml/Client xml/Server man/man3 html/Client html/Server
+alldirsrel := xml xml/Client xml/Server man/man3 html/Client html/Server
+alldirs := $(patsubst %,$(CURDIR)/%,$(alldirsrel))
$(diagrams): $(diagramssrc)
$(diagram_maps): $(diagramssrc)
-xml/%/index.xml: $(top_srcdir)/src/scanner.c $(scanned_src_files_%) wayland.doxygen $(diagrams) $(diagram_maps) | xml/%
+xml/%/index.xml: $(top_srcdir)/src/scanner.c $(scanned_src_files_%) wayland.doxygen $(diagrams) $(diagram_maps) | $(CURDIR)/xml/%
$(AM_V_GEN)(cat wayland.doxygen; \
echo "GENERATE_XML=YES"; \
echo "XML_OUTPUT=xml/$*"; \
echo "INPUT= $(scanned_src_files_$*)"; \
) | $(DOXYGEN) -
-html/%/index.html: $(scanned_src_files_%) wayland.doxygen $(diagrams) $(diagram_maps) | html/%
+html/%/index.html: $(scanned_src_files_%) wayland.doxygen $(diagrams) $(diagram_maps) | $(CURDIR)/html/%
$(AM_V_GEN)(cat wayland.doxygen; \
echo "PROJECT_NAME=\"Wayland $* API\""; \
echo "GENERATE_HTML=YES"; \
@@ -74,7 +75,7 @@ html/%/index.html: $(scanned_src_files_%) wayland.doxygen $(diagrams) $(diagram_
echo "INPUT= $(scanned_src_files_$*) $(extra_doxygen_$*)"; \
) | $(DOXYGEN) -
-man/man3/wl_display.3: $(top_srcdir)/src/scanner.c $(scanned_src_files_man) wayland.doxygen | man/man3
+man/man3/wl_display.3: $(top_srcdir)/src/scanner.c $(scanned_src_files_man) wayland.doxygen | $(CURDIR)/man/man3
$(AM_V_GEN)(cat wayland.doxygen; \
echo "GENERATE_MAN=YES"; \
echo "MAN_OUTPUT=man"; \
@@ -82,10 +83,10 @@ man/man3/wl_display.3: $(top_srcdir)/src/scanner.c $(scanned_src_files_man) wayl
echo "INPUT= $(scanned_src_files_man)"; \
) | $(DOXYGEN) -
-xml/%.png: $(diagramsdir)/%.gv | xml
+xml/%.png: $(diagramsdir)/%.gv | $(CURDIR)/xml
-xml/%.map: $(diagramsdir)/%.gv | xml
+xml/%.map: $(diagramsdir)/%.gv | $(CURDIR)/xml
# general rule to create one of the listed directories.
Pekka Paalanen
2018-08-29 09:20:49 UTC
Permalink
On Tue, 28 Aug 2018 23:19:16 +0100
Post by Daniel Stone
The tests that run exec-fd-leak-checker expect the binary to be located
in the current directory. This is not always the case; for instance, the
binaries could be built under `tests`, but be invoked under the
top-level build directory.
Hi,

saying Meson will need this would have been nice.
Post by Daniel Stone
We can use an environment variable to control what's the location of the
test binaries, and fall back to the current directory if the variable is
unset.
---
tests/test-helpers.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tests/test-helpers.c b/tests/test-helpers.c
index b2189d8e..20b66903 100644
--- a/tests/test-helpers.c
+++ b/tests/test-helpers.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
@@ -67,11 +68,19 @@ count_open_fds(void)
void
exec_fd_leak_check(int nr_expected_fds)
{
- const char *exe = "./exec-fd-leak-checker";
+ const char *exe = "exec-fd-leak-checker";
char number[16] = { 0 };
+ const char *test_build_dir = getenv("TEST_BUILD_DIR");
+ char exe_path[256] = { 0 };
256 bytes is very short for various build systems that really like long
paths
like /var/tmp/buildbuilder/packages/dev-lib/wayland/wayland-1.123/tmp/work/install-prefix/sysroot/tmp/build/...

Use PATH_MAX instead?

Otherwise looks good to me, so
Reviewed-by: Pekka Paalanen <***@collabora.co.uk>


Thanks,
pq
Post by Daniel Stone
+
+ if (test_build_dir == NULL || test_build_dir[0] == 0) {
+ test_build_dir = ".";
+ }
+
+ snprintf(exe_path, sizeof exe_path - 1, "%s/%s", test_build_dir, exe);
snprintf(number, sizeof number - 1, "%d", nr_expected_fds);
- execl(exe, exe, number, (char *)NULL);
+ execl(exe_path, exe, number, (char *)NULL);
assert(0 && "execing fd leak checker failed");
}
Emil Velikov
2018-08-29 16:46:46 UTC
Permalink
Hi Dan,
Make considers a variable called VPATH when trying to satisfy
dependencies, e.g. for a target 'foo', it will consider the target
extant if VPATH is '../../bar' and '../../bar/foo' exists.
Part of the doc build, the '$(alldirs)' target, exists to create the
target directories if they do not exist. For example, before generating
xml/wayland-architecture.png, it will ensure the 'xml' target is
considered up-to-date thanks to the target dependency.
Creating $(srcdir)/doc/doxygen/xml thus means that the 'xml' dependency
will be satisfied, so we'll never create the output directory, and the
doc build will fail.
Change the alldirs target list to be absolute paths, so VPATH will not
be consulted and defeat the entire point of what we're trying to do.
This fixes the Meson build, where we later create
doc/doxygen/xml/meson.build.
Have you tried something as trivial as the below sed?
s/$(AM_V_GEN)/$(AM_V_GEN)$(MKDIR_P) $@/g

It will allow you to remove the, dare I say it, bonkers "let's make a
target that only creates a folder".
Plus avoid all the complexity that you've proposing.

-Emil
Daniel Stone
2018-08-30 13:02:16 UTC
Permalink
Post by Emil Velikov
Change the alldirs target list to be absolute paths, so VPATH will not
be consulted and defeat the entire point of what we're trying to do.
This fixes the Meson build, where we later create
doc/doxygen/xml/meson.build.
Have you tried something as trivial as the below sed?
It will allow you to remove the, dare I say it, bonkers "let's make a
target that only creates a folder".
Plus avoid all the complexity that you've proposing.
Sure. I was trying to work within what was already there rather than
rewrite the Makefile, given how fragile the entire thing is, but I've
now rewritten the commit.

Cheers,
Daniel
Loading...