meson: Add option to control building wayland-scanner

Wayland requires a binary, wayland-scanner, to be run during the build
process. For any configuration other than native builds (including
cross compiling and even 32-bit x86 builds on an x86-64 build machine)
Wayland's build process builds and uses its own wayland-scanner.

For any builds using a cross file, wayland-scanner is built for the host
machine and therefore cannot be executed during the build of the Wayland
libraries. Instead builds using a cross file must execute the build
machine's wayland-scanner (typically /usr/bin/wayland-scanner).

As such, to build Wayland's libraries for a non-native ABI a package
manager must build and install /usr/bin/wayland-scanner first. But then
the build for the native ABI then rebuilds wayland-scanner itself and
doesn't use the system's, and worse, wants to install its own, which
conflicts with the /usr/bin/wayland-scanner already installed!

So, add the -Dscanner=... option to control whether to install
wayland-scanner.

Signed-off-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Matt Turner 2020-03-05 12:04:36 -08:00
parent 5ddb8dff87
commit 618663c791
4 changed files with 80 additions and 58 deletions

View file

@ -84,12 +84,12 @@ if get_option('libraries')
subdir('cursor') subdir('cursor')
subdir('egl') subdir('egl')
subdir('tests') subdir('tests')
endif
if get_option('documentation') if get_option('documentation')
subdir('doc') subdir('doc')
endif endif
endif
if get_option('scanner')
install_data([ install_data([
'wayland-scanner.mk', 'wayland-scanner.mk',
'protocol/wayland.xml', 'protocol/wayland.xml',
@ -100,3 +100,4 @@ install_data(
[ 'wayland-scanner.m4' ], [ 'wayland-scanner.m4' ],
install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'aclocal'), install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'aclocal'),
) )
endif

View file

@ -2,6 +2,10 @@ option('libraries',
description: 'Compile Wayland libraries', description: 'Compile Wayland libraries',
type: 'boolean', type: 'boolean',
value: 'true') value: 'true')
option('scanner',
description: 'Compile wayland-scanner binary',
type: 'boolean',
value: 'true')
option('documentation', option('documentation',
description: 'Build the documentation (requires Doxygen, dot, xmlto, xsltproc)', description: 'Build the documentation (requires Doxygen, dot, xmlto, xsltproc)',
type: 'boolean', type: 'boolean',

View file

@ -4,12 +4,6 @@ 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_MAJOR', wayland_version[0].to_int())
wayland_version_h.set('WAYLAND_VERSION_MINOR', wayland_version[1].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()) 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_dir: join_paths(get_option('prefix'), get_option('includedir'))
)
wayland_util = static_library( wayland_util = static_library(
'wayland-util', 'wayland-util',
@ -21,8 +15,15 @@ wayland_util_dep = declare_dependency(
include_directories: include_directories('.') include_directories: include_directories('.')
) )
if get_option('scanner')
# wayland-scanner # wayland-scanner
configure_file(
input: 'wayland-version.h.in',
output: 'wayland-version.h',
configuration: wayland_version_h,
)
configure_file( configure_file(
input: '../protocol/wayland.dtd', input: '../protocol/wayland.dtd',
output: 'wayland.dtd.embed', output: 'wayland.dtd.embed',
@ -53,8 +54,9 @@ pkgconfig.generate(
], ],
filebase: 'wayland-scanner' filebase: 'wayland-scanner'
) )
endif
if meson.is_cross_build() if meson.is_cross_build() or not get_option('scanner')
scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version()) scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
wayland_scanner_for_build = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner')) wayland_scanner_for_build = find_program(scanner_dep.get_pkgconfig_variable('wayland_scanner'))
else else
@ -62,6 +64,19 @@ else
endif endif
if get_option('libraries') if get_option('libraries')
# wayland libraries
# Duplicated inside the "if get_option('scanner')" block above since we
# still need the wayland-version.h to build the scanner, but do not want
# to install it. Meson 0.50 adds "install: bool" which will let us
# deduplicate this block.
configure_file(
input: 'wayland-version.h.in',
output: 'wayland-version.h',
configuration: wayland_version_h,
install_dir: join_paths(get_option('prefix'), get_option('includedir'))
)
mathlib_dep = cc.find_library('m', required: false) mathlib_dep = cc.find_library('m', required: false)
threads_dep = dependency('threads', required: false) threads_dep = dependency('threads', required: false)

View file

@ -76,6 +76,7 @@ test(
sed_path = find_program('sed').path() sed_path = find_program('sed').path()
if get_option('scanner')
test( test(
'scanner-test', 'scanner-test',
find_program('scanner-test.sh'), find_program('scanner-test.sh'),
@ -86,6 +87,7 @@ test(
'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()), 'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()),
], ],
) )
endif
tests = { tests = {
'array-test': [], 'array-test': [],