Add more descriptive description to CustomTarget

Allow modules using CustomTarget to modify the command description used by ninja backend. This result in more precise logs when building a project.
pull/12091/head
Charles Brunet 1 year ago committed by Eli Schwartz
parent 88747b4f8d
commit 7cbe37ebd9
  1. 6
      docs/markdown/snippets/custom_target_description.md
  2. 4
      mesonbuild/backend/ninjabackend.py
  3. 2
      mesonbuild/build.py
  4. 1
      mesonbuild/modules/external_project.py
  5. 1
      mesonbuild/modules/fs.py
  6. 10
      mesonbuild/modules/gnome.py
  7. 3
      mesonbuild/modules/i18n.py
  8. 3
      mesonbuild/modules/qt.py
  9. 1
      mesonbuild/modules/rust.py
  10. 1
      mesonbuild/modules/windows.py

@ -0,0 +1,6 @@
## More meaningful description of many generative tasks
When a module uses a `CustomTarget` to process files, it now has the possibility
to customize the message displayed by ninja.
Many modules were updated to take advantage of this new feature.

@ -1147,7 +1147,7 @@ class NinjaBackend(backends.Backend):
deps.append(os.path.join(self.get_target_dir(i), output))
return deps
def generate_custom_target(self, target):
def generate_custom_target(self, target: build.CustomTarget):
self.custom_target_generator_inputs(target)
(srcs, ofilenames, cmd) = self.eval_custom_target_command(target)
deps = self.unwrap_dep_list(target)
@ -1185,7 +1185,7 @@ class NinjaBackend(backends.Backend):
elem.add_item('pool', 'console')
full_name = Path(target.subdir, target.name).as_posix()
elem.add_item('COMMAND', cmd)
elem.add_item('description', f'Generating {full_name} with a custom command{cmd_type}')
elem.add_item('description', target.description.format(full_name) + cmd_type)
self.add_build(elem)
self.processed_targets.add(target.get_id())

@ -2535,6 +2535,7 @@ class CustomTarget(Target, CommandBase):
install_tag: T.Optional[T.List[T.Optional[str]]] = None,
absolute_paths: bool = False,
backend: T.Optional['Backend'] = None,
description: str = 'Generating {} with a custom command',
):
# TODO expose keyword arg to make MachineChoice.HOST configurable
super().__init__(name, subdir, subproject, False, MachineChoice.HOST, environment,
@ -2559,6 +2560,7 @@ class CustomTarget(Target, CommandBase):
self.install_mode = install_mode
self.install_tag = _process_install_tag(install_tag, len(self.outputs))
self.name = name if name else self.outputs[0]
self.description = description
# Whether to use absolute paths for all files on the commandline
self.absolute_paths = absolute_paths

@ -247,6 +247,7 @@ class ExternalProject(NewExtensionModule):
depfile=f'{self.name}.d',
console=True,
extra_depends=extra_depends,
description='Generating external project {}',
)
idir = build.InstallDir(self.subdir.as_posix(),

@ -308,6 +308,7 @@ class FSModule(ExtensionModule):
install_mode=kwargs['install_mode'],
install_tag=[kwargs['install_tag']],
backend=state.backend,
description='Copying file {}',
)
return ModuleReturnValue(ct, [ct])

