summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/detect.py4
-rw-r--r--mesonbuild/coredata.py39
-rw-r--r--unittests/linuxliketests.py7
3 files changed, 6 insertions, 44 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index a0ae8108d..71081fedc 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -674,11 +674,13 @@ def detect_cuda_compiler(env: 'Environment', for_machine: MachineChoice) -> Comp
cls = CudaCompiler
env.add_lang_args(cls.language, cls, for_machine)
key = OptionKey('cuda_link_args', machine=for_machine)
+ if for_machine is MachineChoice.BUILD and not is_cross:
+ key = key.as_host()
if key in env.options:
# To fix LDFLAGS issue
val = env.options[key]
assert isinstance(val, list)
- env.coredata.set_options({key: cls.to_host_flags_base(val, Phase.LINKER)})
+ env.coredata.optstore.set_option(key, cls.to_host_flags_base(val, Phase.LINKER))
linker = CudaLinker(compiler, for_machine, CudaCompiler.LINKER_PREFIX, [], version=CudaLinker.parse_version())
return cls(ccache, compiler, version, for_machine, is_cross, host_compiler=cpp_compiler, info=info, linker=linker)
raise EnvironmentException(f'Could not find suitable CUDA compiler: "{"; ".join([" ".join(c) for c in compilers])}"')
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 39e491792..80e6e0b70 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -463,45 +463,6 @@ class CoreData:
return False
return len(self.cross_files) > 0
- def set_options(self, opts_to_set: T.Dict[OptionKey, T.Any], subproject: str = '', first_invocation: bool = False) -> bool:
- dirty = False
- if not self.is_cross_build():
- opts_to_set = {k: v for k, v in opts_to_set.items() if k.machine is not MachineChoice.BUILD}
- # Set prefix first because it's needed to sanitize other options
- pfk = OptionKey('prefix')
- if pfk in opts_to_set:
- prefix = self.optstore.sanitize_prefix(opts_to_set[pfk])
- for key in options.BUILTIN_DIR_NOPREFIX_OPTIONS:
- if key not in opts_to_set:
- val = options.BUILTIN_OPTIONS[key].prefixed_default(key, prefix)
- dirty |= self.optstore.set_option(key, val)
-
- unknown_options: T.List[OptionKey] = []
- for k, v in opts_to_set.items():
- if k == pfk:
- continue
- elif k.evolve(subproject=None) in self.optstore:
- dirty |= self.set_option(k, v, first_invocation)
- elif k.machine != MachineChoice.BUILD and not self.optstore.is_compiler_option(k):
- unknown_options.append(k)
- if unknown_options:
- if subproject:
- # The subproject may have top-level options that should be used
- # when it is not a subproject. Ignore those for now. With option
- # refactor they will get per-subproject values.
- really_unknown = []
- for uo in unknown_options:
- topkey = uo.as_root()
- if topkey not in self.optstore:
- really_unknown.append(uo)
- unknown_options = really_unknown
- if unknown_options:
- unknown_options_str = ', '.join(sorted(str(s) for s in unknown_options))
- sub = f'In subproject {subproject}: ' if subproject else ''
- raise MesonException(f'{sub}Unknown options: "{unknown_options_str}"')
-
- return dirty
-
def add_compiler_options(self, c_options: MutableKeyedOptionDictType, lang: str, for_machine: MachineChoice,
subproject: str) -> None:
for k, o in c_options.items():
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index ad6d0ecea..c9ba37118 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -1144,7 +1144,7 @@ class LinuxlikeTests(BasePlatformTests):
self.assertPathExists(os.path.join(pkg_dir, 'librelativepath.pc'))
env = get_fake_env(testdir, self.builddir, self.prefix)
- env.coredata.set_options({OptionKey('pkg_config_path'): pkg_dir}, subproject='')
+ env.coredata.optstore.set_option(OptionKey('pkg_config_path'), pkg_dir)
kwargs = {'required': True, 'silent': True}
relative_path_dep = PkgConfigDependency('librelativepath', env, kwargs)
self.assertTrue(relative_path_dep.found())
@@ -1160,7 +1160,7 @@ class LinuxlikeTests(BasePlatformTests):
pkg_dir = os.path.join(testdir, 'pkgconfig')
env = get_fake_env(testdir, self.builddir, self.prefix)
- env.coredata.set_options({OptionKey('pkg_config_path'): pkg_dir}, subproject='')
+ env.coredata.optstore.set_option(OptionKey('pkg_config_path'), pkg_dir)
# Regression test: This used to modify the value of `pkg_config_path`
# option, adding the meson-uninstalled directory to it.
@@ -1195,8 +1195,7 @@ class LinuxlikeTests(BasePlatformTests):
env = get_fake_env(testdir, self.builddir, self.prefix)
- env.coredata.set_options({OptionKey('pkg_config_path'): external_pkg_config_path_dir},
- subproject='')
+ env.coredata.optstore.set_option(OptionKey('pkg_config_path'), external_pkg_config_path_dir)
newEnv = PkgConfigInterface.setup_env({}, env, MachineChoice.HOST, uninstalled=True)