From 3f0329dc3e7e93525a5aa2138f1fe7d7b59cc62b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 20 Jul 2023 10:55:58 -0700 Subject: [PATCH] interpreter: deprecated language args that don't apply to targets `java_args` is only valid for `jar()` (and `build_target()`, but that's deprecated), while all other language args are invalid for `jar()`. This deprecates all of those arguments, that shouldn't be allowed, and provides useful error messages. As an advantage, this avoids generating useless `java_static_args` and `java_shared_args`. In order to get useful error messages for both build_target and executable + *library, we need to separate LIBRARY and BUILD_TARGET a bit. --- mesonbuild/interpreter/type_checking.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 21afc2d581a3..b188eb990efa 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -482,20 +482,25 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus _LANGUAGE_KWS: T.List[KwargInfo[T.List[str]]] = [ KwargInfo(f'{lang}_args', ContainerTypeInfo(list, (str, File)), listify=True, default=[]) - for lang in compilers.all_languages - {'rust'} + for lang in compilers.all_languages - {'rust', 'java'} ] _LANGUAGE_KWS.append(KwargInfo( 'rust_args', ContainerTypeInfo(list, str), listify=True, default=[], since='0.41.0')) +# We need this deprecated values more than the non-deprecated values. So we'll evolve them out elsewhere. +_JAVA_LANG_KW: KwargInfo[T.List[str]] = KwargInfo( + 'java_args', ContainerTypeInfo(list, str), listify=True, default=[], + deprecated='1.3.0', deprecated_message='This does not, and never has, done anything. It should be removed') + # Applies to all build_target like classes _ALL_TARGET_KWS: T.List[KwargInfo] = [ - *_LANGUAGE_KWS, OVERRIDE_OPTIONS_KW, ] # Applies to all build_target classes except jar _BUILD_TARGET_KWS: T.List[KwargInfo] = [ *_ALL_TARGET_KWS, + *_LANGUAGE_KWS, ] # Arguments exclusive to Executable. These are separated to make integrating @@ -506,6 +511,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus EXECUTABLE_KWS = [ *_BUILD_TARGET_KWS, *_EXCLUSIVE_EXECUTABLE_KWS, + _JAVA_LANG_KW, ] # Arguments exclusive to StaticLibrary. These are separated to make integrating @@ -516,6 +522,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus STATIC_LIB_KWS = [ *_BUILD_TARGET_KWS, *_EXCLUSIVE_STATIC_LIB_KWS, + _JAVA_LANG_KW, ] # Arguments exclusive to SharedLibrary. These are separated to make integrating @@ -526,6 +533,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus SHARED_LIB_KWS = [ *_BUILD_TARGET_KWS, *_EXCLUSIVE_SHARED_LIB_KWS, + _JAVA_LANG_KW, ] # Arguments exclusive to SharedModule. These are separated to make integrating @@ -536,6 +544,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus SHARED_MOD_KWS = [ *_BUILD_TARGET_KWS, *_EXCLUSIVE_SHARED_MOD_KWS, + _JAVA_LANG_KW, ] # Arguments exclusive to JAR. These are separated to make integrating @@ -543,12 +552,16 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus _EXCLUSIVE_JAR_KWS: T.List[KwargInfo] = [ KwargInfo('main_class', str, default=''), KwargInfo('java_resources', (StructuredSources, NoneType), since='0.62.0'), + _JAVA_LANG_KW.evolve(deprecated=None, deprecated_message=None), ] # The total list of arguments used by JAR JAR_KWS = [ *_ALL_TARGET_KWS, *_EXCLUSIVE_JAR_KWS, + *[a.evolve(deprecated='1.3.0', deprecated_message='This argument has never done anything in jar(), and should be removed') + for a in _LANGUAGE_KWS], + # This is the only not deprecated case ] # Arguments used by both_library and library @@ -557,11 +570,15 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus *_EXCLUSIVE_SHARED_LIB_KWS, *_EXCLUSIVE_SHARED_MOD_KWS, *_EXCLUSIVE_STATIC_LIB_KWS, + _JAVA_LANG_KW, ] # Arguments used by build_Target BUILD_TARGET_KWS = [ - *LIBRARY_KWS, + *_BUILD_TARGET_KWS, + *_EXCLUSIVE_SHARED_LIB_KWS, + *_EXCLUSIVE_SHARED_MOD_KWS, + *_EXCLUSIVE_STATIC_LIB_KWS, *_EXCLUSIVE_EXECUTABLE_KWS, *[a.evolve(deprecated='1.3.0', deprecated_message='The use of "jar" in "build_target()" is deprecated, and this argument is only used by jar()') for a in _EXCLUSIVE_JAR_KWS],