aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/mconf.py')
-rw-r--r--mesonbuild/mconf.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 416caf1..217379f 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -73,6 +73,7 @@ class Conf:
self.build_dir = os.path.dirname(self.build_dir)
self.build = None
self.max_choices_line_length = 60
+ self.pending_section: T.Optional[str] = None
self.name_col: T.List[LOGLINE] = []
self.value_col: T.List[LOGLINE] = []
self.choices_col: T.List[LOGLINE] = []
@@ -125,9 +126,6 @@ class Conf:
def clear_cache(self) -> None:
self.coredata.clear_cache()
- def set_options(self, options: T.Dict[OptionKey, str]) -> bool:
- return self.coredata.set_options(options)
-
def save(self) -> None:
# Do nothing when using introspection
if self.default_values_only:
@@ -194,7 +192,7 @@ class Conf:
) -> T.Dict[str, options.MutableKeyedOptionDictType]:
result: T.Dict[str, options.MutableKeyedOptionDictType] = {}
for k, o in opts.items():
- if k.subproject:
+ if k.subproject is not None:
self.all_subprojects.add(k.subproject)
result.setdefault(k.subproject, {})[k] = o
return result
@@ -210,11 +208,13 @@ class Conf:
self.descr_col.append(descr)
def add_option(self, name: str, descr: str, value: T.Any, choices: T.Any) -> None:
+ self._add_section()
value = stringify(value)
choices = stringify(choices)
self._add_line(mlog.green(name), mlog.yellow(value), mlog.blue(choices), descr)
def add_title(self, title: str) -> None:
+ self._add_section()
newtitle = mlog.cyan(title)
descr = mlog.cyan('Description')
value = mlog.cyan('Default Value' if self.default_values_only else 'Current Value')
@@ -223,11 +223,17 @@ class Conf:
self._add_line(newtitle, value, choices, descr)
self._add_line('-' * len(newtitle), '-' * len(value), '-' * len(choices), '-' * len(descr))
- def add_section(self, section: str) -> None:
+ def _add_section(self) -> None:
+ if not self.pending_section:
+ return
self.print_margin = 0
self._add_line('', '', '', '')
- self._add_line(mlog.normal_yellow(section + ':'), '', '', '')
+ self._add_line(mlog.normal_yellow(self.pending_section + ':'), '', '', '')
self.print_margin = 2
+ self.pending_section = None
+
+ def add_section(self, section: str) -> None:
+ self.pending_section = section
def print_options(self, title: str, opts: T.Union[options.MutableKeyedOptionDictType, options.OptionStore]) -> None:
if not opts:
@@ -291,15 +297,15 @@ class Conf:
project_options = self.split_options_per_subproject({k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_project_option(k)})
show_build_options = self.default_values_only or self.build.environment.is_cross_build()
- self.add_section('Main project options')
+ self.add_section('Global build options')
self.print_options('Core options', host_core_options[None])
if show_build_options and build_core_options:
self.print_options('', build_core_options[None])
self.print_options('Backend options', {k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_backend_option(k)})
self.print_options('Base options', {k: v for k, v in self.coredata.optstore.items() if self.coredata.optstore.is_base_option(k)})
- self.print_options('Compiler options', host_compiler_options.get('', {}))
+ self.print_options('Compiler options', host_compiler_options.get(None, {}))
if show_build_options:
- self.print_options('', build_compiler_options.get('', {}))
+ self.print_options('', build_compiler_options.get(None, {}))
for mod, mod_options in module_options.items():
self.print_options(f'{mod} module options', mod_options)
self.print_options('Directories', dir_options)
@@ -307,8 +313,9 @@ class Conf:
self.print_options('Project options', project_options.get('', {}))
for subproject in sorted(self.all_subprojects):
if subproject == '':
- continue
- self.add_section('Subproject ' + subproject)
+ self.add_section('Main project')
+ else:
+ self.add_section('Subproject ' + subproject)
if subproject in host_core_options:
self.print_options('Core options', host_core_options[subproject])
if subproject in build_core_options and show_build_options:
@@ -317,7 +324,7 @@ class Conf:
self.print_options('Compiler options', host_compiler_options[subproject])
if subproject in build_compiler_options and show_build_options:
self.print_options('', build_compiler_options[subproject])
- if subproject in project_options:
+ if subproject != '' and subproject in project_options:
self.print_options('Project options', project_options[subproject])
self.print_aligned()
@@ -342,7 +349,7 @@ class Conf:
if self.coredata.optstore.augments:
mlog.log('\nCurrently set option augments:')
for k, v in self.coredata.optstore.augments.items():
- mlog.log(f'{k:21}{v:10}')
+ mlog.log(f'{k!s:21}{v:10}')
else:
mlog.log('\nThere are no option augments.')
@@ -373,11 +380,7 @@ def run_impl(options: CMDOptions, builddir: str) -> int:
save = False
if has_option_flags(options):
- unset_opts = getattr(options, 'unset_opts', [])
- all_D = options.projectoptions[:]
- for keystr, valstr in options.cmd_line_options.items():
- all_D.append(f'{keystr}={valstr}')
- save |= c.coredata.optstore.set_from_configure_command(all_D, unset_opts)
+ save |= c.coredata.set_from_configure_command(options)
coredata.update_cmd_line_file(builddir, options)
if options.clearcache:
c.clear_cache()