build: Start using meson feature options

Use feature options for things that are optional features,
update the docs.

Visible changes here is that the 'print-backends' option
got renamed to 'print' to go better with 'media', and the
'tracker3' option got renamed to 'tracker'.

For options that have been changed into features, the
syntax now is -Dfeature=enabled or -Dfeature=disabled
or -Dfeature=auto.
This commit is contained in:
Matthias Clasen 2020-08-21 19:36:17 -04:00
parent 54e4bf8b75
commit c4d350c260
7 changed files with 228 additions and 180 deletions

View File

@ -17,8 +17,8 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings -Dgtk:werror=true"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true -Dvulkan=yes"
FEATURE_FLAGS: "-Dcloudproviders=true"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v22"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"

View File

@ -66,7 +66,7 @@ meson \
-Dx11-backend=false \
-Dwayland-backend=false \
-Dwin32-backend=true \
-Dvulkan=no \
-Dvulkan=disabled \
-Dintrospection=false \
-Dgtk:werror=true \
_build

View File

@ -206,22 +206,70 @@ all else fails, you can ask for help on the
## Extra Configuration Options {#extra-configuration-options}
In addition to the normal options provided by Meson,
GTK defines various arguments that modify what should
be built. All of these options are passed to `meson`
as `-Doption=value`. Most of the time, the value can
be `true` or `false`. To see a summary of all supported
options and their allowed values, run
In addition to the normal options provided by Meson, GTK defines various
arguments that modify what should be built. All of these options are passed
to `meson` as `-Doption=value`. Most of the time, the value can be `true` or
`false`, or `enabled`, `disabled` or `auto`.
To see a summary of all supported options and their allowed values, run
```
meson configure builddir
```
### `x11-backend`, `win32-backend`, `broadway-backend`, `wayland-backend` and `macos-backend`
Enable specific backends for GDK. If none of these options
are given, the Wayland backend will be enabled by default,
if the platform is Linux; the X11 backend will also be enabled
by default, unless the platform is Windows, in which case the
default is win32, or the platform is macOS, in which case the
default is macOS. If any backend is explicitly enabled or disabled,
no other platform will be enabled automatically.
### `vulkan`
By default, GTK will try to build with support for the Vulkan graphics
API in addition to cairo and OpenGL. This option can be used to explicitly
control whether Vulkan should be used.
### `xinerama`
By default GTK will try to link against the Xinerama libraries
By default, GTK will try to link against the Xinerama libraries
if they are found. This option can be used to explicitly control
whether Xinerama should be used.
### `media`
By default, GTK will try to build the gstreamer backend for
media playback support. This option can be used to explicitly
control which media backends should be built.
### `print`
By default, GTK will try to build various print backends
if their dependencies are found. This option can be used
to explicitly control which print backends should be built.
### `cloudproviders`
This option controls whether GTK should use libcloudproviders for
supporting various Cloud storage APIs in the file chooser.
### `sysprof`
This option controls whether GTK should include support for
tracing with sysprof.
### `tracker`
This option controls whether GTK should use Tracker for search
support in the file chooser.
### `colord`
This option controls whether GTK should use colord for color
calibration support in the cups print backend.
### `gtk_doc` and `man-pages`
The *gtk-doc* package is used to generate the reference documentation
@ -235,22 +283,6 @@ manual pages generated using a similar set of dependencies;
if you have *xsltproc* then you can generate manual pages by
passing `-Dman-pages=true` when configuring the build.
### `print-backends`
By default, GTK will try to build various print backends
if their dependencies are found. This option can be used
to explicitly control which print backends should be built.
### `x11-backend`, `win32-backend`, `broadway-backend`, `wayland-backend` and `quartz-backend`
Enable specific backends for GDK. If none of these options
are given, the Wayland backend will be enabled by default,
if the platform is Linux; the X11 backend will also be enabled
by default, unless the platform is Windows, in which case the
default is win32, or the platform is macOS, in which case the
default is quartz. If any backend is explicitly enabled or disabled,
no other platform will be enabled automatically.
### `introspection`
Allows to disable building introspection support. This is option

View File

@ -741,7 +741,7 @@ foreach p: proto_sources
endif
endforeach
if os_unix and tracker3_enabled
if os_unix and tracker3_dep.found()
gtk_sources += 'gtksearchenginetracker3.c'
endif
@ -1023,11 +1023,9 @@ if x11_enabled or wayland_enabled
gtk_deps += pangoft_dep
endif
if cloudproviders_enabled
gtk_deps += cloudproviders_dep
endif
gtk_deps += cloudproviders_dep
if os_unix and tracker3_enabled
if os_unix
gtk_deps += tracker3_dep
endif

