From f23b0e7f35661645b7fec82025e72dffa189ab59 Mon Sep 17 00:00:00 2001 From: Andrew McNulty Date: Wed, 9 Apr 2025 18:13:39 +0200 Subject: interpreter: Error if java sources used with non-jar target (#14424) If the user specifies java sources as input to a non-jar build target, raise an error with a message directing them to use the jar target instead. Fixes: https://github.com/mesonbuild/meson/issues/13870 --- mesonbuild/compilers/__init__.py | 2 ++ mesonbuild/compilers/compilers.py | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'mesonbuild/compilers') diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index 116b3fa7a..aab761af4 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -19,6 +19,7 @@ __all__ = [ 'is_llvm_ir', 'is_object', 'is_source', + 'is_java', 'is_known_suffix', 'lang_suffixes', 'LANGUAGES_USING_LDFLAGS', @@ -55,6 +56,7 @@ from .compilers import ( get_base_link_args, is_header, is_source, + is_java, is_assembly, is_llvm_ir, is_object, diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index a3b243dd9..3c1d58b4e 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -148,6 +148,12 @@ def is_assembly(fname: 'mesonlib.FileOrString') -> bool: suffix = fname.split('.')[-1] return suffix in assembler_suffixes +def is_java(fname: mesonlib.FileOrString) -> bool: + if isinstance(fname, mesonlib.File): + fname = fname.fname + suffix = fname.split('.')[-1] + return suffix in lang_suffixes['java'] + def is_llvm_ir(fname: 'mesonlib.FileOrString') -> bool: if isinstance(fname, mesonlib.File): fname = fname.fname -- cgit v1.2.3