[igt-dev] [PATCH i-g-t 1/2] meson: Start using 'feature' options
Arkadiusz Hiler
arkadiusz.hiler at intel.com
Tue May 21 09:36:01 UTC 2019
Meson 0.47 comes with a new type of option called 'feature' so instead of:
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
We can:
type : 'feature',
The main difference is that the feature takes auto, enabled and disabled
instead of auto, true and false.
get_option() on a feature returns opaque object that can be passed as
a 'required' argument of a dependency. Auto is equivalent to 'required
: false', enabled is equivalent to 'required : true' and disabled
introduces new behavior forcing the dependency to be considered not
found.
This allows us to streamline a lot of logic regarding optional IGT
features.
This patch bumps required meson version to 0.47.0
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Simon Ser <simon.ser at intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
.gitlab-ci.yml | 14 +++---
Dockerfile.fedora | 2 +-
NEWS | 4 +-
lib/meson.build | 2 +-
man/meson.build | 10 ++--
meson.build | 113 ++++++++++++--------------------------------
meson_options.txt | 32 ++++---------
overlay/meson.build | 17 ++++---
runner/meson.build | 12 +++--
tests/meson.build | 2 +-
10 files changed, 75 insertions(+), 133 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9fe6a8f6..771143a9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,13 +2,13 @@ image: $CI_REGISTRY/$CI_PROJECT_PATH/igt-fedora:latest
variables:
MESON_OPTIONS: >
-Dwith_libdrm=intel,nouveau,amdgpu
- -Dbuild_overlay=true
- -Dbuild_chamelium=true
- -Dwith_valgrind=true
- -Dbuild_man=true
- -Dbuild_tests=true
- -Dbuild_runner=true
- -Dwith_libunwind=true
+ -Dbuild_overlay=enabled
+ -Dbuild_chamelium=enabled
+ -Dwith_valgrind=enabled
+ -Dbuild_man=enabled
+ -Dbuild_tests=enabled
+ -Dbuild_runner=enabled
+ -Dwith_libunwind=enabled
LANG: "C.UTF-8"
stages:
diff --git a/Dockerfile.fedora b/Dockerfile.fedora
index 5283c8eb..6686e587 100644
--- a/Dockerfile.fedora
+++ b/Dockerfile.fedora
@@ -38,7 +38,7 @@ RUN dnf install -y clang
# Meson version switching shenanigans
WORKDIR /usr/src
-RUN curl -O https://files.pythonhosted.org/packages/17/d0/0fe98a9557a2f07dbe6f99ef57f2bc37450b641e1f6ceae9ce04c3c845dd/meson-0.46.0.tar.gz
+RUN curl -O https://files.pythonhosted.org/packages/c0/9b/44cdb8adcbb186be6cba5c93718d0c68f177b0e8082ae00cafa63a1d3535/meson-0.47.0.tar.gz
# Cleanup workdir
WORKDIR /
diff --git a/NEWS b/NEWS
index ffddc096..f4e96c69 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,9 @@ Unreleased
General changes:
- - Bumped required meson version to 0.46. (Arkadiusz Hiler)
+ - Bumped required meson version to 0.47. (Arkadiusz Hiler)
+ - All the meson build options that used auto, true and false are now first
+ class 'feature' options taking auto, enabled and disabled (Arkadiusz Hiler)
Release 1.23 (2018-07-18)
-------------------------
diff --git a/lib/meson.build b/lib/meson.build
index 80736868..89d9e11d 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -104,7 +104,7 @@ if alsa.found()
lib_sources += 'igt_alsa.c'
endif
-if chamelium_found
+if chamelium.found()
lib_deps += chamelium
lib_sources += 'igt_chamelium.c'
lib_sources += 'igt_chamelium_stream.c'
diff --git a/man/meson.build b/man/meson.build
index a6b08900..35faad28 100644
--- a/man/meson.build
+++ b/man/meson.build
@@ -1,3 +1,5 @@
+build_man = get_option('build_man')
+
manpages = [
'intel_aubdump',
'intel_audio_dump',
@@ -22,10 +24,10 @@ defs_rst = configure_file(input : 'defs.rst.in',
output : 'defs.rst',
configuration : config)
-rst2man = find_program('rst2man-3', 'rst2man', required : _man_required)
+rst2man = find_program('rst2man-3', 'rst2man', required : build_man)
rst2man_script = find_program('rst2man.sh')
-if _build_man and rst2man.found()
+if rst2man.found()
foreach manpage : manpages
custom_target(manpage + '.1',
build_by_default : true,
@@ -36,10 +38,10 @@ if _build_man and rst2man.found()
install : true,
install_dir : join_paths(mandir, 'man1'))
endforeach
- build_info += 'Build man pages: Yes'
+ build_info += 'Build man pages: true'
else
if _man_required
error('Cannot build man pages due to missing dependencies')
endif
- build_info += 'Build man pages: No'
+ build_info += 'Build man pages: false'
endif
diff --git a/meson.build b/meson.build
index 2af08f9a..6268c58d 100644
--- a/meson.build
+++ b/meson.build
@@ -7,7 +7,7 @@ project('igt-gpu-tools', 'c',
'buildtype=debugoptimized',
],
license : 'MIT',
- meson_version : '>=0.46.0')
+ meson_version : '>=0.47.0')
if get_option('b_ndebug') != 'false'
error('Building without -Db_ndebug=false is not supported')
@@ -77,42 +77,10 @@ foreach cc_arg : cc_args
endif
endforeach
-_build_overlay = false
-_overlay_required = false
-_build_man = false
-_man_required = false
-_build_chamelium = false
-_chamelium_required = false
-_build_docs = false
-_docs_required = false
-_build_tests = false
-_tests_required = false
-_build_runner = false
-_runner_required = false
-
-build_overlay = get_option('build_overlay')
-overlay_backends = get_option('overlay_backends')
-build_man = get_option('build_man')
-with_valgrind = get_option('with_valgrind')
build_chamelium = get_option('build_chamelium')
build_docs = get_option('build_docs')
-build_tests = get_option('build_tests')
+build_tests = not get_option('build_tests').disabled()
with_libdrm = get_option('with_libdrm')
-with_libunwind = get_option('with_libunwind')
-build_runner = get_option('build_runner')
-
-_build_overlay = build_overlay != 'false'
-_overlay_required = build_overlay == 'true'
-_build_man = build_man != 'false'
-_man_required = build_man == 'true'
-_build_chamelium = build_chamelium != 'false'
-_chamelium_required = build_chamelium == 'true'
-_build_docs = build_docs != 'false'
-_docs_required = build_docs == 'true'
-_build_tests = build_tests != 'false'
-_tests_required = build_tests == 'true'
-_build_runner = build_runner != 'false'
-_runner_required = build_runner == 'true'
build_info = ['Build type: ' + get_option('buildtype')]
@@ -150,29 +118,17 @@ pciaccess = dependency('pciaccess', version : '>=0.10')
libkmod = dependency('libkmod')
libprocps = dependency('libprocps', required : true)
-libunwind = null_dep
-libunwindinfo = 'No'
-if with_libunwind != 'false'
- libunwind = dependency('libunwind', required : with_libunwind == 'true')
- if libunwind.found()
- libunwindinfo = 'Yes'
- endif
-endif
-build_info += 'With libunwind: ' + libunwindinfo
+libunwind = dependency('libunwind', required : get_option('with_libunwind'))
+build_info += 'With libunwind: @0@'.format(libunwind.found())
libdw = dependency('libdw', required : true)
pixman = dependency('pixman-1', required : true)
-valgrind = null_dep
-valgrindinfo = 'No'
-if with_valgrind != 'false'
- valgrind = dependency('valgrind', required : with_valgrind == 'true')
- if valgrind.found()
- config.set('HAVE_VALGRIND', 1)
- valgrindinfo = 'Yes'
- endif
+valgrind = dependency('valgrind', required : get_option('with_valgrind'))
+if valgrind.found()
+ config.set('HAVE_VALGRIND', 1)
endif
-build_info += 'Valgrind annotations: ' + valgrindinfo
+build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
cairo = dependency('cairo', version : '>1.12.0', required : true)
libudev = dependency('libudev', required : true)
@@ -195,15 +151,16 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
endif
endif
-gsl = null_dep
-alsa = null_dep
-chamelium = null_dep
-chamelium_found = false # TODO: use a disabler object instead
-chameliuminfo = 'No'
-if _build_chamelium
- gsl = dependency('gsl', required : _chamelium_required)
- alsa = dependency('alsa', required : _chamelium_required)
- libcurl = dependency('libcurl', required : _chamelium_required)
+if build_chamelium.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
+ error('Chamelium build forced and required dependency xmlrpc not found')
+endif
+
+gsl = dependency('gsl', required : build_chamelium)
+alsa = dependency('alsa', required : build_chamelium)
+libcurl = dependency('libcurl', required : build_chamelium)
+
+if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and gsl.found() and alsa.found() and libcurl.found()
+ config.set('HAVE_CHAMELIUM', 1)
chamelium = declare_dependency(dependencies : [
xmlrpc,
xmlrpc_util,
@@ -211,13 +168,11 @@ if _build_chamelium
gsl,
alsa,
])
- if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and gsl.found() and alsa.found() and libcurl.found()
- config.set('HAVE_CHAMELIUM', 1)
- chameliuminfo = 'Yes'
- chamelium_found = true
- endif
+else
+ chamelium = disabler()
endif
-build_info += 'Build Chamelium test: ' + chameliuminfo
+
+build_info += 'Build Chamelium test: @0@'.format(chamelium.found())
pthreads = dependency('threads')
math = cc.find_library('m')
@@ -319,12 +274,11 @@ else
endif
subdir('lib')
-if _build_tests
+if build_tests
subdir('tests')
- build_info += 'Build tests: Yes'
-else
- build_info += 'Build tests: No'
endif
+build_info += 'Build tests: @0@'.format(build_tests)
+
subdir('benchmarks')
subdir('tools')
subdir('runner')
@@ -334,18 +288,13 @@ endif
subdir('overlay')
subdir('man')
-gtk_doc = dependency('gtk-doc', required : _docs_required)
-
-docs_info = 'No'
-if _build_docs
- if _build_tests and gtk_doc.found()
- subdir('docs')
- docs_info = 'Yes'
- elif _docs_required
- error('Documentation requires building tests')
- endif
+gtk_doc = dependency('gtk-doc', required : build_docs)
+if build_tests and gtk_doc.found()
+ subdir('docs')
+elif build_docs.enabled()
+ error('Documentation requires building tests')
endif
-build_info += 'Build documentation: ' + docs_info
+build_info += 'Build documentation: @0@'.format(build_tests and gtk_doc.found())
message('Build options')
message('=============')
diff --git a/meson_options.txt b/meson_options.txt
index 888efe56..9cca0c4f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,7 +1,5 @@
option('build_overlay',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build overlay')
option('overlay_backends',
@@ -11,33 +9,23 @@ option('overlay_backends',
description : 'Overlay backends to enable')
option('build_chamelium',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build chamelium test')
option('with_valgrind',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build with support for valgrind annotations')
option('build_man',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build man pages')
option('build_docs',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build documentation')
option('build_tests',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build tests')
option('with_libdrm',
@@ -47,15 +35,11 @@ option('with_libdrm',
description : 'libdrm libraries to be used')
option('with_libunwind',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Use libunwind')
option('build_runner',
- type : 'combo',
- value : 'auto',
- choices : ['auto', 'true', 'false'],
+ type : 'feature',
description : 'Build test runner')
option('use_rpath',
diff --git a/overlay/meson.build b/overlay/meson.build
index 46d2d494..d133b6be 100644
--- a/overlay/meson.build
+++ b/overlay/meson.build
@@ -1,3 +1,6 @@
+build_overlay = get_option('build_overlay')
+overlay_backends = get_option('overlay_backends')
+
gpu_overlay_src = [
'chart.c',
'config.c',
@@ -18,7 +21,7 @@ xv_backend_required = false
xlib_backend_required = false
build_xv_backend = overlay_backends.contains('xv') or overlay_backends.contains('auto')
build_xlib_backend = overlay_backends.contains('x') or overlay_backends.contains('auto')
-if _overlay_required
+if build_overlay.enabled()
xv_backend_required = overlay_backends.contains('xv')
xlib_backend_required = overlay_backends.contains('x')
endif
@@ -30,7 +33,7 @@ dri2proto = dependency('dri2proto',
version : '>= 2.6',
required : xv_backend_required or xlib_backend_required)
cairo_xlib = dependency('cairo-xlib', required : xlib_backend_required)
-xrandr = dependency('xrandr', version : '>=1.3', required : _overlay_required)
+xrandr = dependency('xrandr', version : '>=1.3', required : build_overlay)
gpu_overlay_deps = [ realtime, math, cairo, pciaccess, libdrm,
libdrm_intel, lib_igt_perf ]
@@ -70,7 +73,7 @@ gpu_overlay_src += both_x11_src
gpu_overlay_src += 'kms/kms-overlay.c'
-leg = find_program('leg', required : _overlay_required)
+leg = find_program('leg', required : build_overlay)
if leg.found()
leg_file = custom_target('tracepoint_format',
output: 'tracepoint_format.h',
@@ -81,17 +84,17 @@ else
message('WARNING: leg command not found, disabling overlay; try : apt-get install peg')
endif
-if _build_overlay and ['x86', 'x86_64'].contains(host_machine.cpu_family()) and libdrm_intel.found() and leg.found() and xrandr.found() and cairo.found() and (with_xlib_backend or with_xv_backend)
+if not build_overlay.disabled() and ['x86', 'x86_64'].contains(host_machine.cpu_family()) and libdrm_intel.found() and leg.found() and xrandr.found() and cairo.found() and (with_xlib_backend or with_xv_backend)
executable('intel-gpu-overlay', gpu_overlay_src,
include_directories : inc,
c_args : gpu_overlay_cflags,
dependencies : gpu_overlay_deps,
install : true)
- build_info += 'Build overlay: Yes'
+ build_info += 'Build overlay: true'
build_info += 'Overlay backends: ' + ','.join(backends_strings)
else
- if _overlay_required
+ if build_overlay.enabled()
error('Cannot build overlay due to missing dependencies')
endif
- build_info += 'Build overlay: No'
+ build_info += 'Build overlay: false'
endif
diff --git a/runner/meson.build b/runner/meson.build
index b658f1d2..4eff193a 100644
--- a/runner/meson.build
+++ b/runner/meson.build
@@ -1,4 +1,4 @@
-jsonc = dependency('json-c', required: _runner_required)
+build_runner = get_option('build_runner')
runnerlib_sources = [ 'settings.c',
'job_list.c',
@@ -12,11 +12,13 @@ results_sources = [ 'results.c' ]
runner_test_sources = [ 'runner_tests.c' ]
runner_json_test_sources = [ 'runner_json_tests.c' ]
-if not _build_tests and _runner_required
+jsonc = dependency('json-c', required: build_runner)
+
+if not build_tests and jsonc.found()
error('Building test runner requires building tests')
endif
-if _build_runner and _build_tests and jsonc.found()
+if jsonc.found()
subdir('testdata')
runnerlib = static_library('igt_runner', runnerlib_sources,
@@ -58,7 +60,7 @@ if _build_runner and _build_tests and jsonc.found()
dependencies : [igt_deps, jsonc])
test('runner_json', runner_json_test)
- build_info += 'Build test runner: Yes'
+ build_info += 'Build test runner: true'
else
- build_info += 'Build test runner: No'
+ build_info += 'Build test runner: false'
endif
diff --git a/tests/meson.build b/tests/meson.build
index 351594fa..5786c2c7 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -243,7 +243,7 @@ if libdrm_nouveau.found()
test_deps += libdrm_nouveau
endif
-if chamelium_found
+if chamelium.found()
test_progs += [
'kms_chamelium',
]
--
2.21.0
More information about the igt-dev
mailing list