diff options
author | Stas Sergeev <stsp@users.sourceforge.net> | 2024-05-07 21:46:55 +0300 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2024-05-09 12:27:35 -0700 |
commit | cfd57180eef9036c7167c5682b9f3055a540fccc (patch) | |
tree | 65f8ed46c385af05d6387aec6d16b1fcd311564f /mesonbuild | |
parent | f8aefe20703e3d64710fa675d511f9bef77dc32a (diff) | |
download | meson-cfd57180eef9036c7167c5682b9f3055a540fccc.zip meson-cfd57180eef9036c7167c5682b9f3055a540fccc.tar.gz meson-cfd57180eef9036c7167c5682b9f3055a540fccc.tar.bz2 |
implement @PLAINNAME0@ and @BASENAME0@
@PLAINNAME@ and @BASENAME@ cannot be used in custom_target()
with multiple inputs. For those, similar macros are needed
with an index.
Fixes #13164
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 10 | ||||
-rw-r--r-- | mesonbuild/utils/universal.py | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index f6b4cf4..08bd054 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1983,17 +1983,23 @@ class Interpreter(InterpreterBase, HoldableObject): def func_subdir_done(self, node: mparser.BaseNode, args: TYPE_var, kwargs: TYPE_kwargs) -> T.NoReturn: raise SubdirDoneRequest() - @staticmethod - def _validate_custom_target_outputs(has_multi_in: bool, outputs: T.Iterable[str], name: str) -> None: + def _validate_custom_target_outputs(self, has_multi_in: bool, outputs: T.Iterable[str], name: str) -> None: """Checks for additional invalid values in a custom_target output. This cannot be done with typed_kwargs because it requires the number of inputs. """ + inregex: T.List[str] = ['@PLAINNAME[0-9]+@', '@BASENAME[0-9]+@'] + from ..utils.universal import iter_regexin_iter for out in outputs: + match = iter_regexin_iter(inregex, [out]) if has_multi_in and ('@PLAINNAME@' in out or '@BASENAME@' in out): raise InvalidArguments(f'{name}: output cannot contain "@PLAINNAME@" or "@BASENAME@" ' 'when there is more than one input (we can\'t know which to use)') + elif match: + FeatureNew.single_use( + f'{match} in output', '1.5.0', + self.subproject) @typed_pos_args('custom_target', optargs=[str]) @typed_kwargs( diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py index ce9afd9..c831169 100644 --- a/mesonbuild/utils/universal.py +++ b/mesonbuild/utils/universal.py @@ -1744,6 +1744,8 @@ def get_filenames_templates_dict(inputs: T.List[str], outputs: T.List[str]) -> T If there is more than one input file, the following keys are also created: @INPUT0@, @INPUT1@, ... one for each input file + @PLAINNAME0@, @PLAINNAME1@, ... one for each input file + @BASENAME0@, @BASENAME1@, ... one for each input file If there is more than one output file, the following keys are also created: @@ -1757,6 +1759,9 @@ def get_filenames_templates_dict(inputs: T.List[str], outputs: T.List[str]) -> T for (ii, vv) in enumerate(inputs): # Write out @INPUT0@, @INPUT1@, ... values[f'@INPUT{ii}@'] = vv + plain = os.path.basename(vv) + values[f'@PLAINNAME{ii}@'] = plain + values[f'@BASENAME{ii}@'] = os.path.splitext(plain)[0] if len(inputs) == 1: # Just one value, substitute @PLAINNAME@ and @BASENAME@ values['@PLAINNAME@'] = plain = os.path.basename(inputs[0]) |