aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msetup.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/msetup.py')
-rw-r--r--mesonbuild/msetup.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 81dd183..e22e0a7 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -11,7 +11,7 @@ import typing as T
from . import build, coredata, environment, interpreter, mesonlib, mintro, mlog
from .mesonlib import MesonException
-from .options import COMPILER_BASE_OPTIONS, OptionKey
+from .options import OptionKey
if T.TYPE_CHECKING:
from typing_extensions import Protocol
@@ -180,36 +180,39 @@ class MesonApp:
# See class Backend's 'generate' for comments on capture args and returned dictionary.
def generate(self, capture: bool = False, vslite_ctx: T.Optional[dict] = None) -> T.Optional[dict]:
env = environment.Environment(self.source_dir, self.build_dir, self.options)
+ if not env.first_invocation:
+ assert self.options.reconfigure
+ env.coredata.set_from_configure_command(self.options)
mlog.initialize(env.get_log_dir(), self.options.fatal_warnings)
if self.options.profile:
mlog.set_timestamp_start(time.monotonic())
if self.options.clearcache:
env.coredata.clear_cache()
- with mesonlib.BuildDirLock(self.build_dir):
+ with mesonlib.DirectoryLock(self.build_dir, 'meson-private/meson.lock',
+ mesonlib.DirectoryLockAction.FAIL,
+ 'Some other Meson process is already using this build directory. Exiting.'):
return self._generate(env, capture, vslite_ctx)
- def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Any, all_subprojects: T.Any) -> None:
- pending = coredata.optstore.pending_options
+ def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Dict[OptionKey, str], all_subprojects: T.Mapping[str, object]) -> None:
errlist: T.List[str] = []
- for opt in pending:
- # It is not an error to set wrong option for unknown subprojects or
- # language because we don't have control on which one will be selected.
- if opt.subproject and opt.subproject not in all_subprojects:
+ known_subprojects = all_subprojects.keys()
+ for opt in cmd_line_options:
+ # Accept options that exist or could appear in subsequent reconfigurations,
+ # including options for subprojects that were not used
+ if opt in coredata.optstore or \
+ opt.evolve(subproject=None) in coredata.optstore or \
+ coredata.optstore.accept_as_pending_option(opt):
continue
- if coredata.optstore.is_compiler_option(opt):
+ if opt.subproject and opt.subproject not in known_subprojects:
continue
- if (coredata.optstore.is_base_option(opt) and
- opt.evolve(subproject=None, machine=mesonlib.MachineChoice.HOST) in COMPILER_BASE_OPTIONS):
+ # "foo=true" may also refer to toplevel project option ":foo"
+ if opt.subproject is None and coredata.optstore.is_project_option(opt.as_root()):
continue
- keystr = str(opt)
- if keystr in cmd_line_options:
- errlist.append(f'"{keystr}"')
+ errlist.append(f'"{opt}"')
if errlist:
errstr = ', '.join(errlist)
raise MesonException(f'Unknown options: {errstr}')
- coredata.optstore.clear_pending()
-
def _generate(self, env: environment.Environment, capture: bool, vslite_ctx: T.Optional[dict]) -> T.Optional[dict]:
# Get all user defined options, including options that have been defined
# during a previous invocation or using meson configure.
@@ -347,17 +350,18 @@ def run_genvslite_setup(options: CMDOptions) -> None:
# invoke the appropriate 'meson compile ...' build commands upon the normal visual studio build/rebuild/clean actions, instead of using
# the native VS/msbuild system.
builddir_prefix = options.builddir
- genvsliteval = options.cmd_line_options.pop('genvslite') # type: ignore [call-overload]
+ k_genvslite = OptionKey('genvslite')
+ genvsliteval = options.cmd_line_options.pop(k_genvslite)
# The command line may specify a '--backend' option, which doesn't make sense in conjunction with
# '--genvslite', where we always want to use a ninja back end -
- k_backend = 'backend'
+ k_backend = OptionKey('backend')
if k_backend in options.cmd_line_options.keys():
- if options.cmd_line_options[k_backend] != 'ninja': # type: ignore [index]
+ if options.cmd_line_options[k_backend] != 'ninja':
raise MesonException('Explicitly specifying a backend option with \'genvslite\' is not necessary '
'(the ninja backend is always used) but specifying a non-ninja backend '
'conflicts with a \'genvslite\' setup')
else:
- options.cmd_line_options[k_backend] = 'ninja' # type: ignore [index]
+ options.cmd_line_options[k_backend] = 'ninja'
buildtypes_list = coredata.get_genvs_default_buildtype_list()
vslite_ctx = {}
@@ -368,7 +372,7 @@ def run_genvslite_setup(options: CMDOptions) -> None:
vslite_ctx[buildtypestr] = app.generate(capture=True)
#Now for generating the 'lite' solution and project files, which will use these builds we've just set up, above.
options.builddir = f'{builddir_prefix}_vs'
- options.cmd_line_options[OptionKey('genvslite')] = genvsliteval
+ options.cmd_line_options[k_genvslite] = genvsliteval
app = MesonApp(options)
app.generate(capture=False, vslite_ctx=vslite_ctx)
@@ -384,7 +388,7 @@ def run(options: T.Union[CMDOptions, T.List[str]]) -> int:
# lie
options.pager = False
- if 'genvslite' in options.cmd_line_options.keys():
+ if OptionKey('genvslite') in options.cmd_line_options.keys():
run_genvslite_setup(options)
else:
app = MesonApp(options)