Skip to content

Commit 54e9ffd

Browse files
committed
compilers: Use get_option_for_maybe_target
1 parent 7092cec commit 54e9ffd

5 files changed

Lines changed: 10 additions & 32 deletions

File tree

mesonbuild/compilers/cpp.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,9 @@ def get_option_link_args(self, target: None, subproject: SubProject) -> T.List[s
808808

809809
def get_option_link_args(self, target: T.Optional[BuildTarget], subproject: T.Optional[SubProject] = None) -> T.List[str]:
810810
subproject = subproject if subproject is not None else target.subproject
811-
# need a typeddict for this
812811
key = self.form_compileropt_key('winlibs', subproject)
813-
if target:
814-
value = self.environment.coredata.optstore.get_option_for_target_untyped(target, key)
815-
else:
816-
value = self.environment.coredata.optstore.get_value_for_untyped(key)
817-
return T.cast('T.List[str]', value)[:]
812+
value = self.environment.coredata.optstore.get_option_for_maybe_target(target, key, list)
813+
return value.copy()
818814

819815
def _get_options_impl(self, opts: 'MutableKeyedOptionDictType', cpp_stds: T.List[str]) -> 'MutableKeyedOptionDictType':
820816
opts = super().get_options()
@@ -922,10 +918,7 @@ def get_option_std_args(self, target: T.Optional[BuildTarget], subproject: T.Opt
922918
# (i.e., after VS2015U3)
923919
# if one is using anything before that point, one cannot set the standard.
924920
stdkey = self.form_compileropt_key('std', subproject)
925-
if target is not None:
926-
std = self.environment.coredata.optstore.get_option_for_target_untyped(target, stdkey)
927-
else:
928-
std = self.environment.coredata.optstore.get_value_for_untyped(stdkey)
921+
std = self.environment.coredata.optstore.get_option_for_maybe_target(target, stdkey, str)
929922
if std in {'vc++11', 'c++11'}:
930923
mlog.warning(self.id, 'does not support C++11;',
931924
'attempting best effort; setting the standard to C++14',

mesonbuild/compilers/cuda.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -778,14 +778,11 @@ def _get_ccbin_args(self, target: 'T.Optional[BuildTarget]',
778778
subproject: T.Optional[SubProject] = None) -> T.List[str]:
779779
subproject = target.subproject if subproject is None else subproject
780780
key = self.form_compileropt_key('ccbindir', subproject)
781-
if target:
782-
ccbindir = self.environment.coredata.optstore.get_option_for_target_untyped(target, key)
783-
else:
784-
ccbindir = self.environment.coredata.optstore.get_value_for_untyped(key)
785-
if isinstance(ccbindir, str) and ccbindir != '':
781+
ccbindir = self.environment.coredata.optstore.get_option_for_maybe_target(target, key, str)
782+
783+
if ccbindir != '':
786784
return [self._shield_nvcc_list_arg('-ccbin='+ccbindir, False)]
787-
else:
788-
return []
785+
return []
789786

790787
def get_profile_generate_args(self) -> T.List[str]:
791788
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_generate_args()]

mesonbuild/compilers/mixins/elbrus.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ def get_option_std_args(self, target: T.Optional[BuildTarget], subproject: T.Opt
8787
args: T.List[str] = []
8888
subproject = subproject if subproject is not None else target.subproject
8989
key = OptionKey(f'{self.language}_std', subproject=subproject, machine=self.for_machine)
90-
if target:
91-
std = self.environment.coredata.optstore.get_option_for_target_untyped(target, key)
92-
else:
93-
std = self.environment.coredata.optstore.get_value_for_untyped(key)
94-
assert isinstance(std, str)
90+
std = self.environment.coredata.optstore.get_option_for_maybe_target(target, key, str)
9591
if std != 'none':
9692
args.append('-std=' + std)
9793
return args

mesonbuild/compilers/objc.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ def get_option_std_args(self, target: T.Optional[BuildTarget], subproject: T.Opt
7979
args: T.List[str] = []
8080
subproject = subproject if subproject is not None else target.subproject
8181
key = OptionKey('c_std', subproject=subproject, machine=self.for_machine)
82-
if target:
83-
std = self.environment.coredata.optstore.get_option_for_target_untyped(target, key)
84-
else:
85-
std = self.environment.coredata.optstore.get_value_for_untyped(key)
86-
assert isinstance(std, str)
82+
std = self.environment.coredata.optstore.get_option_for_maybe_target(target, key, str)
8783
if std != 'none':
8884
args.append('-std=' + std)
8985
return args

mesonbuild/compilers/objcpp.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ def get_option_std_args(self, target: T.Optional[BuildTarget], subproject: T.Opt
8383
args: T.List[str] = []
8484
subproject = subproject if subproject is not None else target.subproject
8585
key = OptionKey('cpp_std', subproject=subproject, machine=self.for_machine)
86-
if target:
87-
std = self.environment.coredata.optstore.get_option_for_target_untyped(target, key)
88-
else:
89-
std = self.environment.coredata.optstore.get_value_for_untyped(key)
90-
assert isinstance(std, str)
86+
std = self.environment.coredata.optstore.get_option_for_maybe_target(target, key, str)
9187
if std != 'none':
9288
args.append('-std=' + std)
9389
return args

0 commit comments

Comments
 (0)