Skip to content

Commit

Permalink
Fix VS code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Aug 19, 2024
1 parent 0ea5891 commit 2a7dd81
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
13 changes: 10 additions & 3 deletions mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,10 @@ def get_options(self) -> MutableKeyedOptionDictType:

def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]:
key = self.form_compileropt_key('winlibs')
libs = env.coredata.get_option_for_target(target, key).copy()
if target is not None:
libs = env.coredata.get_option_for_target(target, key).copy()
else:
libs = env.coredata.get_option_for_subproject(key, subproject).copy()
assert isinstance(libs, list)
for l in libs:
assert isinstance(l, str)
Expand Down Expand Up @@ -514,8 +517,12 @@ def get_options(self) -> 'MutableKeyedOptionDictType':

def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]:
args = []
key = self.form_compileropt_key('std')
std = env.coredata.get_option_for_target(target, key)
stdkey = self.form_compileropt_key('std')
if target is not None:
std = env.coredata.get_option_for_target(target, stdkey)
else:
std = env.coredata.get_option_for_subproject(stdkey, subproject)

# As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options.
if std in {'c11'}:
args.append('/std:c11')
Expand Down
30 changes: 19 additions & 11 deletions mesonbuild/compilers/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,18 @@ def _get_options_impl(self, opts: 'MutableKeyedOptionDictType', cpp_stds: T.List

def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]:
args: T.List[str] = []
key = self.form_compileropt_key('std')
stdkey = self.form_compileropt_key('std')
ehkey = self.form_compileropt_key('eh')
rttikey = self.form_compileropt_key('rtti')

if target is not None:
std = env.coredata.get_option_for_target(target, key)
eh = env.coredata.get_option_for_target(target, key.evolve('eh'))
rtti = env.coredata.get_option_for_target(target, key.evolve('rtti'))
std = env.coredata.get_option_for_target(target, stdkey)
eh = env.coredata.get_option_for_target(target, ehkey)
rtti = env.coredata.get_option_for_target(target, rttikey)
else:
std = env.coredata.get_option_for_subproject(key, subprojct)
eh = env.coredata.get_option_for_target(key.evolve('eh'), subproject)
rtti = env.coredata.get_option_for_target(key.evolve('rtti'), subproject)
std = env.coredata.get_option_for_subproject(stdkey, subproject)
eh = env.coredata.get_option_for_subproject(ehkey, subproject)
rtti = env.coredata.get_option_for_subproject(rttikey, subproject)

if eh == 'default':
args.append('/EHsc')
Expand Down Expand Up @@ -844,8 +846,11 @@ def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', sub
# which means setting the C++ standard version to C++14, in compilers that support it
# (i.e., after VS2015U3)
# if one is using anything before that point, one cannot set the standard.
key = self.form_compileropt_key('std')
std = env.coredata.get_option_for_target(target, key)
stdkey = self.form_compileropt_key('std')
if target is not None:
std = env.coredata.get_option_for_target(target, stdkey)
else:
std = env.coredata.get_option_for_subproject(stdkey, subproject)
if std in {'vc++11', 'c++11'}:
mlog.warning(self.id, 'does not support C++11;',
'attempting best effort; setting the standard to C++14',
Expand Down Expand Up @@ -884,8 +889,11 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
return self._get_options_impl(super().get_options(), cpp_stds)

def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]:
key = self.form_compileropt_key('std')
std = env.coredata.get_option_for_target(target, key)
stdkey = self.form_compileropt_key('std')
if target is not None:
std = env.coredata.get_option_for_target(target, stdkey)
else:
std = env.coredata.get_option_for_subproject(stdkey, subproject)
if std != 'none' and version_compare(self.version, '<19.00.24210'):
mlog.warning('This version of MSVC does not support cpp_std arguments', fatal=False)

Expand Down
2 changes: 1 addition & 1 deletion test cases/common/40 options/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if get_option('array_opt') != ['one', 'two']
endif

# If the default changes, update test cases/unit/13 reconfigure
if get_option('b_lto') != false
if get_option('b_pch') != true
error('Incorrect value in base option.')
endif

Expand Down

0 comments on commit 2a7dd81

Please sign in to comment.