Fix @typed_pos_args on java.generate_native_headers

pull/10072/head
Tristan Partin 3 years ago committed by Dylan Baker
parent d35f11fc08
commit d072ebc955
  1. 11
      mesonbuild/modules/java.py
  2. 15
      test cases/java/9 jni/meson.build
  3. 5
      test cases/java/9 jni/src/com/mesonbuild/Configured.java.in
  4. 2
      test cases/java/9 jni/src/com/mesonbuild/JniTest.java
  5. 10
      test cases/java/9 jni/src/com/mesonbuild/meson.build
  6. 18
      test cases/java/9 jni/src/meson.build

@ -16,7 +16,7 @@ import os
import pathlib
import typing as T
from mesonbuild import mesonlib
from mesonbuild.build import CustomTarget
from mesonbuild.build import CustomTarget, CustomTargetIndex, GeneratedList, Target
from mesonbuild.compilers import detect_compiler_for, Compiler
from mesonbuild.interpreter import Interpreter
from mesonbuild.interpreterbase.decorators import ContainerTypeInfo, FeatureDeprecated, FeatureNew, KwargInfo, typed_pos_args, typed_kwargs
@ -80,12 +80,13 @@ class JavaModule(NewExtensionModule):
return ModuleReturnValue(target, [target])
@FeatureNew('java.generate_native_headers', '0.62.0')
@typed_pos_args('java.generate_native_headers', (str, mesonlib.File), min_varargs=1)
@typed_pos_args('java.generate_native_headers',
varargs=(str, mesonlib.File, Target, CustomTargetIndex, GeneratedList))
@typed_kwargs('java.generate_native_headers',
KwargInfo('classes', (ContainerTypeInfo(list, str)), default=[], listify=True,
KwargInfo('classes', ContainerTypeInfo(list, str), default=[], listify=True,
required=True),
KwargInfo('package', str, default=None))
def generate_native_headers(self, state: ModuleState, args: T.List[mesonlib.FileOrString],
def generate_native_headers(self, state: ModuleState, args: T.Tuple[T.List[mesonlib.FileOrString]],
kwargs: T.Dict[str, T.Optional[str]]) -> ModuleReturnValue:
classes = T.cast(T.List[str], kwargs.get('classes'))
package = kwargs.get('package')
@ -112,7 +113,7 @@ class JavaModule(NewExtensionModule):
prefix = classes[0] if not package else package
target = CustomTarget(f'{prefix}-native-headers', state.subdir, state.subproject, command,
sources=list(args), outputs=headers, backend=state.backend)
sources=args[0], outputs=headers, backend=state.backend)
# It is only known that 1.8.0 won't pre-create the directory. 11 and 16
# do not exhibit this behavior.

@ -16,6 +16,17 @@ java = find_program('java')
jni_dep = dependency('jni', version : '>=1.8', modules: ['jvm', 'awt'])
# generate native headers
subdir('src/com/mesonbuild')
subdir('lib')
subdir('src')
subdir('lib')
test(
'jnitest',
java,
args: [
'-Djava.library.path=@0@'.format(fs.parent(jnijava.full_path())),
'-jar',
jnijar,
],
protocol : 'exitcode',
depends : [jnijava],
)

@ -0,0 +1,5 @@
package com.mesonbuild;
public final class Configured {
public static final int FINGERPRINT = @fingerprint@;
}

@ -4,7 +4,7 @@ public final class JniTest {
private static native int jni_test();
public static void main(String[] args) {
if (jni_test() != 0xdeadbeef) {
if (jni_test() != Configured.FINGERPRINT) {
throw new RuntimeException("jdk_test() did not return 0");
}
}

@ -1,3 +1,11 @@
configured = configure_file(
input: files('Configured.java.in'),
output: 'Configured.java',
configuration: configuration_data({'fingerprint': '0xdeadbeef'})
)
sources += configured
native_headers = javamod.generate_native_headers(
'JniTest.java', package: 'com.mesonbuild', classes: ['JdkTest'])
sources, package: 'com.mesonbuild', classes: ['JniTest'])
native_header_includes = include_directories('.')

@ -1,17 +1,9 @@
sources = [files('com/mesonbuild/JniTest.java')]
subdir('com/mesonbuild')
jnijar = jar(
'jnijar',
'com' / 'mesonbuild' / 'JniTest.java',
sources,
main_class : 'com.mesonbuild.JniTest',
)
test(
'jnitest',
java,
args: [
'-Djava.library.path=@0@'.format(fs.parent(jnijava.full_path())),
'-jar',
jnijar,
],
protocol : 'exitcode',
depends : [jnijava],
)

Loading…
Cancel
Save