aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-01-19 12:42:25 -0800
committerEli Schwartz <eschwartz93@gmail.com>2022-01-28 15:53:20 -0500
commit11f96380351a88059ec55f1070fdebc1b1033117 (patch)
tree3577f52920c3e2159f193605a894cb090b95ec10 /mesonbuild/modules
parentb402817fb6f0392812bfa272bdbc05c9c30139fa (diff)
downloadmeson-11f96380351a88059ec55f1070fdebc1b1033117.zip
meson-11f96380351a88059ec55f1070fdebc1b1033117.tar.gz
meson-11f96380351a88059ec55f1070fdebc1b1033117.tar.bz2
build: replace kwargs in CustomTarget initializer
Because we don't want to pass the Interpreter kwargs into the build layer. This turned out to be a mega commit, as there's really on elegant way to make this change in an incremental way. On the nice side, mypy made this change super easy, as nearly all of the calls to `CustomTarget` are fully type checked! It also turns out that we're not handling install_tags in custom_target correctly, since we're not converting the boolean values into Optional values!
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/gnome.py383
-rw-r--r--mesonbuild/modules/hotdoc.py7
-rw-r--r--mesonbuild/modules/i18n.py77
-rw-r--r--mesonbuild/modules/java.py18
-rw-r--r--mesonbuild/modules/qt.py59
-rw-r--r--mesonbuild/modules/unstable_external_project.py19
-rw-r--r--mesonbuild/modules/unstable_rust.py22
-rw-r--r--mesonbuild/modules/windows.py27
8 files changed, 331 insertions, 281 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index ffdfd42..37d4d92 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -148,7 +148,7 @@ if T.TYPE_CHECKING:
build_by_default: T.Optional[bool]
depend_files: T.List[mesonlib.File]
extra_args: T.List[str]
- install_dir: T.List[T.Union[str, bool]]
+ install_dir: T.Union[str, bool]
install_header: bool
internal: bool
nostdinc: bool
@@ -404,7 +404,7 @@ class GnomeModule(ExtensionModule):
glib_version = self._get_native_glib_version(state)
glib_compile_resources = state.find_program('glib-compile-resources')
- cmd = [glib_compile_resources, '@INPUT@']
+ cmd: T.List[T.Union[ExternalProgram, str]] = [glib_compile_resources, '@INPUT@']
source_dirs = kwargs['source_dir']
dependencies = kwargs['dependencies']
@@ -486,39 +486,47 @@ class GnomeModule(ExtensionModule):
if install_header and not kwargs['export']:
raise MesonException('GResource header is installed yet export is not enabled')
- c_kwargs: T.Dict[str, T.Any] = {
- 'build_by_default': kwargs['build_by_default'],
- 'depends': depends,
- 'input': input_file,
- 'install': kwargs['install'],
- 'install_dir': kwargs['install_dir'] or [],
- 'output': output,
- }
+ depfile: T.Optional[str] = None
+ target_cmd: T.List[T.Union[ExternalProgram, str]]
if not mesonlib.version_compare(glib_version, gresource_dep_needed_version):
# This will eventually go out of sync if dependencies are added
- c_kwargs['depend_files'] = depend_files
- c_kwargs['command'] = cmd
+ target_cmd = cmd
else:
depfile = f'{output}.d'
- c_kwargs['depfile'] = depfile
- c_kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@']
- target_c = GResourceTarget(name, state.subdir, state.subproject, c_kwargs)
+ depend_files = []
+ target_cmd = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@']
+ target_c = GResourceTarget(
+ name,
+ state.subdir,
+ state.subproject,
+ target_cmd,
+ [input_file],
+ [output],
+ build_by_default=kwargs['build_by_default'],
+ depfile=depfile,
+ depend_files=depend_files,
+ extra_depends=depends,
+ install=kwargs['install'],
+ install_dir=[kwargs['install_dir']] if kwargs['install_dir'] else [],
+ )
if gresource: # Only one target for .gresource files
return ModuleReturnValue(target_c, [target_c])
- h_kwargs: T.Dict[str, T.Any] = {
- 'command': cmd,
- 'input': input_file,
- 'output': f'{target_name}.h',
- # The header doesn't actually care about the files yet it errors if missing
- 'depends': depends,
- 'build_by_default': kwargs['build_by_default'],
- 'install_dir': kwargs['install_dir'] or [state.environment.coredata.get_option(mesonlib.OptionKey('includedir'))],
- }
- if install_header:
- h_kwargs['install'] = install_header
- target_h = GResourceHeaderTarget(f'{target_name}_h', state.subdir, state.subproject, h_kwargs)
+ install_dir = kwargs['install_dir'] or state.environment.coredata.get_option(mesonlib.OptionKey('includedir'))
+ assert isinstance(install_dir, str), 'for mypy'
+ target_h = GResourceHeaderTarget(
+ f'{target_name}_h',
+ state.subdir,
+ state.subproject,
+ cmd,
+ [input_file],
+ [f'{target_name}.h'],
+ build_by_default=kwargs['build_by_default'],
+ extra_depends=depends,
+ install=install_header,
+ install_dir=[install_dir],
+ )
rv = [target_c, target_h]
return ModuleReturnValue(rv, rv)
@@ -932,18 +940,19 @@ class GnomeModule(ExtensionModule):
elif install_dir is False:
install = False
- scankwargs = {
- 'input': generated_files,
- 'output': girfile,
- 'command': scan_command,
- 'depends': depends,
- 'install': install,
- 'install_dir': install_dir,
- 'install_tag': 'devel',
- 'build_by_default': kwargs['build_by_default'],
- }
-
- return GirTarget(girfile, state.subdir, state.subproject, scankwargs)
+ return GirTarget(
+ girfile,
+ state.subdir,
+ state.subproject,
+ scan_command,
+ generated_files,
+ [girfile],
+ build_by_default=kwargs['build_by_default'],
+ extra_depends=depends,
+ install=install,
+ install_dir=[install_dir],
+ install_tag=['devel'],
+ )
@staticmethod
def _make_typelib_target(state: 'ModuleState', typelib_output: str,
@@ -960,17 +969,18 @@ class GnomeModule(ExtensionModule):
elif install_dir is False:
install = False
- typelib_kwargs = {
- 'input': generated_files,
- 'output': [typelib_output],
- 'command': list(typelib_cmd),
- 'install': install,
- 'install_dir': install_dir,
- 'install_tag': 'typelib',
- 'build_by_default': kwargs['build_by_default'],
- }
-
- return TypelibTarget(typelib_output, state.subdir, state.subproject, typelib_kwargs)
+ return TypelibTarget(
+ typelib_output,
+ state.subdir,
+ state.subproject,
+ typelib_cmd,
+ generated_files,
+ [typelib_output],
+ install=install,
+ install_dir=[install_dir],
+ install_tag=['typelib'],
+ build_by_default=kwargs['build_by_default'],
+ )
@staticmethod
def _gather_typelib_includes_and_update_depends(
@@ -1178,16 +1188,21 @@ class GnomeModule(ExtensionModule):
srcdir = os.path.join(state.build_to_src, state.subdir)
outdir = state.subdir
- cmd = [state.find_program('glib-compile-schemas'), '--targetdir', outdir, srcdir]
- ct_kwargs = T.cast(T.Dict[str, T.Any], kwargs.copy())
- ct_kwargs['command'] = cmd
- ct_kwargs['input'] = []
- ct_kwargs['output'] = 'gschemas.compiled'
+ cmd: T.List[T.Union[ExternalProgram, str]] = [state.find_program('glib-compile-schemas'), '--targetdir', outdir, srcdir]
if state.subdir == '':
targetname = 'gsettings-compile'
else:
targetname = 'gsettings-compile-' + state.subdir.replace('/', '_')
- target_g = build.CustomTarget(targetname, state.subdir, state.subproject, ct_kwargs)
+ target_g = build.CustomTarget(
+ targetname,
+ state.subdir,
+ state.subproject,
+ cmd,
+ [],
+ ['gschemas.compiled'],
+ build_by_default=kwargs['build_by_default'],
+ depend_files=kwargs['depend_files'],
+ )
self._devenv_prepend('GSETTINGS_SCHEMA_DIR', os.path.join(state.environment.get_build_dir(), state.subdir))
return ModuleReturnValue(target_g, [target_g])
@@ -1289,22 +1304,27 @@ class GnomeModule(ExtensionModule):
potargets.append(potarget)
gmo_file = project_id + '-' + l + '.gmo'
- gmo_kwargs = {'command': [msgfmt, '@INPUT@', '-o', '@OUTPUT@'],
- 'input': po_file,
- 'output': gmo_file,
- }
- gmotarget = build.CustomTarget(f'help-{project_id}-{l}-gmo', l_subdir, state.subproject, gmo_kwargs)
+ gmotarget = build.CustomTarget(
+ f'help-{project_id}-{l}-gmo',
+ l_subdir,
+ state.subproject,
+ [msgfmt, '@INPUT@', '-o', '@OUTPUT@'],
+ [po_file],
+ [gmo_file],
+ )
targets.append(gmotarget)
- merge_kwargs = {'command': [itstool, '-m', os.path.join(l_subdir, gmo_file),
- '-o', '@OUTDIR@', '@INPUT@'],
- 'input': sources_files,
- 'output': sources,
- 'depends': gmotarget,
- 'install': True,
- 'install_dir': l_install_dir,
- }
- mergetarget = build.CustomTarget(f'help-{project_id}-{l}', l_subdir, state.subproject, merge_kwargs)
+ mergetarget = build.CustomTarget(
+ f'help-{project_id}-{l}',
+ l_subdir,
+ state.subproject,
+ [itstool, '-m', os.path.join(l_subdir, gmo_file), '-o', '@OUTDIR@', '@INPUT@'],
+ sources_files,
+ sources,
+ extra_depends=[gmotarget],
+ install=True,
+ install_dir=[l_install_dir],
+ )
targets.append(mergetarget)
allpotarget = build.AliasTarget(f'help-{project_id}-update-po', potargets,
@@ -1377,15 +1397,16 @@ class GnomeModule(ExtensionModule):
else:
header_dirs.append(src_dir)
- t_args = ['--internal', 'gtkdoc',
- '--sourcedir=' + state.environment.get_source_dir(),
- '--builddir=' + state.environment.get_build_dir(),
- '--subdir=' + state.subdir,
- '--headerdirs=' + '@@'.join(header_dirs),
- '--mainfile=' + main_file,
- '--modulename=' + modulename,
- '--moduleversion=' + moduleversion,
- '--mode=' + kwargs['mode']]
+ t_args: T.List[str] = [
+ '--internal', 'gtkdoc',
+ '--sourcedir=' + state.environment.get_source_dir(),
+ '--builddir=' + state.environment.get_build_dir(),
+ '--subdir=' + state.subdir,
+ '--headerdirs=' + '@@'.join(header_dirs),
+ '--mainfile=' + main_file,
+ '--modulename=' + modulename,
+ '--moduleversion=' + moduleversion,
+ '--mode=' + kwargs['mode']]
for tool in ['scan', 'scangobj', 'mkdb', 'mkhtml', 'fixxref']:
program_name = 'gtkdoc-' + tool
program = state.find_program(program_name)
@@ -1432,12 +1453,16 @@ class GnomeModule(ExtensionModule):
t_args.append(f'--installdir={"@@".join(kwargs["install_dir"])}')
t_args += self._get_build_args(kwargs['c_args'], kwargs['include_directories'],
kwargs['dependencies'], state, depends)
- custom_kwargs = {'output': modulename + '-decl.txt',
- 'command': command + t_args,
- 'depends': depends,
- 'build_always_stale': True,
- }
- custom_target = build.CustomTarget(targetname, state.subdir, state.subproject, custom_kwargs)
+ custom_target = build.CustomTarget(
+ targetname,
+ state.subdir,
+ state.subproject,
+ command + t_args,
+ [],
+ [f'{modulename}-decl.txt'],
+ build_always_stale=True,
+ extra_depends=depends,
+ )
alias_target = build.AliasTarget(targetname, [custom_target], state.subdir, state.subproject)
if kwargs['check']:
check_cmd = state.find_program('gtkdoc-check')
@@ -1555,11 +1580,7 @@ class GnomeModule(ExtensionModule):
# Added in https://gitlab.gnome.org/GNOME/glib/commit/e4d68c7b3e8b01ab1a4231bf6da21d045cb5a816 (2.55.2)
# Fixed in https://gitlab.gnome.org/GNOME/glib/commit/cd1f82d8fc741a2203582c12cc21b4dacf7e1872 (2.56.2)
if mesonlib.version_compare(glib_version, '>= 2.56.2'):
- custom_kwargs = {'input': xml_files,
- 'output': output,
- 'command': cmd + ['--body', '--output', '@OUTPUT@', '@INPUT@'],
- 'build_by_default': build_by_default
- }
+ c_cmd = cmd + ['--body', '--output', '@OUTPUT@', '@INPUT@']
else:
if kwargs['docbook'] is not None:
docbook = kwargs['docbook']
@@ -1572,36 +1593,39 @@ class GnomeModule(ExtensionModule):
else:
self._print_gdbus_warning()
cmd += ['--generate-c-code', '@OUTDIR@/' + namebase, '@INPUT@']
-
- custom_kwargs = {'input': xml_files,
- 'output': output,
- 'command': cmd,
- 'build_by_default': build_by_default
- }
-
- cfile_custom_target = build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs)
+ c_cmd = cmd
+
+ cfile_custom_target = build.CustomTarget(
+ output,
+ state.subdir,
+ state.subproject,
+ c_cmd,
+ xml_files,
+ [output],
+ build_by_default=build_by_default,
+ )
targets.append(cfile_custom_target)
output = namebase + '.h'
if mesonlib.version_compare(glib_version, '>= 2.56.2'):
- custom_kwargs = {'input': xml_files,
- 'output': output,
- 'command': cmd + ['--header', '--output', '@OUTPUT@', '@INPUT@'],
- 'build_by_default': build_by_default,
- 'install': install_header,
- 'install_dir': install_dir
- }
+ hfile_cmd = cmd + ['--header', '--output', '@OUTPUT@', '@INPUT@']
+ depends = []
else:
- custom_kwargs = {'input': xml_files,
- 'output': output,
- 'command': cmd,
- 'build_by_default': build_by_default,
- 'install': install_header,
- 'install_dir': install_dir,
- 'depends': cfile_custom_target
- }
-
- hfile_custom_target = build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs)
+ hfile_cmd = cmd
+ depends = [cfile_custom_target]
+
+ hfile_custom_target = build.CustomTarget(
+ output,
+ state.subdir,
+ state.subproject,
+ hfile_cmd,
+ xml_files,
+ [output],
+ build_by_default=build_by_default,
+ extra_depends=depends,
+ install=install_header,
+ install_dir=[install_dir],
+ )
targets.append(hfile_custom_target)
if kwargs['docbook'] is not None:
@@ -1609,8 +1633,6 @@ class GnomeModule(ExtensionModule):
if not isinstance(docbook, str):
raise MesonException('docbook value must be a string.')
- docbook_cmd = cmd + ['--output-directory', '@OUTDIR@', '--generate-docbook', docbook, '@INPUT@']
-
# The docbook output is always ${docbook}-${name_of_xml_file}
output = namebase + '-docbook'
outputs = []
@@ -1618,20 +1640,22 @@ class GnomeModule(ExtensionModule):
outputs.append('{}-{}'.format(docbook, os.path.basename(str(f))))
if mesonlib.version_compare(glib_version, '>= 2.56.2'):
- custom_kwargs = {'input': xml_files,
- 'output': outputs,
- 'command': docbook_cmd,
- 'build_by_default': build_by_default
- }
+ docbook_cmd = cmd + ['--output-directory', '@OUTDIR@', '--generate-docbook', docbook, '@INPUT@']
+ depends = []
else:
- custom_kwargs = {'input': xml_files,
- 'output': outputs,
- 'command': cmd,
- 'build_by_default': build_by_default,
- 'depends': cfile_custom_target
- }
-
- docbook_custom_target = build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs)
+ docbook_cmd = cmd
+ depends = [cfile_custom_target]
+
+ docbook_custom_target = build.CustomTarget(
+ output,
+ state.subdir,
+ state.subproject,
+ docbook_cmd,
+ xml_files,
+ outputs,
+ build_by_default=build_by_default,
+ extra_depends=depends,
+ )
targets.append(docbook_custom_target)
return ModuleReturnValue(targets, targets)
@@ -1835,18 +1859,23 @@ class GnomeModule(ExtensionModule):
) -> build.CustomTarget:
real_cmd: T.List[T.Union[str, ExternalProgram]] = [state.find_program(['glib-mkenums', 'mkenums'])]
real_cmd.extend(cmd)
- custom_kwargs = {
- 'input': sources,
- 'output': [output],
- 'capture': True,
- 'command': real_cmd,
- 'install': install,
- 'install_dir': install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir')),
- 'depends': list(depends or []),
- }
- return build.CustomTarget(output, state.subdir, state.subproject, custom_kwargs,
- # https://github.com/mesonbuild/meson/issues/973
- absolute_paths=True)
+ _install_dir = install_dir or state.environment.coredata.get_option(mesonlib.OptionKey('includedir'))
+ assert isinstance(_install_dir, str), 'for mypy'
+
+ return build.CustomTarget(
+ output,
+ state.subdir,
+ state.subproject,
+ real_cmd,
+ sources,
+ [output],
+ capture=True,
+ install=install,
+ install_dir=[_install_dir],
+ extra_depends=depends,
+ # https://github.com/mesonbuild/meson/issues/973
+ absolute_paths=True,
+ )
@typed_pos_args('gnome.genmarshal', str)
@typed_kwargs(
@@ -1886,36 +1915,45 @@ class GnomeModule(ExtensionModule):
cmd.append(f'--{k.replace("_", "-")}')
install_header = kwargs['install_header']
- install_dir: T.List[T.Union[str, bool]] = kwargs['install_dir'] or []
-
-
- custom_kwargs: T.Dict[str, T.Any] = {
- 'input': sources,
- 'depend_files': kwargs['depend_files'],
- 'install_dir': kwargs['install_dir'],
- }
+ capture = False
# https://github.com/GNOME/glib/commit/0fbc98097fac4d3e647684f344e508abae109fdf
if mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.51.0'):
cmd += ['--output', '@OUTPUT@']
else:
- custom_kwargs['capture'] = True
+ capture = True
header_file = output + '.h'
- custom_kwargs['command'] = cmd + ['--body', '@INPUT@']
+ c_cmd = cmd + ['--body', '@INPUT@']
if mesonlib.version_compare(self._get_native_glib_version(state), '>= 2.53.4'):
# Silence any warnings about missing prototypes
- custom_kwargs['command'] += ['--include-header', header_file]
- custom_kwargs['output'] = output + '.c'
- body = build.CustomTarget(output + '_c', state.subdir, state.subproject, custom_kwargs)
-
- custom_kwargs['install'] = install_header
- custom_kwargs['install_dir'] = install_dir
+ c_cmd += ['--include-header', header_file]
+ body = build.CustomTarget(
+ output + '_c',
+ state.subdir,
+ state.subproject,
+ c_cmd,
+ sources,
+ [f'{output}.c'],
+ capture=capture,
+ depend_files=kwargs['depend_files'],
+ )
+
+ h_cmd = cmd + ['--header', '@INPUT@']
if new_genmarshal:
- cmd += ['--pragma-once']
- custom_kwargs['command'] = cmd + ['--header', '@INPUT@']
- custom_kwargs['output'] = header_file
- header = build.CustomTarget(output + '_h', state.subdir, state.subproject, custom_kwargs)
+ h_cmd += ['--pragma-once']
+ header = build.CustomTarget(
+ output + '_h',
+ state.subdir,
+ state.subproject,
+ h_cmd,
+ sources,
+ [header_file],
+ install=install_header,
+ install_dir=[kwargs['install_dir']] if kwargs['install_dir'] else [],
+ capture=capture,
+ depend_files=kwargs['depend_files'],
+ )
rv = [body, header]
return ModuleReturnValue(rv, rv)
@@ -2021,24 +2059,25 @@ class GnomeModule(ExtensionModule):
cmd.append(gir_file)
vapi_output = library + '.vapi'
- custom_kwargs = {
- 'command': cmd,
- 'input': inputs,
- 'output': vapi_output,
- 'depends': vapi_depends,
- }
datadir = state.environment.coredata.get_option(mesonlib.OptionKey('datadir'))
assert isinstance(datadir, str), 'for mypy'
install_dir = kwargs['install_dir'] or os.path.join(datadir, 'vala', 'vapi')
- custom_kwargs['install'] = kwargs['install']
- custom_kwargs['install_dir'] = install_dir
- custom_kwargs['packages'] = packages
if kwargs['install']:
# We shouldn't need this locally but we install it
deps_target = self._generate_deps(state, library, vapi_packages, install_dir)
created_values.append(deps_target)
- vapi_target = VapiTarget(vapi_output, state.subdir, state.subproject, custom_kwargs)
+ vapi_target = VapiTarget(
+ vapi_output,
+ state.subdir,
+ state.subproject,
+ command=cmd,
+ sources=inputs,
+ outputs=[vapi_output],
+ extra_depends=vapi_depends,
+ install=kwargs['install'],
+ install_dir=[install_dir],
+ )
# So to try our best to get this to just work we need:
# - link with with the correct library
diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py
index 1b89d50..69f39a6 100644
--- a/mesonbuild/modules/hotdoc.py
+++ b/mesonbuild/modules/hotdoc.py
@@ -344,8 +344,9 @@ class HotdocTargetBuilder:
extra_assets=self._extra_assets,
subprojects=self._subprojects,
command=target_cmd,
- depends=self._dependencies,
- output=fullname,
+ extra_depends=self._dependencies,
+ outputs=[fullname],
+ sources=[],
depfile=os.path.basename(depfile),
build_by_default=self.build_by_default)
@@ -379,7 +380,7 @@ class HotdocTargetHolder(CustomTargetHolder):
class HotdocTarget(build.CustomTarget):
def __init__(self, name, subdir, subproject, hotdoc_conf, extra_extension_paths, extra_assets,
subprojects, **kwargs):
- super().__init__(name, subdir, subproject, kwargs, absolute_paths=True)
+ super().__init__(name, subdir, subproject, **kwargs, absolute_paths=True)
self.hotdoc_conf = hotdoc_conf
self.extra_extension_paths = extra_extension_paths
self.extra_assets = extra_assets
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index d84f66e..98070d7 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -188,18 +188,18 @@ class I18nModule(ExtensionModule):
if build_by_default is None:
build_by_default = kwargs['install']
- real_kwargs = {
- 'build_by_default': build_by_default,
- 'command': command,
- 'install': kwargs['install'],
- 'install_dir': kwargs['install_dir'],
- 'output': kwargs['output'],
- 'input': kwargs['input'],
- 'install_tag': kwargs['install_tag'],
- }
-
- ct = build.CustomTarget('', state.subdir, state.subproject,
- T.cast(T.Dict[str, T.Any], real_kwargs))
+ ct = build.CustomTarget(
+ '',
+ state.subdir,
+ state.subproject,
+ command,
+ kwargs['input'],
+ kwargs['output'],
+ build_by_default=build_by_default,
+ install=kwargs['install'],
+ install_dir=kwargs['install_dir'],
+ install_tag=kwargs['install_tag'],
+ )
return ModuleReturnValue(ct, [ct])
@@ -258,18 +258,21 @@ class I18nModule(ExtensionModule):
for l in languages:
po_file = mesonlib.File.from_source_file(state.environment.source_dir,
state.subdir, l+'.po')
- gmo_kwargs = {'command': ['msgfmt', '@INPUT@', '-o', '@OUTPUT@'],
- 'input': po_file,
- 'output': packagename+'.mo',
- 'install': install,
- # We have multiple files all installed as packagename+'.mo' in different install subdirs.
- # What we really wanted to do, probably, is have a rename: kwarg, but that's not available
- # to custom_targets. Crude hack: set the build target's subdir manually.
- # Bonus: the build tree has something usable as an uninstalled bindtextdomain() target dir.
- 'install_dir': path.join(install_dir, l, 'LC_MESSAGES'),
- 'install_tag': 'i18n',
- }
- gmotarget = build.CustomTarget(f'{packagename}-{l}.mo', path.join(state.subdir, l, 'LC_MESSAGES'), state.subproject, gmo_kwargs)
+ gmotarget = build.CustomTarget(
+ f'{packagename}-{l}.mo',
+ path.join(state.subdir, l, 'LC_MESSAGES'),
+ state.subproject,
+ ['msgfmt', '@INPUT@', '-o', '@OUTPUT@'],
+ [po_file],
+ [f'{packagename}.mo'],
+ install=install,
+ # We have multiple files all installed as packagename+'.mo' in different install subdirs.
+ # What we really wanted to do, probably, is have a rename: kwarg, but that's not available
+ # to custom_targets. Crude hack: set the build target's subdir manually.
+ # Bonus: the build tree has something usable as an uninstalled bindtextdomain() target dir.
+ install_dir=[path.join(install_dir, l, 'LC_MESSAGES')],
+ install_tag=['i18n'],
+ )
targets.append(gmotarget)
gmotargets.append(gmotarget)
@@ -331,19 +334,19 @@ class I18nModule(ExtensionModule):
if build_by_default is None:
build_by_default = kwargs['install']
- real_kwargs = {
- 'build_by_default': build_by_default,
- 'command': command,
- 'depends': mo_targets,
- 'install': kwargs['install'],
- 'install_dir': kwargs['install_dir'],
- 'output': kwargs['output'],
- 'input': kwargs['input'],
- 'install_tag': kwargs['install_tag'],
- }
-
- ct = build.CustomTarget('', state.subdir, state.subproject,
- T.cast(T.Dict[str, T.Any], real_kwargs))
+ ct = build.CustomTarget(
+ '',
+ state.subdir,
+ state.subproject,
+ command,
+ kwargs['input'],
+ kwargs['output'],
+ build_by_default=build_by_default,
+ extra_depends=mo_targets,
+ install=kwargs['install'],
+ install_dir=kwargs['install_dir'],
+ install_tag=kwargs['install_tag'],
+ )
return ModuleReturnValue(ct, [ct])
diff --git a/mesonbuild/modules/java.py b/mesonbuild/modules/java.py
index 0af5aec..20cf3fd 100644
--- a/mesonbuild/modules/java.py
+++ b/mesonbuild/modules/java.py
@@ -51,20 +51,22 @@ class JavaModule(ExtensionModule):
else:
header = f'{pathlib.Path(file.fname).stem}.h'
- ct_kwargs = {
- 'input': file,
- 'output': header,
- 'command': [
+ target = CustomTarget(
+ os.path.basename(header),
+ state.subdir,
+ state.subproject,
+ [
self.javac.exelist[0],
'-d',
'@PRIVATE_DIR@',
'-h',
state.subdir,
'@INPUT@',
- ]
- }
-
- target = CustomTarget(os.path.basename(header), state.subdir, state.subproject, backend=state.backend, kwargs=ct_kwargs)
+ ],
+ [file],
+ [header],
+ backend=state.backend,
+ )
# It is only known that 1.8.0 won't pre-create the directory. 11 and 16
# do not exhibit this behavior.
if version_compare(self.javac.version, '1.8.0'):
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index cf97368..37072b4 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -328,14 +328,16 @@ class QtBaseModule(ExtensionModule):
for s in sources:
qrc_deps.extend(self._parse_qrc_deps(state, s))
- rcc_kwargs: T.Dict[str, T.Any] = { # TODO: if CustomTarget had typing information we could use that here...
- 'input': sources,
- 'output': name + '.cpp',
- 'command': self.tools['rcc'].get_command() + ['-name', name, '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
- 'depend_files': qrc_deps,
- 'depfile': f'{name}.d',
- }
- res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
+ res_target = build.CustomTarget(
+ name,
+ state.subdir,
+ state.subproject,
+ self.tools['rcc'].get_command() + ['-name', name, '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
+ sources,
+ [f'{name}.cpp'],
+ depend_files=qrc_deps,
+ depfile=f'{name}.d',
+ )
targets.append(res_target)
else:
for rcc_file in sources:
@@ -345,14 +347,16 @@ class QtBaseModule(ExtensionModule):
else:
basename = os.path.basename(rcc_file.fname)
name = f'qt{self.qt_version}-{basename.replace(".", "_")}'
- rcc_kwargs = {
- 'input': rcc_file,
- 'output': f'{name}.cpp',
- 'command': self.tools['rcc'].get_command() + ['-name', '@BASENAME@', '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
- 'depend_files': qrc_deps,
- 'depfile': f'{name}.d',
- }
- res_target = build.CustomTarget(name, state.subdir, state.subproject, rcc_kwargs)
+ res_target = build.CustomTarget(
+ name,
+ state.subdir,
+ state.subproject,
+ self.tools['rcc'].get_command() + ['-name', '@BASENAME@', '-o', '@OUTPUT@'] + extra_args + ['@INPUT@'] + DEPFILE_ARGS,
+ [rcc_file],
+ [f'{name}.cpp'],
+ depend_files=qrc_deps,
+ depfile=f'{name}.d',
+ )
targets.append(res_target)
return targets
@@ -570,16 +574,19 @@ class QtBaseModule(ExtensionModule):
ts = os.path.basename(ts)
else:
outdir = state.subdir
- cmd = [self.tools['lrelease'], '@INPUT@', '-qm', '@OUTPUT@']
- lrelease_kwargs: T.Dict[str, T.Any] = {
- 'output': '@BASENAME@.qm',
- 'input': ts,
- 'install': kwargs['install'],
- 'install_dir': install_dir or [],
- 'install_tag': 'i18n',
- 'build_by_default': kwargs['build_by_default'],
- 'command': cmd}
- lrelease_target = build.CustomTarget(f'qt{self.qt_version}-compile-{ts}', outdir, state.subproject, lrelease_kwargs)
+ cmd: T.List[T.Union[ExternalProgram, str]] = [self.tools['lrelease'], '@INPUT@', '-qm', '@OUTPUT@']
+ lrelease_target = build.CustomTarget(
+ f'qt{self.qt_version}-compile-{ts}',
+ outdir,
+ state.subproject,
+ cmd,
+ [ts],
+ ['@BASENAME@.qm'],
+ install=kwargs['install'],
+ install_dir=install_dir,
+ install_tag=['i18n'],
+ build_by_default=kwargs['build_by_default'],
+ )
translations.append(lrelease_target)
if qresource:
return ModuleReturnValue(results.return_value[0], [results.new_objects, translations])
diff --git a/mesonbuild/modules/unstable_external_project.py b/mesonbuild/modules/unstable_external_project.py
index 4e3d6db..164af9b 100644
--- a/mesonbuild/modules/unstable_external_project.py
+++ b/mesonbuild/modules/unstable_external_project.py
@@ -227,15 +227,16 @@ class ExternalProject(NewExtensionModule):
if self.verbose:
cmd.append('--verbose')
- target_kwargs = {'output': f'{self.name}.stamp',
- 'depfile': f'{self.name}.d',
- 'command': cmd + ['@OUTPUT@', '@DEPFILE@'],
- 'console': True,
- }
- self.target = build.CustomTarget(self.name,
- self.subdir.as_posix(),
- self.subproject,
- target_kwargs)
+ self.target = build.CustomTarget(
+ self.name,
+ self.subdir.as_posix(),
+ self.subproject,
+ cmd + ['@OUTPUT@', '@DEPFILE@'],
+ [],
+ [f'{self.name}.stamp'],
+ depfile=f'{self.name}.d',
+ console=True,
+ )
idir = build.InstallDir(self.subdir.as_posix(),
Path('dist', self.rel_prefix).as_posix(),
diff --git a/mesonbuild/modules/unstable_rust.py b/mesonbuild/modules/unstable_rust.py
index d0d9ca5..501273f 100644
--- a/mesonbuild/modules/unstable_rust.py
+++ b/mesonbuild/modules/unstable_rust.py
@@ -212,18 +212,16 @@ class RustModule(ExtensionModule):
f'rustmod-bindgen-{name}'.replace('/', '_'),
state.subdir,
state.subproject,
- {
- 'input': header,
- 'output': kwargs['output'],
- 'command': self._bindgen_bin.get_command() + [
- '@INPUT@', '--output',
- os.path.join(state.environment.build_dir, '@OUTPUT@')] +
- kwargs['args'] + ['--'] + kwargs['c_args'] + inc_strs +
- ['-MD', '-MQ', '@INPUT@', '-MF', '@DEPFILE@'],
- 'depfile': '@PLAINNAME@.d',
- 'depends': depends,
- 'depend_files': depend_files,
- },
+ self._bindgen_bin.get_command() + [
+ '@INPUT@', '--output',
+ os.path.join(state.environment.build_dir, '@OUTPUT@')] +
+ kwargs['args'] + ['--'] + kwargs['c_args'] + inc_strs +
+ ['-MD', '-MQ', '@INPUT@', '-MF', '@DEPFILE@'],
+ [header],
+ [kwargs['output']],
+ depfile='@PLAINNAME@.d',
+ extra_depends=depends,
+ depend_files=depend_files,
backend=state.backend,
)
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py
index 5f7301d..eb07ced 100644
--- a/mesonbuild/modules/windows.py
+++ b/mesonbuild/modules/windows.py
@@ -181,26 +181,25 @@ class WindowsModule(ExtensionModule):
command: T.List[T.Union[str, ExternalProgram]] = []
command.append(rescomp)
command.extend(res_args)
-
- res_kwargs: 'RcKwargs' = {
- 'output': output,
- 'input': [src],
- 'depfile': None,
- 'depend_files': wrc_depend_files,
- 'depends': wrc_depends,
- 'command': [],
- }
-
+ depfile: T.Optional[str] = None
# instruct binutils windres to generate a preprocessor depfile
if rescomp_type == ResourceCompilerType.windres:
- res_kwargs['depfile'] = f'{output}.d'
+ depfile = f'{output}.d'
command.extend(['--preprocessor-arg=-MD',
'--preprocessor-arg=-MQ@OUTPUT@',
'--preprocessor-arg=-MF@DEPFILE@'])
- res_kwargs['command'] = command
-
- res_targets.append(build.CustomTarget(name_formatted, state.subdir, state.subproject, res_kwargs))
+ res_targets.append(build.CustomTarget(
+ name_formatted,
+ state.subdir,
+ state.subproject,
+ command,
+ [src],
+ [output],
+ depfile=depfile,
+ depend_files=wrc_depend_files,
+ extra_depends=wrc_depends,
+ ))
return ModuleReturnValue(res_targets, [res_targets])