diff options
Diffstat (limited to 'mesonbuild/linkers.py')
-rw-r--r-- | mesonbuild/linkers.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 967e465..9ad4a28 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -477,6 +477,11 @@ class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta): # Only used by the Apple linker return [] + def get_win_subsystem_args(self, value: str) -> T.List[str]: + # Only used if supported by the dynamic linker and + # only when targeting Windows + return [] + def bitcode_args(self) -> T.List[str]: raise mesonlib.MesonException('This linker does not support bitcode bundles') @@ -743,6 +748,22 @@ class GnuDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dynam """Representation of GNU ld.bfd and ld.gold.""" + def get_win_subsystem_args(self, value: str) -> T.List[str]: + m = env.machines[self.for_machine] + args = [] + + if m.is_windows() or m.is_cygwin(): + if 'windows' in value: + args = ['--subsystem,windows'] + elif 'console' in value: + args = ['--subsystem,console'] + else: + raise mesonlib.MesonException(f'Only "windows" and "console" are supported for win_subsystem with MinGW, not "{value}".') + if ',' in value: + args[-1] = args[-1] + ':' + value.split(',')[1] + + return self._apply_prefix(args) + def get_accepts_rsp(self) -> bool: return True @@ -781,6 +802,13 @@ class LLVMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dyna return self._apply_prefix('--allow-shlib-undefined') return [] + def get_win_subsystem_args(self, value: str) -> T.List[str]: + m = env.machines[self.for_machine] + if not m.is_windows() or m.is_cygwin(): + return [] + + return self._apply_prefix([f'-subsystem:{value}']) + class WASMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, DynamicLinker): @@ -1122,6 +1150,9 @@ class VisualStudioLikeLinkerMixin: def get_allow_undefined_args(self) -> T.List[str]: return [] + def get_win_subsystem_args(self, value: str) -> T.List[str]: + return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}']) + def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str, suffix: str, soversion: str, darwin_versions: T.Tuple[str, str], is_shared_module: bool) -> T.List[str]: |