Only emit warning about "native:" on projects with minimum required version

'native:' keyword was only added in 0.54. For projects declaring
meson_version >= 0.54, warn, because those projects can and should set
the keyword. For older projects declaring support for older versions,
don't warn and use the default implicitly.

Fixes https://github.com/mesonbuild/meson/issues/6849.
pull/7494/head
Zbigniew Jędrzejewski-Szmek 5 years ago
parent 18aff92d7a
commit 3dea817a59
  1. 7
      mesonbuild/interpreter.py
  2. 3
      test cases/warning/2 languages missing native/meson.build
  3. 2
      test cases/warning/2 languages missing native/test.json

@ -3122,8 +3122,11 @@ external dependencies (including libraries) must go to "dependencies".''')
return self.add_languages(args, required, self.machine_from_native_kwarg(kwargs))
else:
# absent 'native' means 'both' for backwards compatibility
mlog.warning('add_languages is missing native:, assuming languages are wanted for both host and build.',
location=self.current_node)
tv = FeatureNew.get_target_version(self.subproject)
if FeatureNew.check_version(tv, '0.54.0'):
mlog.warning('add_languages is missing native:, assuming languages are wanted for both host and build.',
location=self.current_node)
success = self.add_languages(args, False, MachineChoice.BUILD)
success &= self.add_languages(args, required, MachineChoice.HOST)
return success

@ -1,2 +1,3 @@
project('languages missing native')
project('languages missing native',
meson_version : '>= 0.54')
add_languages('c')

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/warning/2 languages missing native/meson.build:2: WARNING: add_languages is missing native:, assuming languages are wanted for both host and build."
"line": "test cases/warning/2 languages missing native/meson.build:3: WARNING: add_languages is missing native:, assuming languages are wanted for both host and build."
}
]
}

Loading…
Cancel
Save