build: actually check for targets with no sources

Do to a bug in which a method, rather than an attribute, was checked
we would never detect that a target had no sources, even though we meant
to. As a result we would never actually error out when a target has no
sources. When fixing the check, I've changed the error to a warning
so that existing projects will continue to build without errors, only
warnings.
pull/10702/head
Dylan Baker 2 years ago
parent fd9ee31d14
commit 5ca5e0c900
  1. 6
      mesonbuild/build.py

@ -783,8 +783,10 @@ class BuildTarget(Target):
self.process_objectlist(objects)
self.process_kwargs(kwargs)
self.check_unknown_kwargs(kwargs)
if not any([self.sources, self.generated, self.objects, self.link_whole, self.structured_sources]):
raise InvalidArguments(f'Build target {name} has no sources.')
if not any([self.sources, self.generated, self.objects, self.link_whole_targets, self.structured_sources]):
mlog.warning(f'Build target {name} has no sources. '
'This was never supposed to be allowed but did because of a bug, '
'support will be removed in a future release of Meson')
self.validate_install()
self.check_module_linking()

Loading…
Cancel
Save