aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/fs.py
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-11-08 03:43:49 -0500
committerMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-11-17 00:17:02 -0500
commit052d918908b4e571a42cd3fc539933f9db139e0c (patch)
tree9ca08b87ffee43e27b19845c74996cf1abe5574a /mesonbuild/modules/fs.py
parentdc8e8f06441030fc1d7f16a8444964ea5a125321 (diff)
downloadmeson-052d918908b4e571a42cd3fc539933f9db139e0c.zip
meson-052d918908b4e571a42cd3fc539933f9db139e0c.tar.gz
meson-052d918908b4e571a42cd3fc539933f9db139e0c.tar.bz2
add fs.with_suffix
Diffstat (limited to 'mesonbuild/modules/fs.py')
-rw-r--r--mesonbuild/modules/fs.py12
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)