Merge pull request #8972 from bonzini/C-symlink

resolve symlinks passed to -C
pull/9008/head
Jussi Pakkanen 3 years ago committed by GitHub
commit 0be74c7835
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      mesonbuild/mdevenv.py
  2. 6
      mesonbuild/mdist.py
  3. 13
      mesonbuild/mesonlib/universal.py
  4. 3
      mesonbuild/minit.py
  5. 4
      mesonbuild/minstall.py
  6. 7
      mesonbuild/mtest.py
  7. 12
      run_unittests.py

@ -4,12 +4,12 @@ import tempfile
from pathlib import Path
from . import build
from .mesonlib import MesonException, is_windows
from .mesonlib import MesonException, RealPathAction, is_windows
import typing as T
def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument('-C', default='.', dest='wd',
parser.add_argument('-C', dest='wd', action=RealPathAction,
help='directory to cd into before running')
parser.add_argument('command', nargs=argparse.REMAINDER,
help='Command to run in developer environment (default: interactive shell)')
@ -37,7 +37,6 @@ def get_env(b: build.Build, build_dir: str) -> T.Dict[str, str]:
return extra_env.get_env(env)
def run(options: argparse.Namespace) -> int:
options.wd = os.path.abspath(options.wd)
buildfile = Path(options.wd) / 'meson-private' / 'build.dat'
if not buildfile.is_file():
raise MesonException(f'Directory {options.wd!r} does not seem to be a Meson build directory.')

@ -23,7 +23,8 @@ import json
from glob import glob
from pathlib import Path
from mesonbuild.environment import detect_ninja
from mesonbuild.mesonlib import windows_proof_rmtree, MesonException, quiet_git
from mesonbuild.mesonlib import (MesonException, RealPathAction, quiet_git,
windows_proof_rmtree)
from mesonbuild.wrap import wrap
from mesonbuild import mlog, build
from .scripts.meson_exe import run_exe
@ -35,7 +36,7 @@ archive_extension = {'gztar': '.tar.gz',
'zip': '.zip'}
def add_arguments(parser):
parser.add_argument('-C', default='.', dest='wd',
parser.add_argument('-C', dest='wd', action=RealPathAction,
help='directory to cd into before running')
parser.add_argument('--formats', default='xztar',
help='Comma separated list of archive types to create. Supports xztar (default), gztar, and zip.')
@ -270,7 +271,6 @@ def determine_archives_to_generate(options):
return result
def run(options):
options.wd = os.path.abspath(options.wd)
buildfile = Path(options.wd) / 'meson-private' / 'build.dat'
if not buildfile.is_file():
raise MesonException(f'Directory {options.wd!r} does not seem to be a Meson build directory.')

@ -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.

@ -139,7 +139,8 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
Meson project.
'''
parser.add_argument("srcfiles", metavar="sourcefile", nargs="*", help="source files. default: all recognized files in current directory")
parser.add_argument('-C', default='.', dest='wd', help='directory to cd into before running')
parser.add_argument('-C', dest='wd', action=mesonlib.RealPathAction,
help='directory to cd into before running')
parser.add_argument("-n", "--name", help="project name. default: name of current directory")
parser.add_argument("-e", "--executable", help="executable name. default: project name")
parser.add_argument("-d", "--deps", help="dependencies, comma-separated")

@ -28,7 +28,7 @@ from . import environment
from .backend.backends import InstallData
from .coredata import major_versions_differ, MesonVersionMismatchException
from .coredata import version as coredata_version
from .mesonlib import is_windows, Popen_safe
from .mesonlib import Popen_safe, RealPathAction, is_windows
from .scripts import depfixer, destdir_join
from .scripts.meson_exe import run_exe
try:
@ -65,7 +65,7 @@ build definitions so that it will not break when the change happens.'''
selinux_updates: T.List[str] = []
def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument('-C', default='.', dest='wd',
parser.add_argument('-C', dest='wd', action=RealPathAction,
help='directory to cd into before running')
parser.add_argument('--profile-self', action='store_true', dest='profile',
help=argparse.SUPPRESS)

@ -43,7 +43,8 @@ from . import environment
from . import mlog
from .coredata import major_versions_differ, MesonVersionMismatchException
from .coredata import version as coredata_version
from .mesonlib import MesonException, OrderedSet, get_wine_shortpath, split_args, join_args
from .mesonlib import (MesonException, OrderedSet, RealPathAction,
get_wine_shortpath, join_args, split_args)
from .mintro import get_infodir, load_info_file
from .programs import ExternalProgram
from .backend.backends import TestProtocol, TestSerialisation
@ -104,7 +105,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
help='List available tests.')
parser.add_argument('--wrapper', default=None, dest='wrapper', type=split_args,
help='wrapper to run tests with (e.g. Valgrind)')
parser.add_argument('-C', default='.', dest='wd',
parser.add_argument('-C', dest='wd', action=RealPathAction,
# https://github.com/python/typeshed/issues/3107
# https://github.com/python/mypy/issues/7177
type=os.path.abspath, # type: ignore
@ -1485,7 +1486,6 @@ class TestHarness:
startdir = os.getcwd()
try:
if self.options.wd:
os.chdir(self.options.wd)
self.build_data = build.load(os.getcwd())
if not self.options.setup:
@ -1656,7 +1656,6 @@ class TestHarness:
self.name_max_len = max([uniwidth(self.get_pretty_suite(test)) for test in tests])
startdir = os.getcwd()
try:
if self.options.wd:
os.chdir(self.options.wd)
runners = [] # type: T.List[SingleTestRunner]
for i in range(self.options.repeat):

@ -6896,6 +6896,18 @@ class LinuxlikeTests(BasePlatformTests):
pcfile = f.read()
self.assertFalse('blub_blob_blib' in pcfile)
def test_symlink_builddir(self):
'''
Test using a symlink as either the builddir for "setup" or
the argument for "-C".
'''
testdir = os.path.join(self.common_test_dir, '1 trivial')
os.symlink(self.builddir, self.builddir + '-symlink')
self.change_builddir(self.builddir + '-symlink')
self.init(testdir)
self.build()
self._run(self.mtest_command)
def test_vala_c_warnings(self):
'''
Test that no warnings are emitted for C code generated by Vala. This

Loading…
Cancel
Save