diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-07-18 15:03:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-18 15:03:54 +0300 |
commit | 0be74c78352bbe996599aed39468dadec45d1109 (patch) | |
tree | de1ac24c6dec3f496cb86b605d8d1af044cb33c1 /mesonbuild/mesonlib/universal.py | |
parent | 6614c7352645770d68bc1adb782fef4da323815a (diff) | |
parent | b5146c02effd53a8b71b2d10f95ecd2358f8241d (diff) | |
download | meson-0be74c78352bbe996599aed39468dadec45d1109.zip meson-0be74c78352bbe996599aed39468dadec45d1109.tar.gz meson-0be74c78352bbe996599aed39468dadec45d1109.tar.bz2 |
Merge pull request #8972 from bonzini/C-symlink
resolve symlinks passed to -C
Diffstat (limited to 'mesonbuild/mesonlib/universal.py')
-rw-r--r-- | mesonbuild/mesonlib/universal.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 17f604d..65d21ee 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -14,6 +14,7 @@ """A library of random helper functionality.""" from pathlib import Path +import argparse import enum import sys import stat @@ -70,6 +71,7 @@ __all__ = [ 'PerThreeMachine', 'PerThreeMachineDefaultable', 'ProgressBar', + 'RealPathAction', 'TemporaryDirectoryWinProof', 'Version', 'check_direntry_issues', @@ -1843,6 +1845,17 @@ else: ProgressBar = ProgressBarTqdm +class RealPathAction(argparse.Action): + def __init__(self, option_strings: T.List[str], dest: str, default: str = '.', **kwargs: T.Any): + default = os.path.abspath(os.path.realpath(default)) + super().__init__(option_strings, dest, nargs=None, default=default, **kwargs) + + def __call__(self, parser: argparse.ArgumentParser, namespace: argparse.Namespace, + values: T.Union[str, T.Sequence[T.Any], None], option_string: str = None) -> None: + assert isinstance(values, str) + setattr(namespace, self.dest, os.path.abspath(os.path.realpath(values))) + + def get_wine_shortpath(winecmd: T.List[str], wine_paths: T.Sequence[str]) -> str: """Get A short version of @wine_paths to avoid reaching WINEPATH number of char limit. |