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