Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structured_sources: Allow build_tgt to be added as source #13351

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ci/ciimage/arch/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand All @@ -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<<EOF
/^OPTIONS=/
s/debug/!debug/
w
q
EOF

# Install packages
pacman -Syu $PACMAN_OPTS "${pkgs[@]}"
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
17 changes: 12 additions & 5 deletions test cases/frameworks/24 libgcrypt/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
9 changes: 4 additions & 5 deletions test cases/java/9 jni/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
36 changes: 32 additions & 4 deletions test cases/java/9 jni/src/com/mesonbuild/JniTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
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) {
if (jni_test() != Configured.FINGERPRINT) {
throw new RuntimeException("jdk_test() did not return 0");
}
}

static {
System.loadLibrary("jnijava");
}
}
2 changes: 2 additions & 0 deletions test cases/java/9 jni/src/com/mesonbuild/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ sources += configured
native_headers = javamod.native_headers(
sources, package: 'com.mesonbuild', classes: ['JniTest'])
native_header_includes = include_directories('.')

subdir('native')
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources = [
native_sources = [
files(
'native.c',
'com_mesonbuild_JniTest.c',
Expand All @@ -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
)
1 change: 1 addition & 0 deletions test cases/java/9 jni/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ jnijar = jar(
'jnijar',
sources,
main_class : 'com.mesonbuild.JniTest',
java_resources : structured_sources(jnijava)
)
Loading