diff options
Diffstat (limited to 'mesonbuild/modules/fs.py')
-rw-r--r-- | mesonbuild/modules/fs.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py index a9881c4..1687d0d 100644 --- a/mesonbuild/modules/fs.py +++ b/mesonbuild/modules/fs.py @@ -13,7 +13,7 @@ # limitations under the License. import typing -from pathlib import Path +from pathlib import Path, PurePath from . import ExtensionModule from . import ModuleReturnValue @@ -55,5 +55,15 @@ class FSModule(ExtensionModule): def is_dir(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue: return self._check('is_dir', state, args) + @stringArgs + @noKwargs + def with_suffix(self, state: 'ModuleState', args: typing.Sequence[str], kwargs: dict) -> ModuleReturnValue: + if len(args) != 2: + MesonException('method takes exactly two arguments.') + original = PurePath(state.source_root) / state.subdir / args[0] + new = original.with_suffix(args[1]) + return ModuleReturnValue(str(new), []) + + def initialize(*args, **kwargs) -> FSModule: return FSModule(*args, **kwargs) |