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 Oct 9, 2023
1 parent 927f434 commit 304c55d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,22 +535,29 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus

_LANGUAGE_KWS: T.List[KwargInfo[T.List[str]]] = [
_BASE_LANG_KW.evolve(name=f'{lang}_args')
for lang in compilers.all_languages - {'rust', 'vala'}
for lang in compilers.all_languages - {'rust', 'vala', 'java'}
]
# Cannot use _BASE_LANG_KW here because Vala is special for types
_LANGUAGE_KWS.append(KwargInfo(
'vala_args', ContainerTypeInfo(list, (str, File)), listify=True, default=[]))
_LANGUAGE_KWS.append(_BASE_LANG_KW.evolve(name='rust_args', 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]] = _BASE_LANG_KW.evolve(
name='java_args',
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,
BT_SOURCES_KW,
RUST_CRATE_TYPE_KW,
KwargInfo(
Expand Down Expand Up @@ -630,6 +637,7 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
*_BUILD_TARGET_KWS,
*_EXCLUSIVE_EXECUTABLE_KWS,
_VS_MODULE_DEFS_KW.evolve(since='1.3.0', since_values=None),
_JAVA_LANG_KW,
]

# Arguments exclusive to library types
Expand All @@ -649,6 +657,7 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
*_BUILD_TARGET_KWS,
*_EXCLUSIVE_STATIC_LIB_KWS,
*_EXCLUSIVE_LIB_KWS,
_JAVA_LANG_KW,
]

# Arguments exclusive to SharedLibrary. These are separated to make integrating
Expand All @@ -665,6 +674,7 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
*_EXCLUSIVE_SHARED_LIB_KWS,
*_EXCLUSIVE_LIB_KWS,
_VS_MODULE_DEFS_KW,
_JAVA_LANG_KW,
]

# Arguments exclusive to SharedModule. These are separated to make integrating
Expand All @@ -677,13 +687,15 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
*_EXCLUSIVE_SHARED_MOD_KWS,
*_EXCLUSIVE_LIB_KWS,
_VS_MODULE_DEFS_KW,
_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
Expand All @@ -695,7 +707,9 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, GeneratedList, ExtractedObjects, BuildTarget)),
listify=True,
default=[],
)
),
*[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],
]

# Arguments used by both_library and library
Expand All @@ -706,11 +720,15 @@ def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tup
*_EXCLUSIVE_SHARED_MOD_KWS,
*_EXCLUSIVE_STATIC_LIB_KWS,
_VS_MODULE_DEFS_KW,
_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 304c55d

Please sign in to comment.