Propagate Windows target checks up

pull/8096/head
Laurin-Luis Lehning 4 years ago committed by Dylan Baker
parent 919278e3e1
commit 4164efceca
  1. 10
      mesonbuild/backend/ninjabackend.py
  2. 8
      mesonbuild/compilers/compilers.py
  3. 2
      mesonbuild/compilers/mixins/clang.py
  4. 6
      mesonbuild/compilers/mixins/gnu.py
  5. 37
      mesonbuild/linkers.py

@ -2702,11 +2702,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# If gui_app is significant on this platform, add the appropriate linker arguments.
# Unfortunately this can't be done in get_target_type_link_args, because some misguided
# libraries (such as SDL2) add -mwindows to their link flags.
m = self.environment.machines[target.for_machine]
if target.gui_app is not None:
commands += linker.get_gui_app_args(self.environment, target.gui_app)
else:
commands += linker.get_win_subsystem_args(self.environment, target.win_subsystem)
if m.is_windows() or m.is_cygwin():
if target.gui_app is not None:
commands += linker.get_gui_app_args(target.gui_app)
else:
commands += linker.get_win_subsystem_args(target.win_subsystem)
return commands
def get_link_whole_args(self, linker, target):

@ -870,15 +870,15 @@ class Compiler(metaclass=abc.ABCMeta):
def gnu_symbol_visibility_args(self, vistype: str) -> T.List[str]:
return []
def get_gui_app_args(self, env: 'Environment', value: bool) -> T.List[str]:
def get_gui_app_args(self, value: bool) -> T.List[str]:
# Only used on Windows
return self.linker.get_gui_app_args(env, value)
return self.linker.get_gui_app_args(value)
def get_win_subsystem_args(self, env: 'Environment', value: str) -> T.List[str]:
def get_win_subsystem_args(self, value: str) -> T.List[str]:
# By default the dynamic linker is going to return an empty
# array in case it either doesn't support Windows subsystems
# or does not target Windows
return self.linker.get_win_subsystem_args(env, value)
return self.linker.get_win_subsystem_args(value)
def has_func_attribute(self, name: str, env: 'Environment') -> T.Tuple[bool, bool]:
raise EnvironmentException(

@ -19,7 +19,7 @@ import shutil
import typing as T
from ... import mesonlib
from ...linkers import AppleDynamicLinker, ClangClDynamicLinker
from ...linkers import AppleDynamicLinker
from ..compilers import CompileCheckMode
from .gnu import GnuLikeCompiler

@ -214,10 +214,8 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def get_profile_use_args(self) -> T.List[str]:
return ['-fprofile-use', '-fprofile-correction']
def get_gui_app_args(self, env: 'Environment', value: bool) -> T.List[str]:
if self.info.is_windows() or self.info.is_cygwin():
return ['-mwindows' if value else '-mconsole']
return []
def get_gui_app_args(self, value: bool) -> T.List[str]:
return ['-mwindows' if value else '-mconsole']
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):

@ -477,11 +477,11 @@ class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta):
# Only used by the Apple linker
return []
def get_gui_app_args(self, env: 'Environment', value: bool) -> T.List[str]:
def get_gui_app_args(self, value: bool) -> T.List[str]:
# Only used by VisualStudioLikeLinkers
return []
def get_win_subsystem_args(self, env: 'Environment', value: str) -> T.List[str]:
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 []
@ -752,17 +752,13 @@ class GnuDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dynam
"""Representation of GNU ld.bfd and ld.gold."""
def get_win_subsystem_args(self, env: 'Environment', 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}".')
def get_win_subsystem_args(self, value: str) -> T.List[str]:
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]
@ -806,11 +802,7 @@ class LLVMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dyna
return self._apply_prefix('--allow-shlib-undefined')
return []
def get_win_subsystem_args(self, env: 'Environment', value: str) -> T.List[str]:
m = env.machines[self.for_machine]
if not m.is_windows() or m.is_cygwin():
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
return self._apply_prefix([f'-subsystem:{value}'])
@ -1154,13 +1146,10 @@ class VisualStudioLikeLinkerMixin:
def get_allow_undefined_args(self) -> T.List[str]:
return []
def get_gui_app_args(self, env: 'Environment', value: bool) -> T.List[str]:
if value:
return self.get_win_subsystem_args(env, "windows")
return self.get_win_subsystem_args(env, "console")
def get_gui_app_args(self, value: bool) -> T.List[str]:
return self.get_win_subsystem_args("windows" if value else "console")
def get_win_subsystem_args(self, env: 'Environment', value: str) -> T.List[str]:
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,

Loading…
Cancel
Save