diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-01-25 21:35:26 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-01-27 22:11:48 -0500 |
commit | d9f55d774c6df52a8536114535d305841e96f105 (patch) | |
tree | ea9a5d32f35197fcb4ea5a405ceebd3c95de34e3 | |
parent | 1913a4246c6a0c0204e29e4957cafa937b251d01 (diff) | |
download | meson-d9f55d774c6df52a8536114535d305841e96f105.zip meson-d9f55d774c6df52a8536114535d305841e96f105.tar.gz meson-d9f55d774c6df52a8536114535d305841e96f105.tar.bz2 |
add location data to various Feature checks
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 32 | ||||
-rw-r--r-- | mesonbuild/interpreter/mesonmain.py | 6 | ||||
-rw-r--r-- | mesonbuild/interpreter/primitives/array.py | 3 | ||||
-rw-r--r-- | test cases/warning/6 list add/test.json | 2 |
4 files changed, 22 insertions, 21 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 19e0f96..2502deb 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -546,7 +546,7 @@ class Interpreter(InterpreterBase, HoldableObject): except KeyError: continue 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, } name = l + '_stdlib' @@ -608,11 +608,11 @@ class Interpreter(InterpreterBase, HoldableObject): variables = kwargs.get(argname, {}) if isinstance(variables, dict): 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: varlist = mesonlib.stringlistify(variables) 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() for v in varlist: try: @@ -668,7 +668,7 @@ external dependencies (including libraries) must go to "dependencies".''') kwargs: 'TYPE_kwargs') -> None: value, message = args 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 message is None: @@ -1024,7 +1024,7 @@ external dependencies (including libraries) must go to "dependencies".''') kwargs: 'TYPE_kwargs') -> build.ConfigurationData: initial_values = args[0] 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(): if not isinstance(v, (str, int ,bool)): raise InvalidArguments( @@ -1113,7 +1113,7 @@ external dependencies (including libraries) must go to "dependencies".''') version = kwargs['version'] 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) ifname = version.absolute_path(self.environment.source_dir, self.environment.build_dir) @@ -1210,7 +1210,7 @@ external dependencies (including libraries) must go to "dependencies".''') @noKwargs def func_message(self, node, args, kwargs): 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] self.message_impl(args_str) @@ -1286,7 +1286,7 @@ external dependencies (including libraries) must go to "dependencies".''') @noKwargs def func_warning(self, node, args, kwargs): 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] mlog.warning(*args_str, location=node) @@ -1294,7 +1294,7 @@ external dependencies (including libraries) must go to "dependencies".''') @noKwargs def func_error(self, node, args, kwargs): 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] 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 # When the first cython target using a particular language is used. 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') success = True @@ -1668,7 +1668,7 @@ external dependencies (including libraries) must go to "dependencies".''') if 'input' not in kwargs or 'output' not in kwargs: raise InterpreterException('Keyword arguments input and output must exist') 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) if not isinstance(fallback, str): 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], kwargs: 'kwargs.CustomTarget') -> build.CustomTarget: 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 kwargs = kwargs.copy() @@ -1883,7 +1883,7 @@ external dependencies (including libraries) must go to "dependencies".''') env = self.unpack_env_kwarg(kwargs) 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 @@ -2235,7 +2235,7 @@ external dependencies (including libraries) must go to "dependencies".''') if 'configuration' in kwargs: conf = kwargs['configuration'] 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(): if not isinstance(v, (str, int ,bool)): raise InvalidArguments( @@ -2270,7 +2270,7 @@ external dependencies (including libraries) must go to "dependencies".''') conf.used = True elif 'command' in kwargs: 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 # that the command is run from is 'unspecified', so it could change. # 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: init = args[0] 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) if msg: raise InvalidArguments(f'"environment": {msg}') diff --git a/mesonbuild/interpreter/mesonmain.py b/mesonbuild/interpreter/mesonmain.py index be1acc6..74b5978 100644 --- a/mesonbuild/interpreter/mesonmain.py +++ b/mesonbuild/interpreter/mesonmain.py @@ -133,7 +133,7 @@ class MesonMain(MesonInterpreterObject): FeatureNew.single_use( f'Calling "{name}" with File, CustomTarget, Index of CustomTarget, ' 'Executable, or ExternalProgram', - '0.55.0', self.interpreter.subproject) + '0.55.0', self.interpreter.subproject, location=self.current_node) return script_args @typed_pos_args( @@ -185,10 +185,10 @@ class MesonMain(MesonInterpreterObject): kwargs: 'TYPE_kwargs') -> None: if args[1]: 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 != '': 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 = self._find_source_script('add_dist_script', args[0], script_args) self.build.dist_scripts.append(script) diff --git a/mesonbuild/interpreter/primitives/array.py b/mesonbuild/interpreter/primitives/array.py index fb42d0d..e48e1c2 100644 --- a/mesonbuild/interpreter/primitives/array.py +++ b/mesonbuild/interpreter/primitives/array.py @@ -94,7 +94,8 @@ class ArrayHolder(ObjectHolder[T.List[TYPE_var]], IterableObject): def op_plus(self, other: TYPE_var) -> T.List[TYPE_var]: if not isinstance(other, list): 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] return self.held_object + other diff --git a/test cases/warning/6 list add/test.json b/test cases/warning/6 list add/test.json index 35c4567..9ff8fda 100644 --- a/test cases/warning/6 list add/test.json +++ b/test cases/warning/6 list add/test.json @@ -1,7 +1,7 @@ { "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." } ] } |