libvirt/build-aux/meson.build
Andrea Bolognani b94239a61e 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>
2022-04-01 15:33:19 +02:00

70 lines
1.7 KiB
Meson

flake8_path = ''
if flake8_prog.found()
flake8_path = flake8_prog.path()
endif
if host_machine.system() == 'freebsd' or host_machine.system() == 'darwin'
make_prog = find_program('gmake')
sed_prog = find_program('gsed')
else
make_prog = find_program('make')
sed_prog = find_program('sed')
endif
if host_machine.system() == 'freebsd'
grep_prog = find_program('grep')
grep_cmd = run_command(grep_prog, '--version', check: true)
if grep_cmd.stdout().startswith('grep (BSD grep')
grep_prog = find_program('/usr/local/bin/grep', required: false)
if not grep_prog.found()
error('GNU grep not found')
endif
endif
elif host_machine.system() == 'darwin'
grep_prog = find_program('ggrep')
else
grep_prog = find_program('grep')
endif
syntax_check_conf = configuration_data({
'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(
input: 'Makefile.in',
output: '@BASENAME@',
configuration: syntax_check_conf,
)
rc = run_command(
'sed', '-n',
's/^\\(sc_[a-zA-Z0-9_-]*\\):.*/\\1/p',
meson.current_source_dir() / 'syntax-check.mk',
check: true,
)
sc_tests = rc.stdout().strip().split()
# Skip syntax-check if not building from git because we get the list of files
# to check using git commands and it fails if we are not in git repository.
if git
foreach target : sc_tests
test(
target,
make_prog,
args: [ '-C', meson.current_build_dir(), target ],
depends: [
potfiles_dep,
],
suite: 'syntax-check',
)
endforeach
endif