Skip to content

Commit

Permalink
interpreter: deprecated language args that don't apply to targets
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
dcbaker committed Jul 24, 2023
1 parent b693d01 commit 3f0329d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -536,19 +544,24 @@ 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
# them into build_target easier
_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
Expand All @@ -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],
Expand Down

0 comments on commit 3f0329d

Please sign in to comment.