mcompile: fix broken codepaths and restore orphaned code

In commit 928078982c a good error message
about the directory not being a valid build directory, was replaced by a
worse message.

In commit abaa980436 the error message was
replaced by a traceback when trying to load the coredata before checking
if it was a build directory.

Revert back to using the helper function with the good error message.
Reorganize code so that we check basic things first, and do less work
before detecting errors.

Fixes #9584
pull/10112/head
Eli Schwartz 3 years ago committed by Nirbheek Chauhan
parent 9b984052bb
commit d8adaf5593
  1. 12
      mesonbuild/mcompile.py

@ -322,20 +322,18 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
)
def run(options: 'argparse.Namespace') -> int:
cdata = coredata.load(options.wd)
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.')
validate_builddir(bdir)
if options.targets and options.clean:
raise MesonException('`TARGET` and `--clean` can\'t be used simultaneously')
cdata = coredata.load(options.wd)
b = build.load(options.wd)
setup_vsenv(b.need_vsenv)
cmd = [] # type: T.List[str]
env = None # type: T.Optional[T.Dict[str, str]]
if options.targets and options.clean:
raise MesonException('`TARGET` and `--clean` can\'t be used simultaneously')
backend = cdata.get_option(mesonlib.OptionKey('backend'))
assert isinstance(backend, str)
if backend == 'ninja':

Loading…
Cancel
Save