fix: noconfirm auto-selects first AUR match

This commit is contained in:
2026-05-08 11:01:02 +01:00
parent d39cdc3fd9
commit 153cca6132
8056 changed files with 1983098 additions and 779 deletions
@@ -0,0 +1,7 @@
package com.mesonbuild;
class Simple {
public static void main(String [] args) {
System.out.println("Java is working.\n");
}
}
@@ -0,0 +1,11 @@
project('simplejava', 'java')
javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
main_class : 'com.mesonbuild.Simple',
install : true,
install_dir : get_option('bindir'))
test('mytest', javaprog)
jc = meson.get_compiler('java')
message(jc.get_id())
message(jc.get_linker_id())
@@ -0,0 +1,5 @@
{
"installed": [
{"type": "file", "file": "usr/bin/myprog.jar"}
]
}
@@ -0,0 +1,7 @@
project('resources', ['java'])
if meson.backend() != 'ninja'
error('MESON_SKIP_TEST: only valid on backends which support jar()')
endif
subdir('src')
@@ -0,0 +1,26 @@
package com.mesonbuild;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public class Resources {
public static void main(String[] args) throws IOException {
try (InputStreamReader reader = new InputStreamReader(
Resources.class.getResourceAsStream("/resource1.txt"),
StandardCharsets.UTF_8)) {
final BufferedReader buffered = new BufferedReader(reader);
assert buffered.readLine() == "1";
}
try (InputStreamReader reader = new InputStreamReader(
Resources.class.getResourceAsStream("/subdir/resource2.txt"),
StandardCharsets.UTF_8)) {
final BufferedReader buffered = new BufferedReader(reader);
assert buffered.readLine() == "2";
}
}
}
@@ -0,0 +1,13 @@
sources = files('com/mesonbuild/Resources.java')
resources = jar(
meson.project_name(),
sources,
main_class: 'com.mesonbuild.Resources',
java_resources: structured_sources(
files('resources/resource1.txt'),
{
'subdir': files('resources/subdir/resource2.txt'),
}
)
)
@@ -0,0 +1,3 @@
project('subdirjava', 'java')
subdir('sub')
@@ -0,0 +1,8 @@
package com.mesonbuild;
class Simple {
public static void main(String [] args) {
TextPrinter t = new TextPrinter("Printing from Java.");
t.print();
}
}
@@ -0,0 +1,14 @@
package com.mesonbuild;
class TextPrinter {
private String msg;
TextPrinter(String s) {
msg = s;
}
public void print() {
System.out.println(msg);
}
}
@@ -0,0 +1,5 @@
javaprog = jar('myprog',
'com/mesonbuild/Simple.java',
'com/mesonbuild/TextPrinter.java',
main_class : 'com.mesonbuild.Simple')
test('subdirtest', javaprog)
@@ -0,0 +1,7 @@
package com.mesonbuild;
class Simple {
public static void main(String [] args) {
System.out.println("Java is working.\n");
}
}
@@ -0,0 +1,8 @@
project('simplejava', 'java')
add_project_arguments('-target', '1.8', language : 'java')
javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
main_class : 'com.mesonbuild.Simple',
java_args : ['-source', '1.8'])
test('mytest', javaprog)
@@ -0,0 +1,15 @@
package com.mesonbuild;
class Simple {
class Inner {
public String getString() {
return "Inner class is working.\n";
}
}
public static void main(String [] args) {
Simple s = new Simple();
Simple.Inner ic = s.new Inner();
System.out.println(ic.getString());
}
}
@@ -0,0 +1,5 @@
project('simplejava', 'java')
javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
main_class : 'com.mesonbuild.Simple')
test('mytest', javaprog)
@@ -0,0 +1,8 @@
package com.mesonbuild;
class Simple {
public static void main(String [] args) {
TextPrinter t = new TextPrinter("Printing from Java.");
t.print();
}
}
@@ -0,0 +1,14 @@
package com.mesonbuild;
class TextPrinter {
private String msg;
TextPrinter(String s) {
msg = s;
}
public void print() {
System.out.println(msg);
}
}
@@ -0,0 +1,14 @@
# The Ninja backend used to try and pass -sourcepath repeatedly for
# multiple includes which would discard prior includes. Since this
# won't compile without the '.' include, this ensures that multiple
# paths are passed in a [semi-]colon separated list instead...
project('includedirsjava', 'java')
javaprog = jar('myprog',
'com/mesonbuild/Simple.java',
'com/mesonbuild/TextPrinter.java',
main_class : 'com.mesonbuild.Simple',
include_directories : [ include_directories('com'),
include_directories('com/mesonbuild') ])
test('subdirtest', javaprog)
@@ -0,0 +1,5 @@
package com.mesonbuild;
public class Config {
public static final boolean FOOBAR = @foobar@;
}
@@ -0,0 +1,12 @@
package com.mesonbuild;
import com.mesonbuild.Config;
class Simple {
public static void main(String [] args) {
if (Config.FOOBAR) {
TextPrinter t = new TextPrinter("Printing from Java.");
t.print();
}
}
}
@@ -0,0 +1,14 @@
package com.mesonbuild;
class TextPrinter {
private String msg;
TextPrinter(String s) {
msg = s;
}
public void print() {
System.out.println(msg);
}
}
@@ -0,0 +1,6 @@
conf_data = configuration_data()
conf_data.set('foobar', 'true')
config_file = configure_file(input : 'Config.java.in',
output : 'Config.java',
configuration : conf_data)
@@ -0,0 +1,15 @@
# If we generate code under the build directory then the backend needs to add
# the build directory to the -sourcepath passed to javac otherwise the compiler
# won't be able to handle the -implicit:class behaviour of automatically
# compiling dependency classes.
project('codegenjava', 'java')
subdir('com/mesonbuild')
javaprog = jar('myprog',
config_file,
'com/mesonbuild/Simple.java',
'com/mesonbuild/TextPrinter.java',
main_class : 'com.mesonbuild.Simple')
test('subdirtest', javaprog)
@@ -0,0 +1,9 @@
package com.mesonbuild;
import com.mesonbuild.SimpleLib;
class Linking {
public static void main(String [] args) {
SimpleLib.func();
}
}
@@ -0,0 +1,8 @@
project('linkingjava', 'java')
subdir('sub')
javaprog = jar('myprog', 'com/mesonbuild/Linking.java',
main_class : 'com.mesonbuild.Linking',
link_with : simplelib)
test('mytest', javaprog)
@@ -0,0 +1,7 @@
package com.mesonbuild;
public class SimpleLib {
public static void func() {
System.out.println("Java linking is working.\n");
}
}
@@ -0,0 +1,2 @@
simplelib = jar('simplelib',
'com/mesonbuild/SimpleLib.java')
@@ -0,0 +1,5 @@
package com.mesonbuild;
public class Config {
public static final boolean FOOBAR = true;
}
@@ -0,0 +1,12 @@
package com.mesonbuild;
import com.mesonbuild.Config;
class Simple {
public static void main(String [] args) {
if (Config.FOOBAR) {
TextPrinter t = new TextPrinter("Printing from Java.");
t.print();
}
}
}
@@ -0,0 +1,14 @@
package com.mesonbuild;
class TextPrinter {
private String msg;
TextPrinter(String s) {
msg = s;
}
public void print() {
System.out.println(msg);
}
}
@@ -0,0 +1,8 @@
python = find_program('python3')
config_file = custom_target('confgen',
input : 'Config.java.in',
output : 'Config.java',
command : [python, '-c',
'import shutil, sys, time; time.sleep(1); shutil.copy(sys.argv[1], sys.argv[2])',
'@INPUT@', '@OUTPUT@'])
@@ -0,0 +1,15 @@
# If we generate code under the build directory then the backend needs to add
# the build directory to the -sourcepath passed to javac otherwise the compiler
# won't be able to handle the -implicit:class behaviour of automatically
# compiling dependency classes.
project('codegenjava', 'java')
subdir('com/mesonbuild')
javaprog = jar('myprog',
config_file[0],
'com/mesonbuild/Simple.java',
'com/mesonbuild/TextPrinter.java',
main_class : 'com.mesonbuild.Simple')
test('subdirtest', javaprog)
@@ -0,0 +1,9 @@
#include <jni.h>
#include "com_mesonbuild_JniTest.h"
JNIEXPORT jint JNICALL Java_com_mesonbuild_JniTest_jni_1test
(JNIEnv *env, jclass clazz)
{
return (jint)0xdeadbeef;
}
@@ -0,0 +1,18 @@
sources = [
files(
'native.c',
'com_mesonbuild_JniTest.c',
),
native_headers
]
jnijava = shared_module(
'jnijava',
sources,
dependencies : [jni_dep],
include_directories : [native_header_includes]
)
jnijava_dep = declare_dependency(
link_with : jnijava
)
@@ -0,0 +1,11 @@
#include <jni.h>
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved)
{
return JNI_VERSION_1_8;
}
JNIEXPORT void JNICALL
JNI_OnUnload(JavaVM *vm, void *reserved)
{}
@@ -0,0 +1,38 @@
project('jnijava', ['c', 'java'])
if build_machine.system() == 'cygwin'
error('MESON_SKIP_TEST: cygwin test failures')
endif
if build_machine.system() == 'windows' and build_machine.cpu_family() == 'x86'
error('MESON_SKIP_TEST: failing builds on 32bit Windows because a 32bit JDK is not available in the Azure Pipelines Windows images')
endif
fs = import('fs')
javamod = import('java')
cc = meson.get_compiler('c')
java = find_program('java')
jni_dep = dependency('jni', version : '>=1.8', modules: ['jvm', 'awt'])
# Assert that the header can actually be found with the dependency.
cc.has_header('jni.h', dependencies: [jni_dep])
# Assert that the platform-specific include directory is included in the compiler arguments.
cc.has_header('jni_md.h', dependencies: [jni_dep])
# 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],
)
@@ -0,0 +1,5 @@
package com.mesonbuild;
public final class Configured {
public static final int FINGERPRINT = @fingerprint@;
}
@@ -0,0 +1,15 @@
package com.mesonbuild;
public final class JniTest {
private static native int jni_test();
public static void main(String[] args) {
if (jni_test() != Configured.FINGERPRINT) {
throw new RuntimeException("jdk_test() did not return 0");
}
}
static {
System.loadLibrary("jnijava");
}
}
@@ -0,0 +1,11 @@
configured = configure_file(
input: files('Configured.java.in'),
output: 'Configured.java',
configuration: configuration_data({'fingerprint': '0xdeadbeef'})
)
sources += configured
native_headers = javamod.native_headers(
sources, package: 'com.mesonbuild', classes: ['JniTest'])
native_header_includes = include_directories('.')
@@ -0,0 +1,9 @@
sources = [files('com/mesonbuild/JniTest.java')]
subdir('com/mesonbuild')
jnijar = jar(
'jnijar',
sources,
main_class : 'com.mesonbuild.JniTest',
)