@ -1242,6 +1242,7 @@ class GnomeModule(ExtensionModule):
['gschemas.compiled'],
build_by_default=kwargs['build_by_default'],
depend_files=kwargs['depend_files'],
description='Compiling gschemas {}',
)
self._devenv_prepend('GSETTINGS_SCHEMA_DIR', os.path.join(state.environment.get_build_dir(), state.subdir))
return ModuleReturnValue(target_g, [target_g])
@ -1355,6 +1356,7 @@ class GnomeModule(ExtensionModule):
[po_file],
[gmo_file],
install_tag=['doc'],
description='Generating yelp doc {}',
)
targets.append(gmotarget)
@ -1370,6 +1372,7 @@ class GnomeModule(ExtensionModule):
install=True,
install_dir=[l_install_dir],
install_tag=['doc'],
description='Generating yelp doc {}',
)
targets.append(mergetarget)
@ -1513,6 +1516,7 @@ class GnomeModule(ExtensionModule):
[f'{modulename}-decl.txt'],
build_always_stale=True,
extra_depends=new_depends,
description='Generating gtkdoc {}',
)
alias_target = build.AliasTarget(targetname, [custom_target], state.subdir, state.subproject, state.environment)
if kwargs['check']:
@ -1656,6 +1660,7 @@ class GnomeModule(ExtensionModule):
xml_files,
[output],
build_by_default=build_by_default,
description='Generating gdbus source {}',
)
targets.append(cfile_custom_target)
@ -1680,6 +1685,7 @@ class GnomeModule(ExtensionModule):
install=install_header,
install_dir=[install_dir],
install_tag=['devel'],
description='Generating gdbus header {}',
)
targets.append(hfile_custom_target)
@ -1708,6 +1714,7 @@ class GnomeModule(ExtensionModule):
outputs,
build_by_default=build_by_default,
extra_depends=depends,
description='Generating gdbus docbook {}',
)
targets.append(docbook_custom_target)
@ -1930,6 +1937,7 @@ class GnomeModule(ExtensionModule):
extra_depends=depends,
# https://github.com/mesonbuild/meson/issues/973
absolute_paths=True,
description='Generating GObject enum file {}',
)
@typed_pos_args('gnome.genmarshal', str)
@ -1996,6 +2004,7 @@ class GnomeModule(ExtensionModule):
install_tag=['devel'],
capture=capture,
depend_files=kwargs['depend_files'],
description='Generating glib marshaller header {}',
)
c_cmd = cmd + ['--body', '@INPUT@']
@ -2015,6 +2024,7 @@ class GnomeModule(ExtensionModule):
capture=capture,
depend_files=kwargs['depend_files'],
extra_depends=extra_deps,
description='Generating glib marshaller source {}',
)
rv = [body, header]

@ -212,6 +212,7 @@ class I18nModule(ExtensionModule):
install=kwargs['install'],
install_dir=[kwargs['install_dir']] if kwargs['install_dir'] is not None else None,
install_tag=install_tag,
description='Merging translations for {}',
)
return ModuleReturnValue(ct, [ct])
@ -304,6 +305,7 @@ class I18nModule(ExtensionModule):
# 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'],
description='Building translation {}',
)
targets.append(gmotarget)
gmotargets.append(gmotarget)
@ -390,6 +392,7 @@ class I18nModule(ExtensionModule):
install=kwargs['install'],
install_dir=[kwargs['install_dir']] if kwargs['install_dir'] is not None else None,
install_tag=install_tag,
description='Merging translations for {}',
)
return ModuleReturnValue(ct, [ct])

@ -348,6 +348,7 @@ class QtBaseModule(ExtensionModule):
[f'{name}.cpp'],
depend_files=qrc_deps,
depfile=f'{name}.d',
description='Compiling Qt resources {}',
)
targets.append(res_target)
else:
@ -368,6 +369,7 @@ class QtBaseModule(ExtensionModule):
[f'{name}.cpp'],
depend_files=qrc_deps,
depfile=f'{name}.d',
description='Compiling Qt resources {}',
)
targets.append(res_target)
@ -600,6 +602,7 @@ class QtBaseModule(ExtensionModule):
install_dir=[kwargs['install_dir']],
install_tag=['i18n'],
build_by_default=kwargs['build_by_default'],
description='Compiling Qt translations {}',
)
translations.append(lrelease_target)
if qresource:

@ -263,6 +263,7 @@ class RustModule(ExtensionModule):
extra_depends=depends,
depend_files=depend_files,
backend=state.backend,
description='Generating bindings for Rust {}',
)
return ModuleReturnValue([target], [target])

@ -206,6 +206,7 @@ class WindowsModule(ExtensionModule):
depfile=depfile,
depend_files=wrc_depend_files,
extra_depends=wrc_depends,
description='Compiling Windows resource {}',
))
return ModuleReturnValue(res_targets, [res_targets])

Loading…
Cancel
Save