aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-07-07 17:37:56 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-07 18:00:37 +0200
commitb44a51d0fdd48089d2cc3864d34a3ccad77ec52d (patch)
treed6009b376b277b7c65b362b76beb1d12681b4510 /mesonbuild/mesonlib
parent81d9acab8744d5fbd067cfad0723975b694101f0 (diff)
downloadmeson-b44a51d0fdd48089d2cc3864d34a3ccad77ec52d.zip
meson-b44a51d0fdd48089d2cc3864d34a3ccad77ec52d.tar.gz
meson-b44a51d0fdd48089d2cc3864d34a3ccad77ec52d.tar.bz2
resolve symlinks passed to -C
"meson setup" is resolving symlinks for the build directory in validate_core_dirs. For consistency with it, do the same when the build directory is passed via -C to devenv, dist, init, install and test. This ensures for example that the path to test dependencies is computed correctly in "meson test". Fixes: #8765
Diffstat (limited to 'mesonbuild/mesonlib')
-rw-r--r--mesonbuild/mesonlib/universal.py13
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.