linkers: Accept both str and List[str] for _apply_prefix
Simplifies some usage.
@@ -246,12 +246,16 @@ class DynamicLinker(metaclass=abc.ABCMeta):
'custom': [],
} # type: T.Dict[str, T.List[str]]
- def _apply_prefix(self, arg: str) -> T.List[str]:
+ def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]:
+ args = [arg] if isinstance(arg, str) else arg
if self.prefix_arg is None:
- return [arg]
+ return args
elif isinstance(self.prefix_arg, str):
- return [self.prefix_arg + arg]
- return self.prefix_arg + [arg]
+ return [self.prefix_arg + arg for arg in args]
+ ret = []
+ for arg in args:
+ ret += self.prefix_arg + [arg]
+ return ret
def __init__(self, exelist: T.List[str], for_machine: mesonlib.MachineChoice,
id_: str, prefix_arg: T.Union[str, T.List[str]],
@@ -796,7 +800,7 @@ class VisualStudioLikeLinkerMixin:
return self._apply_prefix('/MDd')
def get_output_args(self, outputname: str) -> T.List[str]:
- return self._apply_prefix('/MACHINE:' + self.machine) + self._apply_prefix('/OUT:' + outputname)
+ return self._apply_prefix(['/MACHINE:' + self.machine, '/OUT:' + outputname])
def get_always_args(self) -> T.List[str]:
return self._apply_prefix('/nologo') + super().get_always_args()
@@ -810,7 +814,7 @@ class VisualStudioLikeLinkerMixin:
def get_debugfile_args(self, targetfile: str) -> T.List[str]:
pdbarr = targetfile.split('.')[:-1]
pdbarr += ['pdb']
- return self._apply_prefix('/DEBUG') + self._apply_prefix('/PDB:' + '.'.join(pdbarr))
+ return self._apply_prefix(['/DEBUG', '/PDB:' + '.'.join(pdbarr)])
def get_link_whole_for(self, args: T.List[str]) -> T.List[str]:
# Only since VS2015
