interpreter: use typed_kwargs for Executable(win_subsystem)
This commit is contained in:
parent
67035a181e
commit
1cfbe5279d
|
@ -1152,10 +1152,10 @@ class BuildTarget(Target):
|
|||
# was not specified and win_subsystem should be used instead.
|
||||
self.gui_app = None
|
||||
if kwargs.get('gui_app') is not None:
|
||||
if 'win_subsystem' in kwargs:
|
||||
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 = self.validate_win_subsystem(kwargs.get('win_subsystem', 'console'))
|
||||
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:
|
||||
|
@ -1240,12 +1240,6 @@ class BuildTarget(Target):
|
|||
raise InvalidArguments(f'Invalid rust_dependency_map "{rust_dependency_map}": must be a dictionary with string values.')
|
||||
self.rust_dependency_map = rust_dependency_map
|
||||
|
||||
def validate_win_subsystem(self, value: str) -> str:
|
||||
value = value.lower()
|
||||
if re.fullmatch(r'(boot_application|console|efi_application|efi_boot_service_driver|efi_rom|efi_runtime_driver|native|posix|windows)(,\d+(\.\d+)?)?', value) is None:
|
||||
raise InvalidArguments(f'Invalid value for win_subsystem: {value}.')
|
||||
return value
|
||||
|
||||
def _extract_pic_pie(self, kwargs, arg: str, option: str):
|
||||
# Check if we have -fPIC, -fpic, -fPIE, or -fpie in cflags
|
||||
all_flags = self.extra_args['c'] + self.extra_args['cpp']
|
||||
|
|
|
@ -1807,7 +1807,6 @@ class Interpreter(InterpreterBase, HoldableObject):
|
|||
return Disabler()
|
||||
|
||||
@FeatureNewKwargs('executable', '0.42.0', ['implib'])
|
||||
@FeatureNewKwargs('executable', '0.56.0', ['win_subsystem'])
|
||||
@permittedKwargs(build.known_exe_kwargs)
|
||||
@typed_pos_args('executable', str, varargs=(str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList, build.StructuredSources, build.ExtractedObjects, build.BuildTarget))
|
||||
@typed_kwargs('executable', *EXECUTABLE_KWS, allow_unknown=True)
|
||||
|
|
|
@ -329,6 +329,7 @@ class _BuildTarget(_BaseBuildTarget):
|
|||
class Executable(_BuildTarget):
|
||||
|
||||
gui_app: T.Optional[bool]
|
||||
win_subsystem: T.Optional[str]
|
||||
|
||||
|
||||
class StaticLibrary(_BuildTarget):
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import re
|
||||
import typing as T
|
||||
|
||||
from .. import compilers
|
||||
|
@ -490,10 +491,22 @@ _BUILD_TARGET_KWS: T.List[KwargInfo] = [
|
|||
*_ALL_TARGET_KWS,
|
||||
]
|
||||
|
||||
def _validate_win_subsystem(value: T.Optional[str]) -> T.Optional[str]:
|
||||
if value is not None:
|
||||
if re.fullmatch(r'(boot_application|console|efi_application|efi_boot_service_driver|efi_rom|efi_runtime_driver|native|posix|windows)(,\d+(\.\d+)?)?', value) is None:
|
||||
return f'Invalid value for win_subsystem: {value}.'
|
||||
return None
|
||||
|
||||
# Arguments exclusive to Executable. These are separated to make integrating
|
||||
# them into build_target easier
|
||||
_EXCLUSIVE_EXECUTABLE_KWS: T.List[KwargInfo] = [
|
||||
KwargInfo('gui_app', (bool, NoneType), deprecated='0.56.0', deprecated_message="Use 'win_subsystem' instead")
|
||||
KwargInfo('gui_app', (bool, NoneType), deprecated='0.56.0', deprecated_message="Use 'win_subsystem' instead"),
|
||||
KwargInfo(
|
||||
'win_subsystem',
|
||||
(str, NoneType),
|
||||
convertor=lambda x: x.lower() if isinstance(x, str) else None,
|
||||
validator=_validate_win_subsystem,
|
||||
),
|
||||
]
|
||||
|
||||
# The total list of arguments used by Executable
|
||||
|
|
Loading…
Reference in New Issue