View File

@ -93,7 +93,6 @@ x11_enabled = get_option('x11-backend')
wayland_enabled = get_option('wayland-backend')
broadway_enabled = get_option('broadway-backend')
macos_enabled = get_option('macos-backend')
quartz_enabled = get_option('quartz-backend')
win32_enabled = get_option('win32-backend')
os_unix = false
@ -392,15 +391,11 @@ if os_unix
platform_gio_dep = giounix_dep
endif
tracker3_enabled = get_option('tracker3')
if tracker3_enabled
tracker3_dep = dependency('tracker-sparql-3.0', required: false)
if tracker3_dep.found()
cdata.set('HAVE_TRACKER3', tracker3_dep.found())
else
error('Tracker3 not found, but was explicitly requested.')
endif
endif
tracker3_dep = dependency('tracker-sparql-3.0', required: get_option('tracker'))
cdata.set('HAVE_TRACKER3', tracker3_dep.found())
colord_dep = dependency('colord', version: '>= 0.1.9', required: get_option('colord'))
cdata.set('HAVE_COLORD', colord_dep.found())
if iso_codes_dep.found()
cdata.set_quoted('ISO_CODES_PREFIX', iso_codes_dep.get_pkgconfig_variable('prefix'))
@ -408,6 +403,7 @@ else
cdata.set_quoted('ISO_CODES_PREFIX', '/usr')
endif
backend_immodules = []
pc_gdk_extra_libs = []
@ -560,18 +556,17 @@ if x11_enabled
# Note that we also check that the XIScrollClassInfo struct is defined,
# because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(),
# but not the XIScrollClassInfo struct
has_allow_touch_evens = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep)
has_allow_touch_events = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep)
has_scroll_class_info = cc.has_member('XIScrollClassInfo', 'number', dependencies: xi_dep,
prefix: '''#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>''')
if has_allow_touch_evens and has_scroll_class_info
if has_allow_touch_events and has_scroll_class_info
cdata.set('XINPUT_2_2', 1)
endif
enable_xinerama = get_option('xinerama')
if enable_xinerama != 'no'
want_xinerama = enable_xinerama == 'yes'
xinerama_dep = dependency('xinerama', required: want_xinerama)
enable_xinerama = get_option('xinerama').enabled()
if enable_xinerama
xinerama_dep = dependency('xinerama', required: true)
if xinerama_dep.found() and cc.has_header_symbol('X11/extensions/Xinerama.h', 'XineramaQueryExtension', dependencies: xinerama_dep)
cdata.set('HAVE_XFREE_XINERAMA', 1)
x11_pkgs += ['xinerama']
@ -653,89 +648,66 @@ if os_unix
endif
# Check for Vulkan support
# TODO: move to gsk subfolder maybe? Or will it be used elsewhere too?
have_vulkan = false
vulkan_pkg_found = false
vulkan_dep = []
enable_vulkan = get_option('vulkan')
if enable_vulkan == 'no'
message('Vulkan support explicitly disabled')
vulkan_dep = dependency('vulkan', required: get_option('vulkan'))
if vulkan_dep.found()
have_vulkan = true
vulkan_pkg_found = true
else
vulkan_dep = dependency('vulkan', required: false)
if vulkan_dep.found()
have_vulkan = true
vulkan_pkg_found = true
have_vulkan = false
vulkan_pkg_found = false
if cc.get_id() == 'msvc'
vulkan_libname = 'vulkan-1'
else
if cc.get_id() == 'msvc'
vulkan_libname = 'vulkan-1'
else
vulkan_libname = 'vulkan'
endif
vulkan_dep = cc.find_library(vulkan_libname, required: false)
if vulkan_dep.found() and cc.has_function('vkCreateInstance', dependencies: vulkan_dep) and cc.has_header('vulkan/vulkan.h')
have_vulkan = true
pc_gdk_extra_libs += ['-l@0@'.format(vulkan_libname)]
endif
vulkan_libname = 'vulkan'
endif
if enable_vulkan == 'yes' and not have_vulkan
error('Vulkan support not found, but was explicitly requested.')
vulkan_dep = cc.find_library(vulkan_libname, required: false)
if vulkan_dep.found() and cc.has_function('vkCreateInstance', dependencies: vulkan_dep) and cc.has_header('vulkan/vulkan.h')
have_vulkan = true
pc_gdk_extra_libs += ['-l@0@'.format(vulkan_libname)]
endif
endif
cloudproviders_enabled = get_option('cloudproviders')
if cloudproviders_enabled
cloudproviders_dep = dependency('cloudproviders',
version: cloudproviders_req,
fallback: [
'libcloudproviders',
'libcloudproviders_dep',
],
default_options: [
'vapigen=false',
])
if cloudproviders_dep.found()
cdata.set('HAVE_CLOUDPROVIDERS', cloudproviders_dep.found())
else
error('Cloudproviders support not found, but was explicitly requested.')
endif
endif
cloudproviders_dep = dependency('cloudproviders',
required: get_option('cloudproviders'),
version: cloudproviders_req,
fallback: [
'libcloudproviders',
'libcloudproviders_dep',
],
default_options: [
'vapigen=false',
])
cdata.set('HAVE_CLOUDPROVIDERS', cloudproviders_dep.found())
profiler_enabled = get_option('sysprof').enabled()
if profiler_enabled
# libsysprof-capture support
libsysprof_capture_dep = dependency('sysprof-capture-4',
required: true,
default_options: [
'enable_examples=false',
'enable_gtk=false',
'enable_tests=false',
'enable_tools=false',
'libsysprof=true',
'with_sysprofd=none',
'help=false',
],
fallback: ['sysprof', 'libsysprof_capture_dep'],
)
if libsysprof_capture_dep.found()
cdata.set('HAVE_SYSPROF', 1)
else
error('Profiler support not found, but was explicitly requested.')
endif
libsysprof_dep = dependency('sysprof-4',
required: false,
default_options: [
'enable_examples=false',
'enable_gtk=false',
'enable_tests=false',
'enable_tools=false',
'libsysprof=true',
'with_sysprofd=none',
'help=false',
],
fallback: ['sysprof', 'libsysprof_dep'],
)
endif
# libsysprof-capture support
libsysprof_capture_dep = dependency('sysprof-capture-4',
required: get_option('sysprof'),
default_options: [
'enable_examples=false',
'enable_gtk=false',
'enable_tests=false',
'enable_tools=false',
'libsysprof=true',
'with_sysprofd=none',
'help=false',
],
fallback: ['sysprof', 'libsysprof_capture_dep'],
)
cdata.set('HAVE_SYSPROF', libsysprof_capture_dep.found())
libsysprof_dep = dependency('sysprof-4',
required: false,
default_options: [
'enable_examples=false',
'enable_gtk=false',
'enable_tests=false',
'enable_tools=false',
'libsysprof=true',
'with_sysprofd=none',
'help=false',
],
fallback: ['sysprof', 'libsysprof_dep'],
)
graphene_dep_type = graphene_dep.type_name()
if graphene_dep_type == 'pkgconfig'
@ -889,10 +861,12 @@ endif
summary('Display backends', display_backends)
summary('Print backends', print_backends)
summary('Media backends', media_backends)
summary('Vulkan support', have_vulkan)
summary('Cloud support', get_option('cloudproviders'))
summary('Sysprof support', get_option('sysprof').enabled())
summary('Colord support', get_option('colord'))
summary('Vulkan support', vulkan_dep.found(), section: 'Features')
summary('Cloud support', cloudproviders_dep.found(), section: 'Features')
summary('Sysprof support', libsysprof_capture_dep.found(), section: 'Features')
summary('Colord support', colord_dep.found(), section: 'Features')
summary('Tracker support', tracker3_dep.found(), section: 'Features')
# Build
summary('Debugging', get_option('debug'), section: 'Build')

