Skip to content

Commit a75a837

Browse files
eli-schwartznirbheek
authored andcommitted
add location data to various Feature checks
1 parent 9de6a50 commit a75a837

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

mesonbuild/interpreter/interpreter.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def check_stdlibs(self):
546546
except KeyError:
547547
continue
548548
if len(di) == 1:
549-
FeatureNew.single_use('stdlib without variable name', '0.56.0', self.subproject)
549+
FeatureNew.single_use('stdlib without variable name', '0.56.0', self.subproject, location=self.current_node)
550550
kwargs = {'native': for_machine is MachineChoice.BUILD,
551551
}
552552
name = l + '_stdlib'
@@ -608,11 +608,11 @@ def extract_variables(self, kwargs, argname='variables', list_new=False, dict_ne
608608
variables = kwargs.get(argname, {})
609609
if isinstance(variables, dict):
610610
if dict_new and variables:
611-
FeatureNew.single_use(f'{argname} as dictionary', '0.56.0', self.subproject)
611+
FeatureNew.single_use(f'{argname} as dictionary', '0.56.0', self.subproject, location=self.current_node)
612612
else:
613613
varlist = mesonlib.stringlistify(variables)
614614
if list_new:
615-
FeatureNew.single_use(f'{argname} as list of strings', '0.56.0', self.subproject)
615+
FeatureNew.single_use(f'{argname} as list of strings', '0.56.0', self.subproject, location=self.current_node)
616616
variables = collections.OrderedDict()
617617
for v in varlist:
618618
try:
@@ -668,7 +668,7 @@ def func_assert(self, node: mparser.FunctionNode, args: T.Tuple[bool, T.Optional
668668
kwargs: 'TYPE_kwargs') -> None:
669669
value, message = args
670670
if message is None:
671-
FeatureNew.single_use('assert function without message argument', '0.53.0', self.subproject)
671+
FeatureNew.single_use('assert function without message argument', '0.53.0', self.subproject, location=node)
672672

673673
if not value:
674674
if message is None:
@@ -1018,7 +1018,7 @@ def func_get_option(self, nodes: mparser.BaseNode, args: T.Tuple[str],
10181018
def func_configuration_data(self, node: mparser.BaseNode, args: T.Optional[dict], kwargs: 'TYPE_kwargs') -> ConfigurationDataObject:
10191019
initial_values = args[0]
10201020
if initial_values is not None:
1021-
FeatureNew.single_use('configuration_data dictionary', '0.49.0', self.subproject)
1021+
FeatureNew.single_use('configuration_data dictionary', '0.49.0', self.subproject, location=node)
10221022
else:
10231023
initial_values = {}
10241024
return ConfigurationDataObject(self.subproject, initial_values)
@@ -1105,7 +1105,7 @@ def func_project(self, node: mparser.FunctionNode, args: T.Tuple[str, T.List[str
11051105

11061106
version = kwargs['version']
11071107
if isinstance(version, mesonlib.File):
1108-
FeatureNew.single_use('version from file', '0.57.0', self.subproject)
1108+
FeatureNew.single_use('version from file', '0.57.0', self.subproject, location=node)
11091109
self.add_build_def_file(version)
11101110
ifname = version.absolute_path(self.environment.source_dir,
11111111
self.environment.build_dir)
@@ -1202,7 +1202,7 @@ def func_add_languages(self, node: mparser.FunctionNode, args: T.Tuple[T.List[st
12021202
@noKwargs
12031203
def func_message(self, node, args, kwargs):
12041204
if len(args) > 1:
1205-
FeatureNew.single_use('message with more than one argument', '0.54.0', self.subproject)
1205+
FeatureNew.single_use('message with more than one argument', '0.54.0', self.subproject, location=node)
12061206
args_str = [stringifyUserArguments(i) for i in args]
12071207
self.message_impl(args_str)
12081208

@@ -1278,15 +1278,15 @@ def _print_summary(self) -> None:
12781278
@noKwargs
12791279
def func_warning(self, node, args, kwargs):
12801280
if len(args) > 1:
1281-
FeatureNew.single_use('warning with more than one argument', '0.54.0', self.subproject)
1281+
FeatureNew.single_use('warning with more than one argument', '0.54.0', self.subproject, location=node)
12821282
args_str = [stringifyUserArguments(i) for i in args]
12831283
mlog.warning(*args_str, location=node)
12841284

12851285
@noArgsFlattening
12861286
@noKwargs
12871287
def func_error(self, node, args, kwargs):
12881288
if len(args) > 1:
1289-
FeatureNew.single_use('error with more than one argument', '0.58.0', self.subproject)
1289+
FeatureNew.single_use('error with more than one argument', '0.58.0', self.subproject, location=node)
12901290
args_str = [stringifyUserArguments(i) for i in args]
12911291
raise InterpreterException('Problem encountered: ' + ' '.join(args_str))
12921292

@@ -1323,7 +1323,7 @@ def add_languages_for(self, args: T.List[str], required: bool, for_machine: Mach
13231323
# compilers we don't add anything for cython here, and instead do it
13241324
# When the first cython target using a particular language is used.
13251325
if 'vala' in langs and 'c' not in langs:
1326-
FeatureNew.single_use('Adding Vala language without C', '0.59.0', self.subproject)
1326+
FeatureNew.single_use('Adding Vala language without C', '0.59.0', self.subproject, location=self.current_node)
13271327
args.append('c')
13281328

13291329
success = True
@@ -1660,7 +1660,7 @@ def func_vcs_tag(self, node, args, kwargs):
16601660
if 'input' not in kwargs or 'output' not in kwargs:
16611661
raise InterpreterException('Keyword arguments input and output must exist')
16621662
if 'fallback' not in kwargs:
1663-
FeatureNew.single_use('Optional fallback in vcs_tag', '0.41.0', self.subproject)
1663+
FeatureNew.single_use('Optional fallback in vcs_tag', '0.41.0', self.subproject, location=node)
16641664
fallback = kwargs.pop('fallback', self.project_version)
16651665
if not isinstance(fallback, str):
16661666
raise InterpreterException('Keyword argument fallback must be a string.')
@@ -1726,7 +1726,7 @@ def func_subdir_done(self, node, args, kwargs):
17261726
def func_custom_target(self, node: mparser.FunctionNode, args: T.Tuple[str],
17271727
kwargs: 'kwargs.CustomTarget') -> build.CustomTarget:
17281728
if kwargs['depfile'] and ('@BASENAME@' in kwargs['depfile'] or '@PLAINNAME@' in kwargs['depfile']):
1729-
FeatureNew.single_use('substitutions in custom_target depfile', '0.47.0', self.subproject)
1729+
FeatureNew.single_use('substitutions in custom_target depfile', '0.47.0', self.subproject, location=node)
17301730

17311731
# Don't mutate the kwargs
17321732
kwargs = kwargs.copy()
@@ -1875,7 +1875,7 @@ def make_test(self, node: mparser.BaseNode,
18751875
env = self.unpack_env_kwarg(kwargs)
18761876

18771877
if kwargs['timeout'] <= 0:
1878-
FeatureNew.single_use('test() timeout <= 0', '0.57.0', self.subproject)
1878+
FeatureNew.single_use('test() timeout <= 0', '0.57.0', self.subproject, location=node)
18791879

18801880
prj = self.subproject if self.is_subproject() else self.build.project_name
18811881

@@ -2227,7 +2227,7 @@ def func_configure_file(self, node, args, kwargs):
22272227
if 'configuration' in kwargs:
22282228
conf = kwargs['configuration']
22292229
if isinstance(conf, dict):
2230-
FeatureNew.single_use('configure_file.configuration dictionary', '0.49.0', self.subproject)
2230+
FeatureNew.single_use('configure_file.configuration dictionary', '0.49.0', self.subproject, location=node)
22312231
conf = ConfigurationDataObject(self.subproject, conf)
22322232
elif not isinstance(conf, ConfigurationDataObject):
22332233
raise InterpreterException('Argument "configuration" is not of type configuration_data')
@@ -2258,7 +2258,7 @@ def func_configure_file(self, node, args, kwargs):
22582258
conf.mark_used()
22592259
elif 'command' in kwargs:
22602260
if len(inputs) > 1:
2261-
FeatureNew.single_use('multiple inputs in configure_file()', '0.52.0', self.subproject)
2261+
FeatureNew.single_use('multiple inputs in configure_file()', '0.52.0', self.subproject, location=node)
22622262
# We use absolute paths for input and output here because the cwd
22632263
# that the command is run from is 'unspecified', so it could change.
22642264
# Currently it's builddir/subdir for in_builddir else srcdir/subdir.
@@ -2533,7 +2533,7 @@ def func_environment(self, node: mparser.FunctionNode, args: T.Tuple[T.Union[Non
25332533
kwargs: 'TYPE_kwargs') -> build.EnvironmentVariables:
25342534
init = args[0]
25352535
if init is not None:
2536-
FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject)
2536+
FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject, location=node)
25372537
msg = ENV_KW.validator(init)
25382538
if msg:
25392539
raise InvalidArguments(f'"environment": {msg}')

mesonbuild/interpreter/mesonmain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _process_script_args(
133133
FeatureNew.single_use(
134134
f'Calling "{name}" with File, CustomTarget, Index of CustomTarget, '
135135
'Executable, or ExternalProgram',
136-
'0.55.0', self.interpreter.subproject)
136+
'0.55.0', self.interpreter.subproject, location=self.current_node)
137137
return script_args
138138

139139
@typed_pos_args(
@@ -185,10 +185,10 @@ def add_dist_script_method(
185185
kwargs: 'TYPE_kwargs') -> None:
186186
if args[1]:
187187
FeatureNew.single_use('Calling "add_dist_script" with multiple arguments',
188-
'0.49.0', self.interpreter.subproject)
188+
'0.49.0', self.interpreter.subproject, location=self.current_node)
189189
if self.interpreter.subproject != '':
190190
FeatureNew.single_use('Calling "add_dist_script" in a subproject',
191-
'0.58.0', self.interpreter.subproject)
191+
'0.58.0', self.interpreter.subproject, location=self.current_node)
192192
script_args = self._process_script_args('add_dist_script', args[1])
193193
script = self._find_source_script('add_dist_script', args[0], script_args)
194194
self.build.dist_scripts.append(script)

mesonbuild/interpreter/primitives/array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def get_method(self, args: T.Tuple[int, T.Optional[TYPE_var]], kwargs: TYPE_kwar
9494
def op_plus(self, other: TYPE_var) -> T.List[TYPE_var]:
9595
if not isinstance(other, list):
9696
if not isinstance(self.current_node, PlusAssignmentNode):
97-
FeatureNew.single_use('list.<plus>', '0.60.0', self.subproject, 'The right hand operand was not a list.')
97+
FeatureNew.single_use('list.<plus>', '0.60.0', self.subproject, 'The right hand operand was not a list.',
98+
location=self.current_node)
9899
other = [other]
99100
return self.held_object + other
100101

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"stdout": [
33
{
4-
"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."
4+
"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."
55
}
66
]
77
}

0 commit comments

Comments
 (0)