interpreter: report FeatureNew for kwargs to project()

We need to know the project minimum version before evaluating the rest
of the function. There's three basic approaches:
- try to set it inside KwargInfo
- just run a minimal version of func_project for this, then load
  everything after
- drop down to the AST and set it before anything else

In order to handle FeatureNew emitted by a FunctionNode evaluated
before project() due to being inlined, such as `version: run_command()`,
only option 3 suffices, the rest all happen way too late. Since we have
just added AST handling support for erroring out, we can do that to set
the version as well.
pull/11466/head
Eli Schwartz 2 years ago
parent 314382d6ff
commit a3f4f6c88f
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/interpreter/interpreter.py
  2. 2
      test cases/common/33 run program/meson.build
  3. 8
      test cases/common/33 run program/test.json

@ -528,6 +528,7 @@ class Interpreter(InterpreterBase, HoldableObject):
def handle_meson_version(self, pv: str, location: mparser.BaseNode) -> None:
if not mesonlib.version_compare(coredata.version, pv):
raise InterpreterException.from_node(f'Meson version is {coredata.version} but project requires {pv}', node=location)
mesonlib.project_meson_versions[self.subproject] = pv
def handle_meson_version_from_ast(self) -> None:
if not self.ast.lines:
@ -1170,7 +1171,6 @@ class Interpreter(InterpreterBase, HoldableObject):
# for things like deprecation testing.
if kwargs['meson_version']:
self.handle_meson_version(kwargs['meson_version'], node)
mesonlib.project_meson_versions[self.subproject] = kwargs['meson_version']
if os.path.exists(self.option_file):
oi = optinterpreter.OptionInterpreter(self.subproject)

@ -1,4 +1,4 @@
project('run command', version : run_command('get-version.py', check : true).stdout().strip())
project('run command', version : run_command('get-version.py', check : true).stdout().strip(), meson_version: '>=0.1.0')
if build_machine.system() == 'windows'
c = run_command('cmd', '/c', 'echo', 'hello', check: false)

@ -0,0 +1,8 @@
{
"stdout": [
{
"line": "test cases/common/33 run program/meson.build:1: WARNING: Project targets '>=0.1.0' but uses feature introduced in '0.47.0': check arg in run_command.",
"comment": "This triggers on line 1 -- the line with the project() function"
}
]
}
Loading…
Cancel
Save