View File

@ -1,57 +1,111 @@
# GDK backends
option('x11-backend', type: 'boolean', value: true,
description : 'Enable the X11 gdk backend (only when building on Unix)')
option('wayland-backend', type: 'boolean', value: true,
description : 'Enable the wayland gdk backend (only when building on Unix except for macOS)')
option('broadway-backend', type: 'boolean', value: false,
description : 'Enable the broadway (HTML5) gdk backend')
option('win32-backend', type: 'boolean', value: true,
description : 'Enable the Windows gdk backend (only when building on Windows)')
option('quartz-backend', type: 'boolean', value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
option('macos-backend', type: 'boolean', value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
option('x11-backend',
type: 'boolean',
value: true,
description : 'Enable the X11 gdk backend (only when building on Unix)')
option('wayland-backend',
type: 'boolean',
value: true,
description : 'Enable the wayland gdk backend (only when building on Unix except for macOS)')
option('broadway-backend',
type: 'boolean',
value: false,
description : 'Enable the broadway (HTML5) gdk backend')
option('win32-backend',
type: 'boolean',
value: true,
description : 'Enable the Windows gdk backend (only when building on Windows)')
option('macos-backend',
type: 'boolean',
value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
# Media backends
option('media', type: 'string', value: 'gstreamer',
description : 'Build the specified media engines (comma-separated list, "all", or "none")')
# Optional dependencies
option('vulkan', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Enable support for the Vulkan graphics API')
option('xinerama', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Enable support for the Xinerama extension')
option('cloudproviders', type: 'boolean', value: false,
description : 'Enable the cloudproviders support')
option('media',
type: 'string',
value: 'gstreamer',
description : 'Build the specified media engines (comma-separated list, "all", or "none")')
# Print backends
option('print',
type: 'string',
value: 'cups,file',
description : 'Build the specified print backends (comma-separated list, "all", or "none")')
# Optional features
option('vulkan',
type: 'feature',
value: 'enabled',
description : 'Enable support for the Vulkan graphics API')
option('xinerama',
type: 'feature',
value: 'enabled',
description : 'Enable support for the X11 Xinerama extension')
option('cloudproviders',
type: 'feature',
value: 'disabled',
description : 'Enable the cloudproviders support')
option('sysprof',
type: 'feature',
value: 'disabled',
description : 'include tracing support for sysprof')
option('tracker3', type: 'boolean', value: false,
description : 'Enable Tracker3 filechooser search')
option('tracker',
type: 'feature',
value: 'disabled',
description : 'Enable Tracker3 filechooser search')
# Print backends
option('print-backends', type : 'string', value : 'cups,file',
description : 'Build the specified print backends (comma-separated list, "all", or "none")')
option('colord', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Build colord support for the CUPS printing backend')
option('colord',
type: 'feature',
value : 'disabled',
description : 'Build colord support for the CUPS printing backend')
# Documentation and introspection
option('gtk_doc', type: 'boolean', value: 'false',
description : 'Build API reference and tools documentation')
option('man-pages', type: 'boolean', value: 'false',
description : 'Build man pages for installed tools')
option('introspection', type: 'boolean', value: 'true',
description : 'Build introspection data (requires gobject-introspection)')
# Demos and binaries
option('demos', type: 'boolean', value: 'true',
description : 'Build demo programs')
option('build-examples', type: 'boolean', value: 'true',
description : 'Build examples')
option('build-tests', type: 'boolean', value: 'true',
description : 'Build tests')
option('install-tests', type: 'boolean', value: 'false',
description : 'Install tests')
option('gtk_doc',
type: 'boolean',
value: 'false',
description : 'Build API reference and tools documentation')
option('man-pages',
type: 'boolean',
value: 'false',
description : 'Build man pages for installed tools')
option('introspection',
type: 'boolean',
value: 'true',
description : 'Build introspection data (requires gobject-introspection)')
# Demos, examples and tests
option('demos',
type: 'boolean',
value: 'true',
description : 'Build demo programs')
option('build-examples',
type: 'boolean',
value: 'true',
description : 'Build examples')
option('build-tests',
type: 'boolean',
value: 'true',
description : 'Build tests')
option('install-tests',
type: 'boolean',
value: 'false',
description : 'Install tests')

View File

@ -3,7 +3,7 @@ all_print_backends = [
'cloudprint',
]
enabled_print_backends = get_option('print-backends').split(',')
enabled_print_backends = get_option('print').split(',')
if enabled_print_backends.contains('none')
enabled_print_backends = []
@ -54,16 +54,6 @@ printbackends_install_dir = join_paths(get_option('libdir'), printbackends_subdi
cdata.set_quoted('GTK_PRINT_BACKENDS', ','.join(print_backends))
enable_colord = get_option('colord')
if enable_colord != 'no'
want_colord = enable_colord == 'yes'
colord_dep = dependency('colord', version: '>= 0.1.9', required: want_colord)
cdata.set('HAVE_COLORD', colord_dep.found())
else
colord_dep = []
endif
printbackends_args = [
'-DGTK_COMPILATION',
'-DGTK_DISABLE_DEPRECATION_WARNINGS',