aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mcompile.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-09-30 11:54:43 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2021-10-10 23:15:18 +0300
commit928078982c8643bffd95a8da06a1b4494fe87e2b (patch)
tree1e8e50892e5f329927d9196cea85e66801c1af03 /mesonbuild/mcompile.py
parent31bea202c9dc9d288d787f0073f0e221971669ba (diff)
downloadmeson-928078982c8643bffd95a8da06a1b4494fe87e2b.zip
meson-928078982c8643bffd95a8da06a1b4494fe87e2b.tar.gz
meson-928078982c8643bffd95a8da06a1b4494fe87e2b.tar.bz2
Add --vsenv command line option and active VS only when needed
Diffstat (limited to 'mesonbuild/mcompile.py')
-rw-r--r--mesonbuild/mcompile.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py
index f586fde..146ea13 100644
--- a/mesonbuild/mcompile.py
+++ b/mesonbuild/mcompile.py
@@ -26,9 +26,10 @@ from pathlib import Path
from . import mlog
from . import mesonlib
from . import coredata
-from .mesonlib import MesonException
+from .mesonlib import MesonException, RealPathAction, setup_vsenv
from mesonbuild.environment import detect_ninja
from mesonbuild.coredata import UserArrayOption
+from mesonbuild import build
if T.TYPE_CHECKING:
import argparse
@@ -286,14 +287,9 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
action='store_true',
help='Clean the build directory.'
)
- parser.add_argument(
- '-C',
- action='store',
- dest='builddir',
- type=Path,
- default='.',
- help='The directory containing build files to be built.'
- )
+ parser.add_argument('-C', dest='wd', action=RealPathAction,
+ help='directory to cd into before running')
+
parser.add_argument(
'-j', '--jobs',
action='store',
@@ -333,8 +329,12 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
)
def run(options: 'argparse.Namespace') -> int:
- bdir = options.builddir # type: Path
- validate_builddir(bdir.resolve())
+ bdir = Path(options.wd)
+ buildfile = bdir / '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.')
+ b = build.load(options.wd)
+ setup_vsenv(b.need_vsenv)
cmd = [] # type: T.List[str]
env = None # type: T.Optional[T.Dict[str, str]]