mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
meson: Use dicts to initialize cfg_data objects
Instead of creating an empty object and then setting keys one at a time, it is possible to pass a dict object to configuration_data(). This is nicer because it doesn't require repeating the name of the cfg_data object over and over. There is one exception: the 'conf' object, where we store values that are used directly by C code. In that case, using a dict object is not feasible for two reasons: first of all, replacing the set_quoted() calls would result in awkward code with a lot of calls to format(); moreover, since code that modifies it is sprinkled all over the place, refactoring it would probably make things more complicated rather than simpler. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
64a7b8203b
commit
b94239a61e
@ -1,14 +1,7 @@
|
|||||||
syntax_check_conf = configuration_data()
|
|
||||||
syntax_check_conf.set('top_srcdir', meson.source_root())
|
|
||||||
syntax_check_conf.set('top_builddir', meson.build_root())
|
|
||||||
|
|
||||||
flake8_path = ''
|
flake8_path = ''
|
||||||
if flake8_prog.found()
|
if flake8_prog.found()
|
||||||
flake8_path = flake8_prog.path()
|
flake8_path = flake8_prog.path()
|
||||||
endif
|
endif
|
||||||
syntax_check_conf.set('flake8_path', flake8_path)
|
|
||||||
syntax_check_conf.set('runutf8', ' '.join(runutf8))
|
|
||||||
syntax_check_conf.set('PYTHON3', python3_prog.path())
|
|
||||||
|
|
||||||
if host_machine.system() == 'freebsd' or host_machine.system() == 'darwin'
|
if host_machine.system() == 'freebsd' or host_machine.system() == 'darwin'
|
||||||
make_prog = find_program('gmake')
|
make_prog = find_program('gmake')
|
||||||
@ -33,8 +26,15 @@ else
|
|||||||
grep_prog = find_program('grep')
|
grep_prog = find_program('grep')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syntax_check_conf.set('GREP', grep_prog.path())
|
syntax_check_conf = configuration_data({
|
||||||
syntax_check_conf.set('SED', sed_prog.path())
|
'top_srcdir': meson.source_root(),
|
||||||
|
'top_builddir': meson.build_root(),
|
||||||
|
'flake8_path': flake8_path,
|
||||||
|
'runutf8': ' '.join(runutf8),
|
||||||
|
'PYTHON3': python3_prog.path(),
|
||||||
|
'GREP': grep_prog.path(),
|
||||||
|
'SED': sed_prog.path(),
|
||||||
|
})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: 'Makefile.in',
|
input: 'Makefile.in',
|
||||||
|
@ -84,10 +84,11 @@ foreach name : keyname_list
|
|||||||
}
|
}
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
docs_man_conf = configuration_data()
|
docs_man_conf = configuration_data({
|
||||||
docs_man_conf.set('SYSCONFDIR', sysconfdir)
|
'SYSCONFDIR': sysconfdir,
|
||||||
docs_man_conf.set('RUNSTATEDIR', runstatedir)
|
'RUNSTATEDIR': runstatedir,
|
||||||
docs_man_conf.set('VERSION', meson.project_version())
|
'VERSION': meson.project_version(),
|
||||||
|
})
|
||||||
|
|
||||||
foreach data : docs_man_files
|
foreach data : docs_man_files
|
||||||
rst_in_file = '@0@.rst'.format(data['name'])
|
rst_in_file = '@0@.rst'.format(data['name'])
|
||||||
|
35
meson.build
35
meson.build
@ -2135,14 +2135,15 @@ pkgconfig_files = [
|
|||||||
'libvirt-admin.pc.in',
|
'libvirt-admin.pc.in',
|
||||||
]
|
]
|
||||||
|
|
||||||
pkgconfig_conf = configuration_data()
|
pkgconfig_conf = configuration_data({
|
||||||
pkgconfig_conf.set('VERSION', meson.project_version())
|
'VERSION': meson.project_version(),
|
||||||
pkgconfig_conf.set('datadir', datadir)
|
'datadir': datadir,
|
||||||
pkgconfig_conf.set('datarootdir', datadir)
|
'datarootdir': datadir,
|
||||||
pkgconfig_conf.set('exec_prefix', prefix)
|
'exec_prefix': prefix,
|
||||||
pkgconfig_conf.set('includedir', includedir)
|
'includedir': includedir,
|
||||||
pkgconfig_conf.set('libdir', libdir)
|
'libdir': libdir,
|
||||||
pkgconfig_conf.set('prefix', prefix)
|
'prefix': prefix,
|
||||||
|
})
|
||||||
|
|
||||||
pkgconfig_dir = libdir / 'pkgconfig'
|
pkgconfig_dir = libdir / 'pkgconfig'
|
||||||
|
|
||||||
@ -2165,8 +2166,9 @@ if git
|
|||||||
'mingw-libvirt.spec.in',
|
'mingw-libvirt.spec.in',
|
||||||
]
|
]
|
||||||
|
|
||||||
spec_conf = configuration_data()
|
spec_conf = configuration_data({
|
||||||
spec_conf.set('VERSION', meson.project_version())
|
'VERSION': meson.project_version(),
|
||||||
|
})
|
||||||
|
|
||||||
foreach file : spec_files
|
foreach file : spec_files
|
||||||
configure_file(
|
configure_file(
|
||||||
@ -2180,8 +2182,9 @@ if git
|
|||||||
env: runutf8, check: true)
|
env: runutf8, check: true)
|
||||||
authors_file = 'AUTHORS.rst.in'
|
authors_file = 'AUTHORS.rst.in'
|
||||||
|
|
||||||
authors_conf = configuration_data()
|
authors_conf = configuration_data({
|
||||||
authors_conf.set('contributorslist', authors.stdout())
|
'contributorslist': authors.stdout(),
|
||||||
|
})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: authors_file,
|
input: authors_file,
|
||||||
@ -2209,9 +2212,11 @@ configure_file(output: 'meson-config.h', configuration: conf)
|
|||||||
|
|
||||||
|
|
||||||
# generate run helper
|
# generate run helper
|
||||||
run_conf = configuration_data()
|
run_conf = configuration_data({
|
||||||
run_conf.set('abs_builddir', meson.build_root())
|
'abs_builddir': meson.build_root(),
|
||||||
run_conf.set('abs_top_builddir', meson.build_root())
|
'abs_top_builddir': meson.build_root(),
|
||||||
|
})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: 'run.in',
|
input: 'run.in',
|
||||||
output: '@BASENAME@',
|
output: '@BASENAME@',
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
i18n = import('i18n')
|
i18n = import('i18n')
|
||||||
|
|
||||||
potfiles_conf = configuration_data()
|
potfiles_conf = configuration_data({
|
||||||
potfiles_conf.set('SRCDIR', '')
|
'SRCDIR': '',
|
||||||
potfiles_conf.set('BUILDDIR', '')
|
'BUILDDIR': '',
|
||||||
|
})
|
||||||
|
|
||||||
potfiles = configure_file(
|
potfiles = configure_file(
|
||||||
input: 'POTFILES.in',
|
input: 'POTFILES.in',
|
||||||
|
@ -698,20 +698,23 @@ endforeach
|
|||||||
foreach data : virt_daemon_confs
|
foreach data : virt_daemon_confs
|
||||||
capitalize_args = [ '-c', 'print("@0@".capitalize())'.format(data['name']) ]
|
capitalize_args = [ '-c', 'print("@0@".capitalize())'.format(data['name']) ]
|
||||||
name_uc = run_command(python3_prog, capitalize_args, check: true, env: runutf8).stdout().strip()
|
name_uc = run_command(python3_prog, capitalize_args, check: true, env: runutf8).stdout().strip()
|
||||||
daemon_conf = configuration_data()
|
|
||||||
daemon_conf.set('runstatedir', runstatedir)
|
|
||||||
daemon_conf.set('sbindir', sbindir)
|
|
||||||
daemon_conf.set('sysconfdir', sysconfdir)
|
|
||||||
daemon_conf.set('DAEMON_NAME', data['name'])
|
|
||||||
daemon_conf.set('DAEMON_NAME_UC', name_uc)
|
|
||||||
# to silence meson warning about missing 'CONFIG' in the configuration_data
|
|
||||||
daemon_conf.set('CONFIG', '@CONFIG@')
|
|
||||||
if conf.has('WITH_POLKIT')
|
if conf.has('WITH_POLKIT')
|
||||||
daemon_conf.set('default_auth', 'polkit')
|
default_auth = 'polkit'
|
||||||
else
|
else
|
||||||
daemon_conf.set('default_auth', 'none')
|
default_auth = 'none'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
daemon_conf = configuration_data({
|
||||||
|
'runstatedir': runstatedir,
|
||||||
|
'sbindir': sbindir,
|
||||||
|
'sysconfdir': sysconfdir,
|
||||||
|
'DAEMON_NAME': data['name'],
|
||||||
|
'DAEMON_NAME_UC': name_uc,
|
||||||
|
'default_auth': default_auth,
|
||||||
|
# to silence meson warning about missing 'CONFIG' in the configuration_data
|
||||||
|
'CONFIG': '@CONFIG@',
|
||||||
|
})
|
||||||
|
|
||||||
if data.get('with_ip', false)
|
if data.get('with_ip', false)
|
||||||
conf_in = libvirtd_conf_tmp
|
conf_in = libvirtd_conf_tmp
|
||||||
@ -783,20 +786,23 @@ if conf.has('WITH_LIBVIRTD')
|
|||||||
)
|
)
|
||||||
|
|
||||||
foreach unit : virt_daemon_units
|
foreach unit : virt_daemon_units
|
||||||
unit_conf = configuration_data()
|
|
||||||
unit_conf.set('runstatedir', runstatedir)
|
|
||||||
unit_conf.set('sbindir', sbindir)
|
|
||||||
unit_conf.set('sysconfdir', sysconfdir)
|
|
||||||
unit_conf.set('name', unit['name'])
|
|
||||||
unit_conf.set('service', unit['service'])
|
|
||||||
unit_conf.set('sockprefix', unit['sockprefix'])
|
|
||||||
unit_conf.set('deps', unit.get('deps', ''))
|
|
||||||
if conf.has('WITH_POLKIT')
|
if conf.has('WITH_POLKIT')
|
||||||
unit_conf.set('mode', '0666')
|
mode = '0666'
|
||||||
else
|
else
|
||||||
unit_conf.set('mode', '0600')
|
mode = '0600'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unit_conf = configuration_data({
|
||||||
|
'runstatedir': runstatedir,
|
||||||
|
'sbindir': sbindir,
|
||||||
|
'sysconfdir': sysconfdir,
|
||||||
|
'name': unit['name'],
|
||||||
|
'service': unit['service'],
|
||||||
|
'sockprefix': unit['sockprefix'],
|
||||||
|
'deps': unit.get('deps', ''),
|
||||||
|
'mode': mode,
|
||||||
|
})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: unit['service_in'],
|
input: unit['service_in'],
|
||||||
output: '@0@.service'.format(unit['service']),
|
output: '@0@.service'.format(unit['service']),
|
||||||
@ -829,15 +835,17 @@ if conf.has('WITH_LIBVIRTD')
|
|||||||
# Generate openrc init files
|
# Generate openrc init files
|
||||||
if init_script == 'openrc'
|
if init_script == 'openrc'
|
||||||
foreach init : openrc_init_files
|
foreach init : openrc_init_files
|
||||||
init_conf = configuration_data()
|
|
||||||
init_conf.set('sbindir', sbindir)
|
|
||||||
init_conf.set('runstatedir', runstatedir)
|
|
||||||
if conf.has('WITH_FIREWALLD')
|
if conf.has('WITH_FIREWALLD')
|
||||||
need_firewalld = 'need firewalld'
|
need_firewalld = 'need firewalld'
|
||||||
else
|
else
|
||||||
need_firewalld = ''
|
need_firewalld = ''
|
||||||
endif
|
endif
|
||||||
init_conf.set('NEED_FIREWALLD', need_firewalld)
|
|
||||||
|
init_conf = configuration_data({
|
||||||
|
'sbindir': sbindir,
|
||||||
|
'runstatedir': runstatedir,
|
||||||
|
'NEED_FIREWALLD': need_firewalld,
|
||||||
|
})
|
||||||
|
|
||||||
init_file = configure_file(
|
init_file = configure_file(
|
||||||
input: init['in_file'],
|
input: init['in_file'],
|
||||||
@ -1010,10 +1018,11 @@ run_pkg_config_files = [
|
|||||||
'libvirt.pc.in',
|
'libvirt.pc.in',
|
||||||
]
|
]
|
||||||
|
|
||||||
run_pkg_config_conf = configuration_data()
|
run_pkg_config_conf = configuration_data({
|
||||||
run_pkg_config_conf.set('VERSION', meson.project_version())
|
'VERSION': meson.project_version(),
|
||||||
run_pkg_config_conf.set('abs_top_builddir', meson.build_root())
|
'abs_top_builddir': meson.build_root(),
|
||||||
run_pkg_config_conf.set('abs_top_srcdir', meson.source_root())
|
'abs_top_srcdir': meson.source_root(),
|
||||||
|
})
|
||||||
|
|
||||||
foreach file : run_pkg_config_files
|
foreach file : run_pkg_config_files
|
||||||
configure_file(
|
configure_file(
|
||||||
|
@ -240,8 +240,9 @@ if conf.has('WITH_REMOTE')
|
|||||||
runstatedir / 'libvirt' / 'common',
|
runstatedir / 'libvirt' / 'common',
|
||||||
]
|
]
|
||||||
|
|
||||||
logrotate_conf = configuration_data()
|
logrotate_conf = configuration_data({
|
||||||
logrotate_conf.set('localstatedir', localstatedir)
|
'localstatedir': localstatedir,
|
||||||
|
})
|
||||||
|
|
||||||
foreach name : logrotate_files
|
foreach name : logrotate_files
|
||||||
log_file = configure_file(
|
log_file = configure_file(
|
||||||
|
@ -5,11 +5,12 @@ apparmor_gen_profiles = [
|
|||||||
'usr.sbin.virtxend',
|
'usr.sbin.virtxend',
|
||||||
]
|
]
|
||||||
|
|
||||||
apparmor_gen_profiles_conf = configuration_data()
|
apparmor_gen_profiles_conf = configuration_data({
|
||||||
apparmor_gen_profiles_conf.set('sysconfdir', sysconfdir)
|
'sysconfdir': sysconfdir,
|
||||||
apparmor_gen_profiles_conf.set('sbindir', sbindir)
|
'sbindir': sbindir,
|
||||||
apparmor_gen_profiles_conf.set('runstatedir', runstatedir)
|
'runstatedir': runstatedir,
|
||||||
apparmor_gen_profiles_conf.set('libexecdir', libexecdir)
|
'libexecdir': libexecdir,
|
||||||
|
})
|
||||||
|
|
||||||
apparmor_dir = sysconfdir / 'apparmor.d'
|
apparmor_dir = sysconfdir / 'apparmor.d'
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ completion_commands = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
foreach command : completion_commands
|
foreach command : completion_commands
|
||||||
completion_conf = configuration_data()
|
completion_conf = configuration_data({
|
||||||
completion_conf.set('command', command)
|
'command': command,
|
||||||
|
})
|
||||||
completion = configure_file(
|
completion = configure_file(
|
||||||
input: 'vsh.in',
|
input: 'vsh.in',
|
||||||
output: command,
|
output: command,
|
||||||
|
@ -231,16 +231,17 @@ if conf.has('WITH_REMOTE')
|
|||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
tools_conf = configuration_data()
|
tools_conf = configuration_data({
|
||||||
tools_conf.set('PACKAGE', meson.project_name())
|
'PACKAGE': meson.project_name(),
|
||||||
tools_conf.set('VERSION', meson.project_version())
|
'VERSION': meson.project_version(),
|
||||||
tools_conf.set('bindir', bindir)
|
'bindir': bindir,
|
||||||
tools_conf.set('libexecdir', libexecdir)
|
'libexecdir': libexecdir,
|
||||||
tools_conf.set('localedir', localedir)
|
'localedir': localedir,
|
||||||
tools_conf.set('localstatedir', localstatedir)
|
'localstatedir': localstatedir,
|
||||||
tools_conf.set('sbindir', sbindir)
|
'sbindir': sbindir,
|
||||||
tools_conf.set('schemadir', pkgdatadir / 'schemas')
|
'schemadir': pkgdatadir / 'schemas',
|
||||||
tools_conf.set('sysconfdir', sysconfdir)
|
'sysconfdir': sysconfdir,
|
||||||
|
})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: 'virt-xml-validate.in',
|
input: 'virt-xml-validate.in',
|
||||||
|
Loading…
Reference in New Issue
Block a user