From 2d10c0f2e61cdc656b6c99ad1149da13e933450f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Tue, 25 Jun 2024 12:06:34 +0200 Subject: [PATCH 1/4] structured_sources: Allow build_tgt to be added as source In some cases, there is a need to use a built library as a "source" for another target. Specifically Java JAR might want to contain their own native JNI libraries in order to provide a single file "executable". --- mesonbuild/interpreter/interpreter.py | 2 +- test cases/java/9 jni/meson.build | 9 +++-- .../9 jni/src/com/mesonbuild/JniTest.java | 36 ++++++++++++++++--- .../java/9 jni/src/com/mesonbuild/meson.build | 2 ++ .../native}/com_mesonbuild_JniTest.c | 0 .../com/mesonbuild/native}/meson.build | 8 ++--- .../com/mesonbuild/native}/native.c | 0 test cases/java/9 jni/src/meson.build | 1 + 8 files changed, 42 insertions(+), 16 deletions(-) rename test cases/java/9 jni/{lib => src/com/mesonbuild/native}/com_mesonbuild_JniTest.c (100%) rename test cases/java/9 jni/{lib => src/com/mesonbuild/native}/meson.build (70%) rename test cases/java/9 jni/{lib => src/com/mesonbuild/native}/native.c (100%) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 95d85ac07ebf..4adc3f9ef84d 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -2377,7 +2377,7 @@ def func_structured_sources( self, node: mparser.BaseNode, args: T.Tuple[object, T.Optional[T.Dict[str, object]]], kwargs: 'TYPE_kwargs') -> build.StructuredSources: - valid_types = (str, mesonlib.File, build.GeneratedList, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList) + valid_types = (str, mesonlib.File, build.GeneratedList, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList, build.BuildTarget) sources: T.Dict[str, T.List[T.Union[mesonlib.File, 'build.GeneratedTypes']]] = collections.defaultdict(list) for arg in mesonlib.listify(args[0]): diff --git a/test cases/java/9 jni/meson.build b/test cases/java/9 jni/meson.build index a4051ad28093..d20dc1fae531 100644 --- a/test cases/java/9 jni/meson.build +++ b/test cases/java/9 jni/meson.build @@ -14,25 +14,24 @@ javamod = import('java') cc = meson.get_compiler('c') java = find_program('java') -jni_dep = dependency('jni', version : '>=1.8', modules: ['jvm', 'awt']) +jni_dep = dependency('jni', modules: ['jvm', 'awt']) +if jni_dep.version().version_compare('< 9') + error('MESON_SKIP_TEST: this test requires Java 9') +endif # Assert that the header can actually be found with the dependency. cc.has_header('jni.h', dependencies: [jni_dep], required: true) # Assert that the platform-specific include directory is included in the compiler arguments. cc.has_header('jni_md.h', dependencies: [jni_dep], required: true) -# generate native headers subdir('src') -subdir('lib') test( 'jnitest', java, args: [ - '-Djava.library.path=@0@'.format(fs.parent(jnijava.full_path())), '-jar', jnijar, ], protocol : 'exitcode', - depends : [jnijava], ) diff --git a/test cases/java/9 jni/src/com/mesonbuild/JniTest.java b/test cases/java/9 jni/src/com/mesonbuild/JniTest.java index 4bfffe987741..040c18f46142 100644 --- a/test cases/java/9 jni/src/com/mesonbuild/JniTest.java +++ b/test cases/java/9 jni/src/com/mesonbuild/JniTest.java @@ -1,6 +1,38 @@ package com.mesonbuild; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.IOException; + public final class JniTest { + private static String libname = "jnijava"; + static { + String fullname = System.mapLibraryName(libname); + // this is somewhat hacky, but attempt to split off the extension + int ext = fullname.indexOf("."); + if (ext < 0) + ext = fullname.length(); + try { + File fslib = File.createTempFile(fullname.substring(0, ext), fullname.substring(ext)); + fslib.setReadable(true); + fslib.setWritable(true, true); + fslib.setExecutable(true); + + InputStream istream = JniTest.class.getResourceAsStream("/" + fullname); + FileOutputStream ostream = new FileOutputStream(fslib); + istream.transferTo(ostream); + istream.close(); + ostream.close(); + + System.load(fslib.getAbsolutePath()); + + fslib.deleteOnExit(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + private static native int jni_test(); public static void main(String[] args) { @@ -8,8 +40,4 @@ public static void main(String[] args) { throw new RuntimeException("jdk_test() did not return 0"); } } - - static { - System.loadLibrary("jnijava"); - } } diff --git a/test cases/java/9 jni/src/com/mesonbuild/meson.build b/test cases/java/9 jni/src/com/mesonbuild/meson.build index a505b1ad2ce8..77566db17f5b 100644 --- a/test cases/java/9 jni/src/com/mesonbuild/meson.build +++ b/test cases/java/9 jni/src/com/mesonbuild/meson.build @@ -9,3 +9,5 @@ sources += configured native_headers = javamod.native_headers( sources, package: 'com.mesonbuild', classes: ['JniTest']) native_header_includes = include_directories('.') + +subdir('native') diff --git a/test cases/java/9 jni/lib/com_mesonbuild_JniTest.c b/test cases/java/9 jni/src/com/mesonbuild/native/com_mesonbuild_JniTest.c similarity index 100% rename from test cases/java/9 jni/lib/com_mesonbuild_JniTest.c rename to test cases/java/9 jni/src/com/mesonbuild/native/com_mesonbuild_JniTest.c diff --git a/test cases/java/9 jni/lib/meson.build b/test cases/java/9 jni/src/com/mesonbuild/native/meson.build similarity index 70% rename from test cases/java/9 jni/lib/meson.build rename to test cases/java/9 jni/src/com/mesonbuild/native/meson.build index c2ddc7a31e79..1d66daacba27 100644 --- a/test cases/java/9 jni/lib/meson.build +++ b/test cases/java/9 jni/src/com/mesonbuild/native/meson.build @@ -1,4 +1,4 @@ -sources = [ +native_sources = [ files( 'native.c', 'com_mesonbuild_JniTest.c', @@ -8,11 +8,7 @@ sources = [ jnijava = shared_module( 'jnijava', - sources, + native_sources, dependencies : [jni_dep], include_directories : [native_header_includes] ) - -jnijava_dep = declare_dependency( - link_with : jnijava -) diff --git a/test cases/java/9 jni/lib/native.c b/test cases/java/9 jni/src/com/mesonbuild/native/native.c similarity index 100% rename from test cases/java/9 jni/lib/native.c rename to test cases/java/9 jni/src/com/mesonbuild/native/native.c diff --git a/test cases/java/9 jni/src/meson.build b/test cases/java/9 jni/src/meson.build index af443b517842..4c2461730673 100644 --- a/test cases/java/9 jni/src/meson.build +++ b/test cases/java/9 jni/src/meson.build @@ -6,4 +6,5 @@ jnijar = jar( 'jnijar', sources, main_class : 'com.mesonbuild.JniTest', + java_resources : structured_sources(jnijava) ) From 6a1bf5dd265bdae60187d36c2d8344cd0828f24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Wed, 17 Jul 2024 16:24:49 +0200 Subject: [PATCH 2/4] testcases/framework/libgcrypt: dont fail with missing libgcrypt-config libgcrypt 1.11.0 on Arch doesnt ship with libgcrypt-config anymore. It only provides libgcrypt.pc. --- test cases/frameworks/24 libgcrypt/meson.build | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test cases/frameworks/24 libgcrypt/meson.build b/test cases/frameworks/24 libgcrypt/meson.build index 5aadb13239e7..8febaef7455e 100644 --- a/test cases/frameworks/24 libgcrypt/meson.build +++ b/test cases/frameworks/24 libgcrypt/meson.build @@ -1,7 +1,8 @@ project('libgcrypt test', 'c') wm = find_program('libgcrypt-config', required : false) -if not wm.found() +dep = dependency('libgcrypt', method: 'pkg-config', required: false) +if not wm.found() and not dep.found() error('MESON_SKIP_TEST: libgcrypt-config not installed') endif @@ -15,9 +16,15 @@ test('libgcrypttest', e) # Test using the method keyword: -dependency('libgcrypt', method : 'config-tool') -dependency('libgcrypt', method : 'pkg-config', required: false) +lct = dependency('libgcrypt', method : 'config-tool', required: false) +pct = dependency('libgcrypt', method : 'pkg-config', required: false) +if not lct.found() and not pct.found() + error('libgcrypt not found') +endif # Check we can apply a version constraint -dependency('libgcrypt', version: '>=@0@'.format(libgcrypt_dep.version()), method: 'pkg-config', required: false) -dependency('libgcrypt', version: '>=@0@'.format(libgcrypt_dep.version()), method: 'config-tool') +lctv = dependency('libgcrypt', version: '>=@0@'.format(libgcrypt_dep.version()), method: 'pkg-config', required: false) +pctv = dependency('libgcrypt', version: '>=@0@'.format(libgcrypt_dep.version()), method: 'config-tool', required: false) +if not lct.found() and not pct.found() + error('libgcrypt version constraint not working as expected') +endif From 73f5c3952630cc83a3d5d81680e354d66bb9a128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Thu, 11 Jul 2024 11:55:44 +0200 Subject: [PATCH 3/4] ciimage/arch: don't force java to be 1.8 Parent introduced unit test (9 jni) that depends on at least java 9, thus causing the test to be skipped. --- ci/ciimage/arch/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/ciimage/arch/install.sh b/ci/ciimage/arch/install.sh index 76eb8cd37aeb..72f41043121a 100755 --- a/ci/ciimage/arch/install.sh +++ b/ci/ciimage/arch/install.sh @@ -11,7 +11,7 @@ pkgs=( ninja make git sudo fakeroot autoconf automake patch libelf gcc gcc-fortran gcc-objc vala rust bison flex cython go dlang-dmd mono boost qt5-base gtkmm3 gtest gmock protobuf gobject-introspection - itstool gtk3 java-environment=8 gtk-doc llvm clang sdl2 graphviz + itstool gtk3 java-environment gtk-doc llvm clang sdl2 graphviz doxygen vulkan-validation-layers openssh mercurial gtk-sharp-2 qt5-tools libwmf cmake netcdf-fortran openmpi nasm gnustep-base gettext python-lxml hotdoc rust-bindgen qt6-base qt6-tools wayland wayland-protocols From 2a3d050b9f008a48cfc8d5ccd50c790a15ff0fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20=22sp1rit=22=E2=80=8B?= Date: Wed, 17 Jul 2024 15:15:39 +0200 Subject: [PATCH 4/4] ciimage/arch: attempt to fix Arch CI --- ci/ciimage/arch/install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ci/ciimage/arch/install.sh b/ci/ciimage/arch/install.sh index 72f41043121a..41f90aa563fc 100755 --- a/ci/ciimage/arch/install.sh +++ b/ci/ciimage/arch/install.sh @@ -11,7 +11,7 @@ pkgs=( ninja make git sudo fakeroot autoconf automake patch libelf gcc gcc-fortran gcc-objc vala rust bison flex cython go dlang-dmd mono boost qt5-base gtkmm3 gtest gmock protobuf gobject-introspection - itstool gtk3 java-environment gtk-doc llvm clang sdl2 graphviz + itstool glib2 glib2-devel gtk3 java-environment gtk-doc llvm clang sdl2 graphviz doxygen vulkan-validation-layers openssh mercurial gtk-sharp-2 qt5-tools libwmf cmake netcdf-fortran openmpi nasm gnustep-base gettext python-lxml hotdoc rust-bindgen qt6-base qt6-tools wayland wayland-protocols @@ -25,9 +25,16 @@ AUR_USER=docker PACMAN_OPTS='--needed --noprogressbar --noconfirm' # Patch config files +pacman -Syu $PACMAN_OPTS ed sed -i 's/#Color/Color/g' /etc/pacman.conf sed -i 's,#MAKEFLAGS="-j2",MAKEFLAGS="-j$(nproc)",g' /etc/makepkg.conf sed -i "s,PKGEXT='.pkg.tar.zst',PKGEXT='.pkg.tar',g" /etc/makepkg.conf +ed /etc/makepkg.conf<