interpreter: use typed_kwargs for build_target.build_by_default

This allows a little bit of cleanup in the build layer, since there is
code now that would always be true and we shouldn't do that.
pull/12392/head
Dylan Baker 1 year ago
parent bd0ab92bba
commit 507d8bf4d7
  1. 3
      mesonbuild/build.py
  2. 1
      mesonbuild/interpreter/interpreter.py
  3. 1
      mesonbuild/interpreter/kwargs.py
  4. 1
      mesonbuild/interpreter/type_checking.py

@ -652,7 +652,8 @@ class Target(HoldableObject, metaclass=abc.ABCMeta):
self.build_by_default = kwargs['build_by_default']
if not isinstance(self.build_by_default, bool):
raise InvalidArguments('build_by_default must be a boolean value.')
elif kwargs.get('install', False):
if not self.build_by_default and kwargs.get('install', False):
# For backward compatibility, if build_by_default is not explicitly
# set, use the value of 'install' if it's enabled.
self.build_by_default = True

@ -3314,7 +3314,6 @@ class Interpreter(InterpreterBase, HoldableObject):
targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]]
) -> T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]:
@FeatureNewKwargs('build target', '0.42.0', ['build_rpath', 'implicit_include_directories'])
@FeatureNewKwargs('build target', '0.38.0', ['build_by_default'])
@FeatureNewKwargs('build target', '0.48.0', ['gnu_symbol_visibility'])
def build_target_decorator_caller(self, node, args, kwargs):
return True

@ -325,6 +325,7 @@ class _BaseBuildTarget(TypedDict):
BuildTarget functions.
"""
build_by_default: bool
override_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
depend_files: NotRequired[T.List[File]]

@ -552,6 +552,7 @@ _JAVA_LANG_KW: KwargInfo[T.List[str]] = _BASE_LANG_KW.evolve(
# Applies to all build_target like classes
_ALL_TARGET_KWS: T.List[KwargInfo] = [
OVERRIDE_OPTIONS_KW,
KwargInfo('build_by_default', bool, default=True, since='0.38.0'),
]
# Applies to all build_target classes except jar

Loading…
Cancel
Save