Skip to content
Snippets Groups Projects
Commit 0e98bf69 authored by Petri Latvala's avatar Petri Latvala Committed by Arkadiusz Hiler
Browse files

meson: Add options to control optional parts


Distributions want explicit control over optional parts so they can
state runtime dependencies before building. Let's restore the
functionality autotools used to provide.

Where possible, the selection is done by choosing whether to build a
particular item and the option name is build_$item. Example:
build_overlay. Where not possible, the option name is
with_$item. Example: with_valgrind.

Array options require a bump of required meson version to 0.44. Debian
stable has meson 0.37 which is already too old, stable-backports has
0.45, CI uses 0.45. Mesa's meson requirement is 0.44.1, for a
perspective.

Note, the old hack for not building docs when cross-compiling is
gone, as doc building can be explicitly controlled now.

v2: glib not optional
v3: bump meson version to 0.44

Signed-off-by: default avatarPetri Latvala <petri.latvala@intel.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Eric Anholt <eric@anholt.net>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 9bbfbb1c
No related branches found
No related tags found
No related merge requests found
......@@ -35,10 +35,10 @@ foreach prog : benchmark_progs
executable(prog + '_bench', prog + '.c',
install : true,
install_dir : benchmarksdir,
dependencies : test_deps)
dependencies : igt_deps)
endforeach
executable('gem_wsim_bench', 'gem_wsim.c',
install : true,
install_dir : benchmarksdir,
dependencies : test_deps + [ lib_igt_perf ])
dependencies : igt_deps + [ lib_igt_perf ])
......@@ -22,10 +22,10 @@ defs_rst = configure_file(input : 'defs.rst.in',
output : 'defs.rst',
configuration : config)
rst2man = find_program('rst2man', required : false)
rst2man = find_program('rst2man', required : _man_required)
rst2man_script = find_program('rst2man.sh')
if rst2man.found()
if _build_man and rst2man.found()
foreach manpage : manpages
custom_target(manpage + '.1',
build_by_default : true,
......@@ -36,4 +36,10 @@ if rst2man.found()
install : true,
install_dir : join_paths(mandir, 'man1'))
endforeach
build_info += 'Build man pages: Yes'
else
if _man_required
error('Cannot build man pages due to missing dependencies')
endif
build_info += 'Build man pages: No'
endif
......@@ -5,7 +5,7 @@ project('igt-gpu-tools', 'c',
'c_std=gnu99',
],
license : 'MIT',
meson_version : '>0.40.0')
meson_version : '>0.44.0')
cc = meson.get_compiler('c')
......@@ -26,36 +26,118 @@ foreach cc_arg : cc_args
endif
endforeach
_build_overlay = false
_overlay_required = false
_build_man = false
_man_required = false
_build_audio = false
_audio_required = false
_build_chamelium = false
_chamelium_required = false
_build_docs = false
_docs_required = false
_build_tests = false
_tests_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_audio = get_option('build_audio')
build_chamelium = get_option('build_chamelium')
build_docs = get_option('build_docs')
build_tests = get_option('build_tests')
with_libdrm = get_option('with_libdrm')
_build_overlay = build_overlay != 'false'
_overlay_required = build_overlay == 'true'
_build_man = build_man != 'false'
_man_required = build_man == 'true'
_build_audio = build_audio != 'false'
_audio_required = build_audio == '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_info = []
inc = include_directories('include/drm-uapi', 'lib', '.')
inc_for_gtkdoc = include_directories('lib')
config = configuration_data()
null_dep = dependency('', required : false)
libdrm_info = []
libdrm_intel = null_dep
libdrm_nouveau = null_dep
libdrm_amdgpu = null_dep
libdrm_version = '>=2.4.82'
libdrm = dependency('libdrm', version : libdrm_version)
libdrm_intel = dependency('libdrm_intel', version : libdrm_version, required : false)
libdrm_nouveau = dependency('libdrm_nouveau', version : libdrm_version, required : false)
libdrm_amdgpu = dependency('libdrm_amdgpu', version : libdrm_version, required : false)
if with_libdrm.contains('auto') or with_libdrm.contains('intel')
libdrm_intel = dependency('libdrm_intel', version : libdrm_version, required : with_libdrm.contains('intel'))
libdrm_info += 'intel'
endif
if with_libdrm.contains('auto') or with_libdrm.contains('nouveau')
libdrm_nouveau = dependency('libdrm_nouveau', version : libdrm_version, required : with_libdrm.contains('nouveau'))
libdrm_info += 'nouveau'
endif
if with_libdrm.contains('auto') or with_libdrm.contains('amdgpu')
libdrm_amdgpu = dependency('libdrm_amdgpu', version : libdrm_version, required : with_libdrm.contains('amdgpu'))
libdrm_info += 'amdgpu'
endif
build_info += 'With libdrm: ' + ','.join(libdrm_info)
pciaccess = dependency('pciaccess', version : '>=0.10')
libkmod = dependency('libkmod')
libprocps = dependency('libprocps', required : true)
libunwind = dependency('libunwind', required : true)
valgrind = dependency('valgrind', required : false)
if valgrind.found()
config.set('HAVE_VALGRIND', 1)
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
endif
build_info += 'Valgrind annotations: ' + valgrindinfo
cairo = dependency('cairo', version : '>1.12.0', required : true)
libudev = dependency('libudev', required : true)
glib = dependency('glib-2.0', required : true)
gsl = dependency('gsl', required : false)
alsa = dependency('alsa', required : false)
gsl = null_dep
alsa = null_dep
pixman = null_dep
if _build_audio or _build_chamelium
gsl = dependency('gsl', required : _audio_required or _chamelium_required)
endif
if _build_audio
alsa = dependency('alsa', required : _audio_required)
endif
if _build_chamelium
pixman = dependency('pixman-1', required : _chamelium_required)
endif
audioinfo = 'No'
if _build_audio and alsa.found() and gsl.found()
audioinfo = 'Yes'
else
if _audio_required
error('Cannot build audio test due to missing dependencies')
endif
_build_audio = false
endif
build_info += 'Build audio test: ' + audioinfo
pixman = dependency('pixman-1', required : false)
xmlrpc = dependency('xmlrpc', required : false)
xmlrpc_util = dependency('xmlrpc_util', required : false)
xmlrpc_client = dependency('xmlrpc_client', required : false)
......@@ -73,13 +155,17 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
endif
endif
if pixman.found() and gsl.found() and xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found()
chamelium = null_dep
chameliuminfo = 'No'
if _build_chamelium and pixman.found() and gsl.found() and xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found()
chamelium = declare_dependency(dependencies : [ pixman, xmlrpc,
xmlrpc_util, xmlrpc_client])
xmlrpc_util, xmlrpc_client])
config.set('HAVE_CHAMELIUM', 1)
else
chamelium = dependency('', required: false)
chameliuminfo = 'Yes'
elif _chamelium_required
error('Cannot build chamelium test due to missing dependencies')
endif
build_info += 'Build Chamelium test: ' + chameliuminfo
pthreads = dependency('threads')
math = cc.find_library('m')
......@@ -130,17 +216,33 @@ mandir = get_option('mandir')
pkgconfigdir = join_paths(libdir, 'pkgconfig')
subdir('lib')
subdir('tests')
if _build_tests
subdir('tests')
build_info += 'Build tests: Yes'
else
build_info += 'Build tests: No'
endif
subdir('benchmarks')
subdir('tools')
if libdrm_intel.found()
subdir('assembler')
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
subdir('overlay')
endif
endif
subdir('overlay')
subdir('man')
# has_exe_wrapper() is undefined if building natively
if not meson.is_cross_build() or not meson.has_exe_wrapper()
subdir('docs')
docs_info = 'No'
if _build_docs
if _build_tests
subdir('docs')
docs_info = 'Yes'
elif _docs_required
error('Documentation requires building tests')
endif
endif
build_info += 'Build documentation: ' + docs_info
message('Build options')
message('=============')
foreach str : build_info
message(str)
endforeach
option('build_overlay',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build overlay')
option('overlay_backends',
type : 'array',
value : ['auto'],
choices : [ 'auto', 'x', 'xv' ],
description : 'Overlay backends to enable')
option('build_audio',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build audio test')
option('build_chamelium',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build chamelium test')
option('with_valgrind',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build with support for valgrind annotations')
option('build_man',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build man pages')
option('build_docs',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build documentation')
option('build_tests',
type : 'combo',
value : 'auto',
choices : ['auto', 'true', 'false'],
description : 'Build tests')
option('with_libdrm',
type : 'array',
value : ['auto'],
choices : ['', 'auto', 'intel', 'nouveau', 'amdgpu'],
description : 'libdrm libraries to be used')
option('use_rpath',
type : 'boolean',
value : false,
......
......@@ -14,20 +14,35 @@ gpu_overlay_src = [
'rc6.c',
]
xv = dependency('xv', required : false)
x11 = dependency('x11', required : false)
xext = dependency('xext', required : false)
dri2proto = dependency('dri2proto', version : '>= 2.6', required : false)
cairo_xlib = dependency('cairo-xlib', required : false)
xrandr = dependency('xrandr', version : '>=1.3', required : false)
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
xv_backend_required = overlay_backends.contains('xv')
xlib_backend_required = overlay_backends.contains('x')
endif
xv = dependency('xv', required : xv_backend_required)
x11 = dependency('x11', required : xv_backend_required)
xext = dependency('xext', required : xv_backend_required)
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)
gpu_overlay_deps = [ realtime, math, cairo, pciaccess, libdrm,
libdrm_intel, lib_igt_perf ]
both_x11_src = ''
with_xv_backend = false
with_xlib_backend = false
backends_strings = []
gpu_overlay_cflags = []
if xv.found() and x11.found() and xext.found() and dri2proto.found()
if build_xv_backend and xv.found() and x11.found() and xext.found() and dri2proto.found()
both_x11_src = 'x11/position.c'
gpu_overlay_src += [
'x11/dri2.c',
......@@ -38,20 +53,24 @@ if xv.found() and x11.found() and xext.found() and dri2proto.found()
]
gpu_overlay_deps += [ xv, x11, xext, dri2proto ]
gpu_overlay_cflags += [ '-DHAVE_OVERLAY_XVLIB' ]
with_xv_backend = true
backends_strings += 'Xv'
endif
if cairo_xlib.found() and xrandr.found() and dri2proto.found()
if build_xlib_backend and cairo_xlib.found() and dri2proto.found()
both_x11_src = 'x11/position.c'
gpu_overlay_src += 'x11/x11-window.c'
gpu_overlay_deps += [ cairo_xlib, dri2proto ]
gpu_overlay_cflags += [ '-DHAVE_OVERLAY_XLIB' ]
with_xlib_backend = true
backends_strings += 'X'
endif
gpu_overlay_src += both_x11_src
gpu_overlay_src += 'kms/kms-overlay.c'
leg = find_program('leg', required : false)
leg = find_program('leg', required : _overlay_required)
if leg.found()
leg_file = custom_target('tracepoint_format',
output: 'tracepoint_format.h',
......@@ -62,10 +81,17 @@ else
message('WARNING: leg command not found, disabling overlay; try : apt-get install peg')
endif
if leg.found() and xrandr.found() and cairo.found()
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)
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 += 'Overlay backends: ' + ','.join(backends_strings)
else
if _overlay_required
error('Cannot build overlay due to missing dependencies')
endif
build_info += 'Build overlay: No'
endif
......@@ -232,14 +232,14 @@ if libdrm_nouveau.found()
test_deps += libdrm_nouveau
endif
if chamelium.found()
if _build_chamelium and chamelium.found()
test_progs += [
'kms_chamelium',
]
test_deps += chamelium
endif
if alsa.found() and gsl.found()
if _build_audio and alsa.found() and gsl.found()
test_progs += [
'audio',
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment