make 'gui_app' an interpreter only concept

Since it's deprecated anyway, we don't really want to plumb it all the
way down into the build and backend layers. Instead, we can just turn
it into a `win_subsystem` value in the interpreter if `win_subsystem`
isn't already set.
pull/12038/head
Dylan Baker 1 year ago committed by Eli Schwartz
parent 1cfbe5279d
commit 1a182ab599
  1. 5
      mesonbuild/backend/ninjabackend.py
  2. 4
      mesonbuild/backend/vs2010backend.py
  3. 14
      mesonbuild/build.py
  4. 4
      mesonbuild/compilers/compilers.py
  5. 3
      mesonbuild/compilers/mixins/gnu.py
  6. 12
      mesonbuild/interpreter/interpreter.py
  7. 13
      mesonbuild/linkers/linkers.py

@ -3277,15 +3277,12 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
def get_target_type_link_args_post_dependencies(self, target, linker):
commands = []
if isinstance(target, build.Executable):
# If gui_app is significant on this platform, add the appropriate linker arguments.
# If win_subsystem 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 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

@ -1645,10 +1645,6 @@ class Vs2010Backend(backends.Backend):
conftype = 'Makefile'
elif isinstance(target, build.Executable):
conftype = 'Application'
if target.gui_app is not None:
if not target.gui_app:
subsystem = 'Console'
else:
# If someone knows how to set the version properly,
# please send a patch.
subsystem = target.win_subsystem.split(',')[0]

@ -1147,18 +1147,11 @@ class BuildTarget(Target):
(str, bool))
self.install_mode = kwargs.get('install_mode', None)
self.install_tag = stringlistify(kwargs.get('install_tag', [None]))
if isinstance(self, Executable):
# This kwarg is deprecated. The value of "none" means that the kwarg
# was not specified and win_subsystem should be used instead.
self.gui_app = None
if not isinstance(self, Executable):
# build_target will always populate these as `None`, which is fine
if kwargs.get('gui_app') is not None:
if kwargs.get('win_subsystem') is not None:
raise InvalidArguments('Can specify only gui_app or win_subsystem for a target, not both.')
self.gui_app = kwargs['gui_app']
self.win_subsystem = kwargs.get('win_subsystem', 'console')
elif 'gui_app' in kwargs:
raise InvalidArguments('Argument gui_app can only be used on executables.')
elif 'win_subsystem' in kwargs:
if kwargs.get('win_subsystem') is not None:
raise InvalidArguments('Argument win_subsystem can only be used on executables.')
extra_files = extract_as_list(kwargs, 'extra_files')
for i in extra_files:
@ -1901,6 +1894,7 @@ class Executable(BuildTarget):
kwargs['pie'] = environment.coredata.options[key].value
super().__init__(name, subdir, subproject, for_machine, sources, structured_sources, objects,
environment, compilers, kwargs)
self.win_subsystem = kwargs.get('win_subsystem') or 'console'
# Check for export_dynamic
self.export_dynamic = kwargs.get('export_dynamic', False)
if not isinstance(self.export_dynamic, bool):

@ -980,10 +980,6 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def gnu_symbol_visibility_args(self, vistype: str) -> T.List[str]:
return []
def get_gui_app_args(self, value: bool) -> T.List[str]:
# Only used on Windows
return self.linker.get_gui_app_args(value)
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

@ -451,9 +451,6 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def get_profile_use_args(self) -> T.List[str]:
return ['-fprofile-use']
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):
if i[:2] == '-I' or i[:2] == '-L':

@ -3280,6 +3280,18 @@ class Interpreter(InterpreterBase, HoldableObject):
outputs.update(o)
kwargs['include_directories'] = self.extract_incdirs(kwargs)
if targetclass is build.Executable:
if kwargs['gui_app'] is not None:
if kwargs['win_subsystem'] is not None:
raise InvalidArguments.from_node(
'Executable got both "gui_app", and "win_subsystem" arguments, which are mutually exclusive',
node=node)
if kwargs['gui_app']:
kwargs['win_subsystem'] = 'windows'
if kwargs['win_subsystem'] is None:
kwargs['win_subsystem'] = 'console'
target = targetclass(name, self.subdir, self.subproject, for_machine, srcs, struct, objs,
self.environment, self.compilers[for_machine], kwargs)

@ -279,10 +279,6 @@ class DynamicLinker(metaclass=abc.ABCMeta):
# Only used by the Apple linker
return []
def get_gui_app_args(self, value: bool) -> T.List[str]:
# Only used by VisualStudioLikeLinkers
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
@ -1318,9 +1314,6 @@ class MSVCDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
def get_always_args(self) -> T.List[str]:
return self._apply_prefix(['/nologo', '/release']) + super().get_always_args()
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, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])
@ -1347,9 +1340,6 @@ class ClangClDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
return super().get_output_args(outputname)
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, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])
@ -1370,9 +1360,6 @@ class XilinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
direct: bool = True):
super().__init__(['xilink.exe'], for_machine, '', always_args, version=version)
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, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])

Loading…
Cancel
Save