mcompile: provide user visibility into what actually happens

This command is magical and I hate it. Mostly because it seems people
have no clue what it does, and what it doesn't do.

Provide informational messages to the user indicating how it works, e.g.
for debugging. Point out if we ran vsenv before shelling out to the
backend.
pull/9372/merge
Eli Schwartz 2 years ago committed by Jussi Pakkanen
parent 6db9a01449
commit 28d07c31b8
  1. 10
      mesonbuild/mcompile.py

@ -22,11 +22,12 @@ import shutil
import typing as T
from collections import defaultdict
from pathlib import Path
from time import sleep
from . import mlog
from . import mesonlib
from . import coredata
from .mesonlib import MesonException, RealPathAction, setup_vsenv
from .mesonlib import MesonException, RealPathAction, join_args, setup_vsenv
from mesonbuild.environment import detect_ninja
from mesonbuild.coredata import UserArrayOption
from mesonbuild import build
@ -336,13 +337,16 @@ def run(options: 'argparse.Namespace') -> int:
cdata = coredata.load(options.wd)
b = build.load(options.wd)
setup_vsenv(b.need_vsenv)
vsenv_active = setup_vsenv(b.need_vsenv)
if vsenv_active:
mlog.log(mlog.green('INFO:'), 'automatically activated MSVC compiler environment')
cmd = [] # type: T.List[str]
env = None # type: T.Optional[T.Dict[str, str]]
backend = cdata.get_option(mesonlib.OptionKey('backend'))
assert isinstance(backend, str)
mlog.log(mlog.green('INFO:'), 'autodetecting backend as', backend)
if backend == 'ninja':
cmd, env = get_parsed_args_ninja(options, bdir)
elif backend.startswith('vs'):
@ -353,6 +357,8 @@ def run(options: 'argparse.Namespace') -> int:
raise MesonException(
f'Backend `{backend}` is not yet supported by `compile`. Use generated project files directly instead.')
mlog.log(mlog.green('INFO:'), 'calculating backend command to run:', join_args(cmd))
sleep(2)
p, *_ = mesonlib.Popen_safe(cmd, stdout=sys.stdout.buffer, stderr=sys.stderr.buffer, env=env)
return p.returncode

Loading…
Cancel
Save