aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-01-04 23:42:50 +0000
committerGitHub <noreply@github.com>2021-01-04 23:42:50 +0000
commitd47a5c81a9af992eca42d857477f2bb5821712b6 (patch)
tree9c9ff772c696661a1582dc81c86273e8d975a13f /mesonbuild/backend
parent6b515c432109cf7ab488da37cddeb1752e91fa5c (diff)
parentf14bf8b2ed052f68857ed3eaec08a326d335a3a4 (diff)
downloadmeson-d47a5c81a9af992eca42d857477f2bb5821712b6.zip
meson-d47a5c81a9af992eca42d857477f2bb5821712b6.tar.gz
meson-d47a5c81a9af992eca42d857477f2bb5821712b6.tar.bz2
Merge pull request #8080 from dcbaker/submit/option-key-type
Use an object for option keys
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py54
-rw-r--r--mesonbuild/backend/ninjabackend.py70
-rw-r--r--mesonbuild/backend/vs2010backend.py41
-rw-r--r--mesonbuild/backend/xcodebackend.py2
4 files changed, 84 insertions, 83 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index b9f175a..ec3aca6 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -31,11 +31,13 @@ from .. import mesonlib
from .. import mlog
from ..compilers import languages_using_ldflags
from ..mesonlib import (
- File, MachineChoice, MesonException, OrderedSet, OptionOverrideProxy,
- classify_unity_sources, unholder
+ File, MachineChoice, MesonException, OptionType, OrderedSet, OptionOverrideProxy,
+ classify_unity_sources, unholder, OptionKey
)
if T.TYPE_CHECKING:
+ from ..arglist import CompilerArgs
+ from ..compilers import Compiler
from ..interpreter import Interpreter, Test
@@ -209,24 +211,21 @@ class Backend:
def get_target_filename_abs(self, target):
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
- def get_base_options_for_target(self, target):
+ def get_base_options_for_target(self, target: build.BuildTarget) -> OptionOverrideProxy:
return OptionOverrideProxy(target.option_overrides_base,
- self.environment.coredata.builtins,
- self.environment.coredata.base_options)
+ {k: v for k, v in self.environment.coredata.options.items()
+ if k.type in {OptionType.BASE, OptionType.BUILTIN}})
- def get_compiler_options_for_target(self, target):
- comp_reg = self.environment.coredata.compiler_options[target.for_machine]
+ def get_compiler_options_for_target(self, target: build.BuildTarget) -> OptionOverrideProxy:
+ comp_reg = {k: v for k, v in self.environment.coredata.options.items() if k.is_compiler()}
comp_override = target.option_overrides_compiler
- return {
- lang: OptionOverrideProxy(comp_override[lang], comp_reg[lang])
- for lang in set(comp_reg.keys()) | set(comp_override.keys())
- }
+ return OptionOverrideProxy(comp_override, comp_reg)
- def get_option_for_target(self, option_name, target):
+ def get_option_for_target(self, option_name: 'OptionKey', target: build.BuildTarget):
if option_name in target.option_overrides_base:
override = target.option_overrides_base[option_name]
return self.environment.coredata.validate_option_value(option_name, override)
- return self.environment.coredata.get_builtin_option(option_name, target.subproject)
+ return self.environment.coredata.get_option(option_name.evolve(subproject=target.subproject))
def get_target_filename_for_linking(self, target):
# On some platforms (msvc for instance), the file that is used for
@@ -251,7 +250,7 @@ class Backend:
@lru_cache(maxsize=None)
def get_target_dir(self, target):
- if self.environment.coredata.get_builtin_option('layout') == 'mirror':
+ if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
dirname = target.get_subdir()
else:
dirname = 'meson-out'
@@ -300,7 +299,7 @@ class Backend:
abs_files = []
result = []
compsrcs = classify_unity_sources(target.compilers.values(), unity_src)
- unity_size = self.get_option_for_target('unity_size', target)
+ unity_size = self.get_option_for_target(OptionKey('unity_size'), target)
def init_language_file(suffix, unity_file_number):
unity_src = self.get_unity_source_file(target, suffix, unity_file_number)
@@ -542,7 +541,7 @@ class Backend:
return paths
def determine_rpath_dirs(self, target):
- if self.environment.coredata.get_builtin_option('layout') == 'mirror':
+ if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
result = target.get_link_dep_subdirs()
else:
result = OrderedSet()
@@ -621,7 +620,8 @@ class Backend:
if self.is_unity(extobj.target):
compsrcs = classify_unity_sources(extobj.target.compilers.values(), sources)
sources = []
- unity_size = self.get_option_for_target('unity_size', extobj.target)
+ unity_size = self.get_option_for_target(OptionKey('unity_size'), extobj.target)
+
for comp, srcs in compsrcs.items():
for i in range(len(srcs) // unity_size + 1):
osrc = self.get_unity_source_file(extobj.target,
@@ -672,13 +672,13 @@ class Backend:
return extra_args
- def generate_basic_compiler_args(self, target, compiler, no_warn_args=False):
+ def generate_basic_compiler_args(self, target: build.BuildTarget, compiler: 'Compiler', no_warn_args: bool = False) -> 'CompilerArgs':
# Create an empty commands list, and start adding arguments from
# various sources in the order in which they must override each other
# starting from hard-coded defaults followed by build options and so on.
commands = compiler.compiler_args()
- copt_proxy = self.get_compiler_options_for_target(target)[compiler.language]
+ copt_proxy = self.get_compiler_options_for_target(target)
# First, the trivial ones that are impossible to override.
#
# Add -nostdinc/-nostdinc++ if needed; can't be overridden
@@ -690,20 +690,20 @@ class Backend:
if no_warn_args:
commands += compiler.get_no_warn_args()
else:
- commands += compiler.get_warn_args(self.get_option_for_target('warning_level', target))
+ commands += compiler.get_warn_args(self.get_option_for_target(OptionKey('warning_level'), target))
# Add -Werror if werror=true is set in the build options set on the
# command-line or default_options inside project(). This only sets the
# action to be done for warnings if/when they are emitted, so it's ok
# to set it after get_no_warn_args() or get_warn_args().
- if self.get_option_for_target('werror', target):
+ if self.get_option_for_target(OptionKey('werror'), target):
commands += compiler.get_werror_args()
# Add compile args for c_* or cpp_* build options set on the
# command-line or default_options inside project().
commands += compiler.get_option_compile_args(copt_proxy)
# Add buildtype args: optimization level, debugging, etc.
- commands += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target))
- commands += compiler.get_optimization_args(self.get_option_for_target('optimization', target))
- commands += compiler.get_debug_args(self.get_option_for_target('debug', target))
+ commands += compiler.get_buildtype_args(self.get_option_for_target(OptionKey('buildtype'), target))
+ commands += compiler.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target))
+ commands += compiler.get_debug_args(self.get_option_for_target(OptionKey('debug'), target))
# MSVC debug builds have /ZI argument by default and /Zi is added with debug flag
# /ZI needs to be removed in that case to avoid cl's warning to that effect (D9025 : overriding '/ZI' with '/Zi')
if ('/ZI' in commands) and ('/Zi' in commands):
@@ -1022,7 +1022,7 @@ class Backend:
return libs
def is_unity(self, target):
- optval = self.get_option_for_target('unity', target)
+ optval = self.get_option_for_target(OptionKey('unity'), target)
if optval == 'on' or (optval == 'subprojects' and target.subproject != ''):
return True
return False
@@ -1183,7 +1183,7 @@ class Backend:
self.environment.get_build_dir(),
self.environment.get_prefix(),
strip_bin,
- self.environment.coredata.get_builtin_option('install_umask'),
+ self.environment.coredata.get_option(OptionKey('install_umask')),
self.environment.get_build_command() + ['introspect'],
self.environment.coredata.version)
self.generate_depmf_install(d)
@@ -1228,7 +1228,7 @@ class Backend:
#
# TODO: Create GNUStrip/AppleStrip/etc. hierarchy for more
# fine-grained stripping of static archives.
- should_strip = not isinstance(t, build.StaticLibrary) and self.get_option_for_target('strip', t)
+ should_strip = not isinstance(t, build.StaticLibrary) and self.get_option_for_target(OptionKey('strip'), t)
# Install primary build output (library/executable/jar, etc)
# Done separately because of strip/aliases/rpath
if outdirs[0] is not False:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index b847c2c..d66708c 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -43,11 +43,14 @@ from ..mesonlib import (
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine,
ProgressBar, quote_arg, unholder,
)
-from ..mesonlib import get_compiler_for_source, has_path_sep
+from ..mesonlib import get_compiler_for_source, has_path_sep, OptionKey
from .backends import CleanTrees
from ..build import InvalidArguments
from ..interpreter import Interpreter
+if T.TYPE_CHECKING:
+ from ..linkers import StaticLinker
+
FORTRAN_INCLUDE_PAT = r"^\s*#?include\s*['\"](\w+\.\w+)['\"]"
FORTRAN_MODULE_PAT = r"^\s*\bmodule\b\s+(\w+)\s*(?:!+.*)*$"
FORTRAN_SUBMOD_PAT = r"^\s*\bsubmodule\b\s*\((\w+:?\w+)\)\s*(\w+)"
@@ -514,7 +517,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.options[OptionKey('backend_max_links')].value
if num_pools > 0:
outfile.write('''pool link_pool
depth = {}
@@ -534,8 +537,9 @@ int dummy;
self.add_build_comment(NinjaComment('Install rules'))
self.generate_install()
self.generate_dist()
- if 'b_coverage' in self.environment.coredata.base_options and \
- self.environment.coredata.base_options['b_coverage'].value:
+ key = OptionKey('b_coverage')
+ if (key in self.environment.coredata.options and
+ self.environment.coredata.options[key].value):
self.add_build_comment(NinjaComment('Coverage rules'))
self.generate_coverage_rules()
self.add_build_comment(NinjaComment('Suffix'))
@@ -811,7 +815,7 @@ int dummy;
source2object[s] = o
obj_list.append(o)
- use_pch = self.environment.coredata.base_options.get('b_pch', False)
+ use_pch = self.environment.coredata.options.get(OptionKey('b_pch'))
if use_pch and target.has_pch():
pch_objects = self.generate_pch(target, header_deps=header_deps)
else:
@@ -890,7 +894,7 @@ int dummy;
cpp = target.compilers['cpp']
if cpp.get_id() != 'msvc':
return False
- if self.environment.coredata.compiler_options[target.for_machine]['cpp']['std'] != 'c++latest':
+ if self.environment.coredata.options[OptionKey('std', machine=target.for_machine, lang='cpp')] != 'latest':
return False
if not mesonlib.current_vs_supports_modules():
return False
@@ -1124,9 +1128,9 @@ int dummy;
def generate_tests(self):
self.serialize_tests()
cmd = self.environment.get_build_command(True) + ['test', '--no-rebuild']
- if not self.environment.coredata.get_builtin_option('stdsplit'):
+ if not self.environment.coredata.get_option(OptionKey('stdsplit')):
cmd += ['--no-stdsplit']
- if self.environment.coredata.get_builtin_option('errorlogs'):
+ if self.environment.coredata.get_option(OptionKey('errorlogs')):
cmd += ['--print-errorlogs']
elem = NinjaBuildElement(self.all_outputs, 'meson-test', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
@@ -1294,8 +1298,8 @@ int dummy;
args.append(a)
return args, deps
- def generate_cs_target(self, target):
- buildtype = self.get_option_for_target('buildtype', target)
+ def generate_cs_target(self, target: build.BuildTarget):
+ buildtype = self.get_option_for_target(OptionKey('buildtype'), target)
fname = target.get_filename()
outname_rel = os.path.join(self.get_target_dir(target), fname)
src_list = target.get_sources()
@@ -1304,8 +1308,8 @@ int dummy;
deps = []
commands = compiler.compiler_args(target.extra_args.get('cs', []))
commands += compiler.get_buildtype_args(buildtype)
- commands += compiler.get_optimization_args(self.get_option_for_target('optimization', target))
- commands += compiler.get_debug_args(self.get_option_for_target('debug', target))
+ commands += compiler.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target))
+ commands += compiler.get_debug_args(self.get_option_for_target(OptionKey('debug'), target))
if isinstance(target, build.Executable):
commands.append('-target:exe')
elif isinstance(target, build.SharedLibrary):
@@ -1346,7 +1350,7 @@ int dummy;
def determine_single_java_compile_args(self, target, compiler):
args = []
- args += compiler.get_buildtype_args(self.get_option_for_target('buildtype', target))
+ args += compiler.get_buildtype_args(self.get_option_for_target(OptionKey('buildtype'), target))
args += self.build.get_global_args(compiler, target.for_machine)
args += self.build.get_project_args(compiler, target.subproject, target.for_machine)
args += target.get_java_args()
@@ -1509,7 +1513,7 @@ int dummy;
valac_outputs.append(vala_c_file)
args = self.generate_basic_compiler_args(target, valac)
- args += valac.get_colorout_args(self.environment.coredata.base_options.get('b_colorout').value)
+ args += valac.get_colorout_args(self.environment.coredata.options.get(OptionKey('b_colorout')).value)
# Tell Valac to output everything in our private directory. Sadly this
# means it will also preserve the directory components of Vala sources
# found inside the build tree (generated sources).
@@ -1613,12 +1617,12 @@ int dummy;
for a in rustc.linker.get_always_args():
args += ['-C', 'link-arg={}'.format(a)]
- opt_proxy = self.get_compiler_options_for_target(target)[rustc.language]
+ opt_proxy = self.get_compiler_options_for_target(target)
args += ['--crate-name', target.name]
- args += rustc.get_buildtype_args(self.get_option_for_target('buildtype', target))
- args += rustc.get_debug_args(self.get_option_for_target('debug', target))
- args += rustc.get_optimization_args(self.get_option_for_target('optimization', target))
+ args += rustc.get_buildtype_args(self.get_option_for_target(OptionKey('buildtype'), target))
+ args += rustc.get_debug_args(self.get_option_for_target(OptionKey('debug'), target))
+ args += rustc.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target))
args += rustc.get_option_compile_args(opt_proxy)
args += self.build.get_global_args(rustc, target.for_machine)
args += self.build.get_project_args(rustc, target.subproject, target.for_machine)
@@ -1769,8 +1773,8 @@ int dummy;
raise InvalidArguments('Swift target {} contains a non-swift source file.'.format(target.get_basename()))
os.makedirs(self.get_target_private_dir_abs(target), exist_ok=True)
compile_args = swiftc.get_compile_only_args()
- compile_args += swiftc.get_optimization_args(self.get_option_for_target('optimization', target))
- compile_args += swiftc.get_debug_args(self.get_option_for_target('debug', target))
+ compile_args += swiftc.get_optimization_args(self.get_option_for_target(OptionKey('optimization'), target))
+ compile_args += swiftc.get_debug_args(self.get_option_for_target(OptionKey('debug'), target))
compile_args += swiftc.get_module_args(module_name)
compile_args += self.build.get_project_args(swiftc, target.subproject, target.for_machine)
compile_args += self.build.get_global_args(swiftc, target.for_machine)
@@ -1846,7 +1850,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.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 +1883,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.options[OptionKey('backend_max_links')].value
for for_machine in MachineChoice:
complist = self.environment.coredata.compilers[for_machine]
for langname, compiler in complist.items():
@@ -2495,7 +2499,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += self.get_compile_debugfile_args(compiler, target, rel_obj)
# PCH handling
- if self.environment.coredata.base_options.get('b_pch', False):
+ if self.environment.coredata.options.get(OptionKey('b_pch')):
commands += self.get_pch_include_args(compiler, target)
pchlist = target.get_pch(compiler.language)
else:
@@ -2695,7 +2699,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += linker.get_pie_link_args()
elif isinstance(target, build.SharedLibrary):
if isinstance(target, build.SharedModule):
- options = self.environment.coredata.base_options
+ options = self.environment.coredata.options
commands += linker.get_std_shared_module_link_args(options)
else:
commands += linker.get_std_shared_lib_link_args()
@@ -2831,7 +2835,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
self.add_build(elem)
return [prelink_name]
- def generate_link(self, target, outname, obj_list, linker, extra_args=None, stdlib_args=None):
+ def generate_link(self, target: build.BuildTarget, outname, obj_list, linker: T.Union['Compiler', 'StaticLinker'], extra_args=None, stdlib_args=None):
extra_args = extra_args if extra_args is not None else []
stdlib_args = stdlib_args if stdlib_args is not None else []
implicit_outs = []
@@ -2866,9 +2870,9 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# Add things like /NOLOGO; usually can't be overridden
commands += linker.get_linker_always_args()
# Add buildtype linker args: optimization level, etc.
- commands += linker.get_buildtype_linker_args(self.get_option_for_target('buildtype', target))
+ commands += linker.get_buildtype_linker_args(self.get_option_for_target(OptionKey('buildtype'), target))
# Add /DEBUG and the pdb filename when using MSVC
- if self.get_option_for_target('debug', target):
+ if self.get_option_for_target(OptionKey('debug'), target):
commands += self.get_link_debugfile_args(linker, target, outname)
debugfile = self.get_link_debugfile_name(linker, target, outname)
if debugfile is not None:
@@ -2928,14 +2932,14 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# to be after all internal and external libraries so that unresolved
# symbols from those can be found here. This is needed when the
# *_winlibs that we want to link to are static mingw64 libraries.
- if hasattr(linker, 'get_language'):
+ if isinstance(linker, Compiler):
# The static linker doesn't know what language it is building, so we
# don't know what option. Fortunately, it doesn't care to see the
# language-specific options either.
#
# We shouldn't check whether we are making a static library, because
# in the LTO case we do use a real compiler here.
- commands += linker.get_option_link_args(self.environment.coredata.compiler_options[target.for_machine][linker.get_language()])
+ commands += linker.get_option_link_args(self.environment.coredata.options)
dep_targets = []
dep_targets.extend(self.guess_external_link_dependencies(linker, target, commands, internal))
@@ -3029,8 +3033,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
def get_user_option_args(self):
cmds = []
- for (k, v) in self.environment.coredata.user_options.items():
- cmds.append('-D' + k + '=' + (v.value if isinstance(v.value, str) else str(v.value).lower()))
+ for (k, v) in self.environment.coredata.options.items():
+ cmds.append('-D' + str(k) + '=' + (v.value if isinstance(v.value, str) else str(v.value).lower()))
# The order of these arguments must be the same between runs of Meson
# to ensure reproducible output. The order we pass them shouldn't
# affect behavior in any other way.
@@ -3152,8 +3156,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
if ctlist:
elem.add_dep(self.generate_custom_target_clean(ctlist))
- if 'b_coverage' in self.environment.coredata.base_options and \
- self.environment.coredata.base_options['b_coverage'].value:
+ if OptionKey('b_coverage') in self.environment.coredata.options and \
+ self.environment.coredata.options[OptionKey('b_coverage')].value:
self.generate_gcov_clean()
elem.add_dep('clean-gcda')
elem.add_dep('clean-gcno')
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 6d81e69..6e070a7 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -28,7 +28,7 @@ from .. import mlog
from .. import compilers
from ..interpreter import Interpreter
from ..mesonlib import (
- MesonException, File, python_command, replace_if_different
+ MesonException, File, python_command, replace_if_different, OptionKey,
)
from ..environment import Environment, build_filename
@@ -181,9 +181,9 @@ class Vs2010Backend(backends.Backend):
self.platform = 'ARM'
else:
raise MesonException('Unsupported Visual Studio platform: ' + target_machine)
- self.buildtype = self.environment.coredata.get_builtin_option('buildtype')
- self.optimization = self.environment.coredata.get_builtin_option('optimization')
- self.debug = self.environment.coredata.get_builtin_option('debug')
+ self.buildtype = self.environment.coredata.get_option(OptionKey('buildtype'))
+ self.optimization = self.environment.coredata.get_option(OptionKey('optimization'))
+ self.debug = self.environment.coredata.get_option(OptionKey('debug'))
sln_filename = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.sln')
projlist = self.generate_projects()
self.gen_testproj('RUN_TESTS', os.path.join(self.environment.get_build_dir(), 'RUN_TESTS.vcxproj'))
@@ -316,7 +316,7 @@ class Vs2010Backend(backends.Backend):
prj_templ = 'Project("{%s}") = "%s", "%s", "{%s}"\n'
for prj in projlist:
coredata = self.environment.coredata
- if coredata.get_builtin_option('layout') == 'mirror':
+ if coredata.get_option(OptionKey('layout')) == 'mirror':
self.generate_solution_dirs(ofile, prj[1].parents)
target = self.build.targets[prj[0]]
lang = 'default'
@@ -403,7 +403,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.options[OptionKey('backend_startup_project')].value
projlist = []
startup_idx = 0
for (i, (name, target)) in enumerate(self.build.targets.items()):
@@ -785,7 +785,7 @@ class Vs2010Backend(backends.Backend):
build_args += compiler.get_optimization_args(self.optimization)
build_args += compiler.get_debug_args(self.debug)
buildtype_link_args = compiler.get_buildtype_linker_args(self.buildtype)
- vscrt_type = self.environment.coredata.base_options['b_vscrt']
+ vscrt_type = self.environment.coredata.options[OptionKey('b_vscrt')]
project_name = target.name
target_name = target.name
root = ET.Element('Project', {'DefaultTargets': "Build",
@@ -878,7 +878,7 @@ class Vs2010Backend(backends.Backend):
# Exception handling has to be set in the xml in addition to the "AdditionalOptions" because otherwise
# cl will give warning D9025: overriding '/Ehs' with cpp_eh value
if 'cpp' in target.compilers:
- eh = self.environment.coredata.compiler_options[target.for_machine]['cpp']['eh']
+ eh = self.environment.coredata.options[OptionKey('eh', machine=target.for_machine, lang='cpp')]
if eh.value == 'a':
ET.SubElement(clconf, 'ExceptionHandling').text = 'Async'
elif eh.value == 's':
@@ -926,7 +926,7 @@ class Vs2010Backend(backends.Backend):
file_args[l] += compilers.get_base_compile_args(
self.get_base_options_for_target(target), comp)
file_args[l] += comp.get_option_compile_args(
- self.environment.coredata.compiler_options[target.for_machine][comp.language])
+ self.environment.coredata.options)
# Add compile args added using add_project_arguments()
for l, args in self.build.projects_args[target.for_machine].get(target.subproject, {}).items():
@@ -940,10 +940,8 @@ class Vs2010Backend(backends.Backend):
# Compile args added from the env or cross file: CFLAGS/CXXFLAGS, etc. We want these
# to override all the defaults, but not the per-target compile args.
for l in file_args.keys():
- opts = self.environment.coredata.compiler_options[target.for_machine][l]
- k = 'args'
- if k in opts:
- file_args[l] += opts[k].value
+ opts = self.environment.coredata.options[OptionKey('args', machine=target.for_machine, lang=l)]
+ file_args[l] += opts.value
for args in file_args.values():
# This is where Visual Studio will insert target_args, target_defines,
# etc, which are added later from external deps (see below).
@@ -1050,9 +1048,9 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(clconf, 'PreprocessorDefinitions').text = ';'.join(target_defines)
ET.SubElement(clconf, 'FunctionLevelLinking').text = 'true'
# Warning level
- warning_level = self.get_option_for_target('warning_level', target)
+ warning_level = self.get_option_for_target(OptionKey('warning_level'), target)
ET.SubElement(clconf, 'WarningLevel').text = 'Level' + str(1 + int(warning_level))
- if self.get_option_for_target('werror', target):
+ if self.get_option_for_target(OptionKey('werror'), target):
ET.SubElement(clconf, 'TreatWarningAsError').text = 'true'
# Optimization flags
o_flags = split_o_flags_args(build_args)
@@ -1077,7 +1075,7 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(clconf, 'FavorSizeOrSpeed').text = 'Speed'
# Note: SuppressStartupBanner is /NOLOGO and is 'true' by default
pch_sources = {}
- if self.environment.coredata.base_options.get('b_pch', False):
+ if self.environment.coredata.options.get(OptionKey('b_pch')):
for lang in ['c', 'cpp']:
pch = target.get_pch(lang)
if not pch:
@@ -1113,7 +1111,7 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(link, 'GenerateDebugInformation').text = 'false'
if not isinstance(target, build.StaticLibrary):
if isinstance(target, build.SharedModule):
- options = self.environment.coredata.base_options
+ options = self.environment.coredata.options
extra_link_args += compiler.get_std_shared_module_link_args(options)
# Add link args added using add_project_link_arguments()
extra_link_args += self.build.get_project_link_args(compiler, target.subproject, target.for_machine)
@@ -1146,8 +1144,7 @@ class Vs2010Backend(backends.Backend):
# to be after all internal and external libraries so that unresolved
# symbols from those can be found here. This is needed when the
# *_winlibs that we want to link to are static mingw64 libraries.
- extra_link_args += compiler.get_option_link_args(
- self.environment.coredata.compiler_options[compiler.for_machine][comp.language])
+ extra_link_args += compiler.get_option_link_args(self.environment.coredata.options)
(additional_libpaths, additional_links, extra_link_args) = self.split_link_args(extra_link_args.to_native())
# Add more libraries to be linked if needed
@@ -1226,7 +1223,7 @@ class Vs2010Backend(backends.Backend):
# /nologo
ET.SubElement(link, 'SuppressStartupBanner').text = 'true'
# /release
- if not self.environment.coredata.get_builtin_option('debug'):
+ if not self.environment.coredata.get_option(OptionKey('debug')):
ET.SubElement(link, 'SetChecksum').text = 'true'
meson_file_group = ET.SubElement(root, 'ItemGroup')
@@ -1426,9 +1423,9 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(midl, 'ProxyFileName').text = '%(Filename)_p.c'
# FIXME: No benchmarks?
test_command = self.environment.get_build_command() + ['test', '--no-rebuild']
- if not self.environment.coredata.get_builtin_option('stdsplit'):
+ if not self.environment.coredata.get_option(OptionKey('stdsplit')):
test_command += ['--no-stdsplit']
- if self.environment.coredata.get_builtin_option('errorlogs'):
+ if self.environment.coredata.get_option(OptionKey('errorlogs')):
test_command += ['--print-errorlogs']
self.serialize_tests()
self.add_custom_build(root, 'run_tests', '"%s"' % ('" "'.join(test_command)))
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index ef0c956..0e39c65 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -61,7 +61,7 @@ class XCodeBackend(backends.Backend):
return str(uuid.uuid4()).upper().replace('-', '')[:24]
def get_target_dir(self, target):
- dirname = os.path.join(target.get_subdir(), self.environment.coredata.get_builtin_option('buildtype'))
+ dirname = os.path.join(target.get_subdir(), self.environment.coredata.get_option(mesonlib.OptionKey('buildtype')))
os.makedirs(os.path.join(self.environment.get_build_dir(), dirname), exist_ok=True)
return dirname