add location data to various Feature checks

pull/9877/head
Eli Schwartz 3 years ago
parent 1913a4246c
commit d9f55d774c
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 32
      mesonbuild/interpreter/interpreter.py
  2. 6
      mesonbuild/interpreter/mesonmain.py
  3. 3
      mesonbuild/interpreter/primitives/array.py
  4. 2
      test cases/warning/6 list add/test.json

@ -546,7 +546,7 @@ class Interpreter(InterpreterBase, HoldableObject):
except KeyError: except KeyError:
continue continue
if len(di) == 1: if len(di) == 1:
FeatureNew.single_use('stdlib without variable name', '0.56.0', self.subproject) FeatureNew.single_use('stdlib without variable name', '0.56.0', self.subproject, location=self.current_node)
kwargs = {'native': for_machine is MachineChoice.BUILD, kwargs = {'native': for_machine is MachineChoice.BUILD,
} }
name = l + '_stdlib' name = l + '_stdlib'
@ -608,11 +608,11 @@ class Interpreter(InterpreterBase, HoldableObject):
variables = kwargs.get(argname, {}) variables = kwargs.get(argname, {})
if isinstance(variables, dict): if isinstance(variables, dict):
if dict_new and variables: if dict_new and variables:
FeatureNew.single_use(f'{argname} as dictionary', '0.56.0', self.subproject) FeatureNew.single_use(f'{argname} as dictionary', '0.56.0', self.subproject, location=self.current_node)
else: else:
varlist = mesonlib.stringlistify(variables) varlist = mesonlib.stringlistify(variables)
if list_new: if list_new:
FeatureNew.single_use(f'{argname} as list of strings', '0.56.0', self.subproject) FeatureNew.single_use(f'{argname} as list of strings', '0.56.0', self.subproject, location=self.current_node)
variables = collections.OrderedDict() variables = collections.OrderedDict()
for v in varlist: for v in varlist:
try: try:
@ -668,7 +668,7 @@ external dependencies (including libraries) must go to "dependencies".''')
kwargs: 'TYPE_kwargs') -> None: kwargs: 'TYPE_kwargs') -> None:
value, message = args value, message = args
if message is None: if message is None:
FeatureNew.single_use('assert function without message argument', '0.53.0', self.subproject) FeatureNew.single_use('assert function without message argument', '0.53.0', self.subproject, location=node)
if not value: if not value:
if message is None: if message is None:
@ -1024,7 +1024,7 @@ external dependencies (including libraries) must go to "dependencies".''')
kwargs: 'TYPE_kwargs') -> build.ConfigurationData: kwargs: 'TYPE_kwargs') -> build.ConfigurationData:
initial_values = args[0] initial_values = args[0]
if initial_values is not None: if initial_values is not None:
FeatureNew.single_use('configuration_data dictionary', '0.49.0', self.subproject) FeatureNew.single_use('configuration_data dictionary', '0.49.0', self.subproject, location=node)
for k, v in initial_values.items(): for k, v in initial_values.items():
if not isinstance(v, (str, int ,bool)): if not isinstance(v, (str, int ,bool)):
raise InvalidArguments( raise InvalidArguments(
@ -1113,7 +1113,7 @@ external dependencies (including libraries) must go to "dependencies".''')
version = kwargs['version'] version = kwargs['version']
if isinstance(version, mesonlib.File): if isinstance(version, mesonlib.File):
FeatureNew.single_use('version from file', '0.57.0', self.subproject) FeatureNew.single_use('version from file', '0.57.0', self.subproject, location=node)
self.add_build_def_file(version) self.add_build_def_file(version)
ifname = version.absolute_path(self.environment.source_dir, ifname = version.absolute_path(self.environment.source_dir,
self.environment.build_dir) self.environment.build_dir)
@ -1210,7 +1210,7 @@ external dependencies (including libraries) must go to "dependencies".''')
@noKwargs @noKwargs
def func_message(self, node, args, kwargs): def func_message(self, node, args, kwargs):
if len(args) > 1: if len(args) > 1:
FeatureNew.single_use('message with more than one argument', '0.54.0', self.subproject) FeatureNew.single_use('message with more than one argument', '0.54.0', self.subproject, location=node)
args_str = [stringifyUserArguments(i) for i in args] args_str = [stringifyUserArguments(i) for i in args]
self.message_impl(args_str) self.message_impl(args_str)
@ -1286,7 +1286,7 @@ external dependencies (including libraries) must go to "dependencies".''')
@noKwargs @noKwargs
def func_warning(self, node, args, kwargs): def func_warning(self, node, args, kwargs):
if len(args) > 1: if len(args) > 1:
FeatureNew.single_use('warning with more than one argument', '0.54.0', self.subproject) FeatureNew.single_use('warning with more than one argument', '0.54.0', self.subproject, location=node)
args_str = [stringifyUserArguments(i) for i in args] args_str = [stringifyUserArguments(i) for i in args]
mlog.warning(*args_str, location=node) mlog.warning(*args_str, location=node)
@ -1294,7 +1294,7 @@ external dependencies (including libraries) must go to "dependencies".''')
@noKwargs @noKwargs
def func_error(self, node, args, kwargs): def func_error(self, node, args, kwargs):
if len(args) > 1: if len(args) > 1:
FeatureNew.single_use('error with more than one argument', '0.58.0', self.subproject) FeatureNew.single_use('error with more than one argument', '0.58.0', self.subproject, location=node)
args_str = [stringifyUserArguments(i) for i in args] args_str = [stringifyUserArguments(i) for i in args]
raise InterpreterException('Problem encountered: ' + ' '.join(args_str)) raise InterpreterException('Problem encountered: ' + ' '.join(args_str))
@ -1331,7 +1331,7 @@ external dependencies (including libraries) must go to "dependencies".''')
# compilers we don't add anything for cython here, and instead do it # compilers we don't add anything for cython here, and instead do it
# When the first cython target using a particular language is used. # When the first cython target using a particular language is used.
if 'vala' in langs and 'c' not in langs: if 'vala' in langs and 'c' not in langs:
FeatureNew.single_use('Adding Vala language without C', '0.59.0', self.subproject) FeatureNew.single_use('Adding Vala language without C', '0.59.0', self.subproject, location=self.current_node)
args.append('c') args.append('c')
success = True success = True
@ -1668,7 +1668,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if 'input' not in kwargs or 'output' not in kwargs: if 'input' not in kwargs or 'output' not in kwargs:
raise InterpreterException('Keyword arguments input and output must exist') raise InterpreterException('Keyword arguments input and output must exist')
if 'fallback' not in kwargs: if 'fallback' not in kwargs:
FeatureNew.single_use('Optional fallback in vcs_tag', '0.41.0', self.subproject) FeatureNew.single_use('Optional fallback in vcs_tag', '0.41.0', self.subproject, location=node)
fallback = kwargs.pop('fallback', self.project_version) fallback = kwargs.pop('fallback', self.project_version)
if not isinstance(fallback, str): if not isinstance(fallback, str):
raise InterpreterException('Keyword argument fallback must be a string.') raise InterpreterException('Keyword argument fallback must be a string.')
@ -1734,7 +1734,7 @@ external dependencies (including libraries) must go to "dependencies".''')
def func_custom_target(self, node: mparser.FunctionNode, args: T.Tuple[str], def func_custom_target(self, node: mparser.FunctionNode, args: T.Tuple[str],
kwargs: 'kwargs.CustomTarget') -> build.CustomTarget: kwargs: 'kwargs.CustomTarget') -> build.CustomTarget:
if kwargs['depfile'] and ('@BASENAME@' in kwargs['depfile'] or '@PLAINNAME@' in kwargs['depfile']): if kwargs['depfile'] and ('@BASENAME@' in kwargs['depfile'] or '@PLAINNAME@' in kwargs['depfile']):
FeatureNew.single_use('substitutions in custom_target depfile', '0.47.0', self.subproject) FeatureNew.single_use('substitutions in custom_target depfile', '0.47.0', self.subproject, location=node)
# Don't mutate the kwargs # Don't mutate the kwargs
kwargs = kwargs.copy() kwargs = kwargs.copy()
@ -1883,7 +1883,7 @@ external dependencies (including libraries) must go to "dependencies".''')
env = self.unpack_env_kwarg(kwargs) env = self.unpack_env_kwarg(kwargs)
if kwargs['timeout'] <= 0: if kwargs['timeout'] <= 0:
FeatureNew.single_use('test() timeout <= 0', '0.57.0', self.subproject) FeatureNew.single_use('test() timeout <= 0', '0.57.0', self.subproject, location=node)
prj = self.subproject if self.is_subproject() else self.build.project_name prj = self.subproject if self.is_subproject() else self.build.project_name
@ -2235,7 +2235,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if 'configuration' in kwargs: if 'configuration' in kwargs:
conf = kwargs['configuration'] conf = kwargs['configuration']
if isinstance(conf, dict): if isinstance(conf, dict):
FeatureNew.single_use('configure_file.configuration dictionary', '0.49.0', self.subproject) FeatureNew.single_use('configure_file.configuration dictionary', '0.49.0', self.subproject, location=node)
for k, v in conf.items(): for k, v in conf.items():
if not isinstance(v, (str, int ,bool)): if not isinstance(v, (str, int ,bool)):
raise InvalidArguments( raise InvalidArguments(
@ -2270,7 +2270,7 @@ external dependencies (including libraries) must go to "dependencies".''')
conf.used = True conf.used = True
elif 'command' in kwargs: elif 'command' in kwargs:
if len(inputs) > 1: if len(inputs) > 1:
FeatureNew.single_use('multiple inputs in configure_file()', '0.52.0', self.subproject) FeatureNew.single_use('multiple inputs in configure_file()', '0.52.0', self.subproject, location=node)
# We use absolute paths for input and output here because the cwd # We use absolute paths for input and output here because the cwd
# that the command is run from is 'unspecified', so it could change. # that the command is run from is 'unspecified', so it could change.
# Currently it's builddir/subdir for in_builddir else srcdir/subdir. # Currently it's builddir/subdir for in_builddir else srcdir/subdir.
@ -2545,7 +2545,7 @@ external dependencies (including libraries) must go to "dependencies".''')
kwargs: 'TYPE_kwargs') -> build.EnvironmentVariables: kwargs: 'TYPE_kwargs') -> build.EnvironmentVariables:
init = args[0] init = args[0]
if init is not None: if init is not None:
FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject) FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject, location=node)
msg = ENV_KW.validator(init) msg = ENV_KW.validator(init)
if msg: if msg:
raise InvalidArguments(f'"environment": {msg}') raise InvalidArguments(f'"environment": {msg}')

@ -133,7 +133,7 @@ class MesonMain(MesonInterpreterObject):
FeatureNew.single_use( FeatureNew.single_use(
f'Calling "{name}" with File, CustomTarget, Index of CustomTarget, ' f'Calling "{name}" with File, CustomTarget, Index of CustomTarget, '
'Executable, or ExternalProgram', 'Executable, or ExternalProgram',
'0.55.0', self.interpreter.subproject) '0.55.0', self.interpreter.subproject, location=self.current_node)
return script_args return script_args
@typed_pos_args( @typed_pos_args(
@ -185,10 +185,10 @@ class MesonMain(MesonInterpreterObject):
kwargs: 'TYPE_kwargs') -> None: kwargs: 'TYPE_kwargs') -> None:
if args[1]: if args[1]:
FeatureNew.single_use('Calling "add_dist_script" with multiple arguments', FeatureNew.single_use('Calling "add_dist_script" with multiple arguments',
'0.49.0', self.interpreter.subproject) '0.49.0', self.interpreter.subproject, location=self.current_node)
if self.interpreter.subproject != '': if self.interpreter.subproject != '':
FeatureNew.single_use('Calling "add_dist_script" in a subproject', FeatureNew.single_use('Calling "add_dist_script" in a subproject',
'0.58.0', self.interpreter.subproject) '0.58.0', self.interpreter.subproject, location=self.current_node)
script_args = self._process_script_args('add_dist_script', args[1]) script_args = self._process_script_args('add_dist_script', args[1])
script = self._find_source_script('add_dist_script', args[0], script_args) script = self._find_source_script('add_dist_script', args[0], script_args)
self.build.dist_scripts.append(script) self.build.dist_scripts.append(script)

@ -94,7 +94,8 @@ class ArrayHolder(ObjectHolder[T.List[TYPE_var]], IterableObject):
def op_plus(self, other: TYPE_var) -> T.List[TYPE_var]: def op_plus(self, other: TYPE_var) -> T.List[TYPE_var]:
if not isinstance(other, list): if not isinstance(other, list):
if not isinstance(self.current_node, PlusAssignmentNode): if not isinstance(self.current_node, PlusAssignmentNode):
FeatureNew.single_use('list.<plus>', '0.60.0', self.subproject, 'The right hand operand was not a list.') FeatureNew.single_use('list.<plus>', '0.60.0', self.subproject, 'The right hand operand was not a list.',
location=self.current_node)
other = [other] other = [other]
return self.held_object + other return self.held_object + other

@ -1,7 +1,7 @@
{ {
"stdout": [ "stdout": [
{ {
"line": "WARNING: Project targeting '>=0.59.0' but tried to use feature introduced in '0.60.0': list.<plus>. The right hand operand was not a list." "line": "test cases/warning/6 list add/meson.build:4: WARNING: Project targeting '>=0.59.0' but tried to use feature introduced in '0.60.0': list.<plus>. The right hand operand was not a list."
} }
] ]
} }

Loading…
Cancel
Save