aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-01 15:16:14 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-04 12:15:41 -0800
commit7142c922856ed0e060b3a0e1b75b6f542f40fca2 (patch)
treee26bfcc0824c352d0c1c66c38f60df7e0c76627e
parente2ef6930ff0b88beed6aeee068b4cf37037d5d9d (diff)
downloadmeson-7142c922856ed0e060b3a0e1b75b6f542f40fca2.zip
meson-7142c922856ed0e060b3a0e1b75b6f542f40fca2.tar.gz
meson-7142c922856ed0e060b3a0e1b75b6f542f40fca2.tar.bz2
use OptionKey for backend_options
-rw-r--r--mesonbuild/backend/ninjabackend.py7
-rw-r--r--mesonbuild/backend/vs2010backend.py3
-rw-r--r--mesonbuild/coredata.py20
-rw-r--r--mesonbuild/mconf.py4
-rw-r--r--mesonbuild/mintro.py5
-rw-r--r--mesonbuild/rewriter.py2
6 files changed, 20 insertions, 21 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 38df344..836cd5b 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -47,6 +47,7 @@ from ..mesonlib import get_compiler_for_source, has_path_sep
from .backends import CleanTrees
from ..build import InvalidArguments
from ..interpreter import Interpreter
+from ..coredata import OptionKey
FORTRAN_INCLUDE_PAT = r"^\s*#?include\s*['\"](\w+\.\w+)['\"]"
FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$"
@@ -514,7 +515,7 @@ int dummy;
outfile.write('# Do not edit by hand.\n\n')
outfile.write('ninja_required_version = 1.8.2\n\n')
- num_pools = self.environment.coredata.backend_options['backend_max_links'].value
+ num_pools = self.environment.coredata.backend_options[OptionKey('backend_max_links')].value
if num_pools > 0:
outfile.write('''pool link_pool
depth = {}
@@ -1846,7 +1847,7 @@ int dummy;
self.create_target_source_introspection(target, swiftc, compile_args + header_imports + module_includes, relsrc, rel_generated)
def generate_static_link_rules(self):
- num_pools = self.environment.coredata.backend_options['backend_max_links'].value
+ num_pools = self.environment.coredata.backend_options[OptionKey('backend_max_links')].value
if 'java' in self.environment.coredata.compilers.host:
self.generate_java_link()
for for_machine in MachineChoice:
@@ -1879,7 +1880,7 @@ int dummy;
extra=pool))
def generate_dynamic_link_rules(self):
- num_pools = self.environment.coredata.backend_options['backend_max_links'].value
+ num_pools = self.environment.coredata.backend_options[OptionKey('backend_max_links')].value
for for_machine in MachineChoice:
complist = self.environment.coredata.compilers[for_machine]
for langname, compiler in complist.items():
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 6d81e69..59a5ed4 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -31,6 +31,7 @@ from ..mesonlib import (
MesonException, File, python_command, replace_if_different
)
from ..environment import Environment, build_filename
+from ..coredata import OptionKey
def autodetect_vs_version(build: T.Optional[build.Build], interpreter: T.Optional[Interpreter]):
vs_version = os.getenv('VisualStudioVersion', None)
@@ -403,7 +404,7 @@ class Vs2010Backend(backends.Backend):
replace_if_different(sln_filename, sln_filename_tmp)
def generate_projects(self):
- startup_project = self.environment.coredata.backend_options['backend_startup_project'].value
+ startup_project = self.environment.coredata.backend_options[OptionKey('backend_startup_project')].value
projlist = []
startup_idx = 0
for (i, (name, target)) in enumerate(self.build.targets.items()):
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 53434ab..7bbd7ee 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -553,7 +553,7 @@ class CoreData:
self.version = version
self.builtins = {} # type: OptionDictType
self.builtins_per_machine: PerMachine['OptionDictType'] = PerMachine({}, {})
- self.backend_options = {} # type: OptionDictType
+ self.backend_options: 'KeyedOptionDictType' = {}
self.user_options: 'KeyedOptionDictType' = {}
self.compiler_options = PerMachine(
defaultdict(dict),
@@ -712,16 +712,14 @@ class CoreData:
def init_backend_options(self, backend_name: str) -> None:
if backend_name == 'ninja':
- self.backend_options['backend_max_links'] = \
- UserIntegerOption(
- 'Maximum number of linker processes to run or 0 for no '
- 'limit',
- (0, None, 0))
+ self.backend_options[OptionKey('backend_max_links')] = UserIntegerOption(
+ 'Maximum number of linker processes to run or 0 for no '
+ 'limit',
+ (0, None, 0))
elif backend_name.startswith('vs'):
- self.backend_options['backend_startup_project'] = \
- UserStringOption(
- 'Default project to execute in Visual Studio',
- '')
+ self.backend_options[OptionKey('backend_startup_project')] = UserStringOption(
+ 'Default project to execute in Visual Studio',
+ '')
def get_builtin_option(self, optname: str, subproject: str = '') -> T.Union[str, int, bool]:
raw_optname = optname
@@ -835,7 +833,7 @@ class CoreData:
return optname.lang is not None
def _get_all_nonbuiltin_options(self) -> T.Iterable[T.Dict[str, UserOption]]:
- yield self.backend_options
+ yield {str(k): v for k, v in self.backend_options.items()}
yield {str(k): v for k, v in self.user_options.items()}
yield dict(self.flatten_lang_iterator(self.get_prefixed_options_per_machine(self.compiler_options)))
yield self.base_options
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 9a68f7d..20e6d26 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -182,7 +182,7 @@ class Conf:
self._add_line(section + ':', '', '', '')
self.print_margin = 2
- def print_options(self, title, options):
+ def print_options(self, title: str, options: 'coredata.OptionDictType') -> None:
if not options:
return
if title:
@@ -232,7 +232,7 @@ class Conf:
self.print_options('', self.coredata.builtins_per_machine.host)
if show_build_options:
self.print_options('', {insert_build_prefix(k): o for k, o in self.coredata.builtins_per_machine.build.items()})
- self.print_options('Backend options', self.coredata.backend_options)
+ self.print_options('Backend options', {str(k): v for k, v in self.coredata.backend_options.items()})
self.print_options('Base options', self.coredata.base_options)
self.print_options('Compiler options', host_compiler_options.get('', {}))
if show_build_options:
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index a01963c..e252e82 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -231,8 +231,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
core_options.update(sub_core_options)
def add_keys(options: 'cdata.OptionDictType', section: str, machine: str = 'any') -> None:
- for key in sorted(options.keys()):
- opt = options[key]
+ for key, opt in sorted(options.items()):
optdict = {'name': key, 'value': opt.value, 'section': section, 'machine': machine}
if isinstance(opt, cdata.UserStringOption):
typestr = 'string'
@@ -258,7 +257,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
'core',
machine='build',
)
- add_keys(coredata.backend_options, 'backend')
+ add_keys({str(k): v for k, v in coredata.backend_options.items()}, 'backend')
add_keys(coredata.base_options, 'base')
add_keys(
dict(coredata.flatten_lang_iterator(coredata.compiler_options.host.items())),
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py
index 480ba60..dcc5040 100644
--- a/mesonbuild/rewriter.py
+++ b/mesonbuild/rewriter.py
@@ -467,7 +467,7 @@ class Rewriter:
**cdata.builtins,
**cdata.builtins_per_machine.host,
**{'build.' + k: o for k, o in cdata.builtins_per_machine.build.items()},
- **cdata.backend_options,
+ **{str(k): v for k, v in cdata.backend_options.items()},
**cdata.base_options,
**(dict(cdata.flatten_lang_iterator(cdata.compiler_options.host.items()))),
**{'build.' + k: o for k, o in cdata.flatten_lang_iterator(cdata.compiler_options.build.items())},