Skip to content

Commit

Permalink
Fix std lookup in subprojects.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Apr 28, 2024
1 parent 593bdc1 commit a3fcf6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ def generate_basic_compiler_args(self, target: build.BuildTarget, compiler: 'Com
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(target, self.environment)
commands += compiler.get_option_compile_args(target, self.environment, target.subproject)

optimization = self.get_target_option(target, 'optimization')
assert isinstance(optimization, str), 'for mypy'
Expand Down Expand Up @@ -2077,10 +2077,12 @@ def is_unity(self, target: build.BuildTarget) -> bool:

def get_target_option(self, target: build.Target, name: T.Union[str, OptionKey]) -> T.Union[str, int, bool, 'WrapMode']:
if isinstance(name, str):
key = OptionKey(name)
key = OptionKey(name, subproject=target.subproject)
elif isinstance(name, OptionKey):
key = name
else:
import sys
sys.exit('Internal error: invalid option type.')
if key.name == 'std':
pass
return self.environment.coredata.get_option_for_target(target, key)
5 changes: 4 additions & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,10 @@ def should_use_dyndeps_for_target(self, target: 'build.BuildTarget') -> bool:
cpp = target.compilers['cpp']
if cpp.get_id() != 'msvc':
return False
cppversion = self.get_target_option(target, OptionKey('std', machine=target.for_machine, lang='cpp'))
cppversion = self.get_target_option(target, OptionKey('std',
machine=target.for_machine,
lang='cpp',
subproject=target.subproject))
if cppversion not in ('latest', 'c++latest', 'vc++latest'):
return False
if not mesonlib.current_vs_supports_modules():
Expand Down
2 changes: 2 additions & 0 deletions mesonbuild/compilers/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]:
args = []
key = OptionKey('std', machine=self.for_machine, lang=self.language)
if subproject is not None:
key = key.evolve(subproject=subproject)
std = env.determine_option_value(key, target, subproject)
rtti = env.determine_option_value(key.evolve('rtti'), target, subproject)
debugstl = env.determine_option_value(key.evolve('debugstl'), target, subproject)
Expand Down

0 comments on commit a3fcf6b

Please sign in to comment.