diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-10-04 00:07:44 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-09-13 13:54:47 -0400 |
commit | 9d338200dacdf24c50259c309380200f8a53d5b5 (patch) | |
tree | 8e268a9357119265f11b30791f56e8e09fec393e /test cases/common | |
parent | 19696c3dcdb379f4c5b88457f43242f2d33427a0 (diff) | |
download | meson-9d338200dacdf24c50259c309380200f8a53d5b5.zip meson-9d338200dacdf24c50259c309380200f8a53d5b5.tar.gz meson-9d338200dacdf24c50259c309380200f8a53d5b5.tar.bz2 |
external-project: New module to build configure/make projects
This adds an experimental meson module to build projects with other
build systems.
Closes: #4316
Diffstat (limited to 'test cases/common')
9 files changed, 126 insertions, 0 deletions
diff --git a/test cases/common/236 external project/app.c b/test cases/common/236 external project/app.c new file mode 100644 index 0000000..166f007 --- /dev/null +++ b/test cases/common/236 external project/app.c @@ -0,0 +1,7 @@ +#include <libfoo.h> + +int main(void) +{ + return call_foo() == 42 ? 0 : 1; +} + diff --git a/test cases/common/236 external project/func.c b/test cases/common/236 external project/func.c new file mode 100644 index 0000000..5e8f933 --- /dev/null +++ b/test cases/common/236 external project/func.c @@ -0,0 +1,7 @@ +#include "func.h" + +int func(void) +{ + return 1; +} + diff --git a/test cases/common/236 external project/func.h b/test cases/common/236 external project/func.h new file mode 100644 index 0000000..340b82a --- /dev/null +++ b/test cases/common/236 external project/func.h @@ -0,0 +1 @@ +int func(void); diff --git a/test cases/common/236 external project/libfoo/configure b/test cases/common/236 external project/libfoo/configure new file mode 100755 index 0000000..a867b48 --- /dev/null +++ b/test cases/common/236 external project/libfoo/configure @@ -0,0 +1,44 @@ +#! /bin/sh + +srcdir=$(dirname "$0") + +for i in "$@" +do +case $i in + --prefix=*) + PREFIX="${i#*=}" + shift + ;; + --libdir=*) + LIBDIR="${i#*=}" + shift + ;; + --includedir=*) + INCDIR="${i#*=}" + shift + ;; + --libext=*) + LIBEXT="${i#*=}" + shift + ;; + *) + shift + ;; +esac +done + +DEP_ARGS=$(pkg-config somelib --cflags --libs) + +cat > Makefile << EOL +all: libfoo.$LIBEXT + +libfoo.$LIBEXT: + $CC "$srcdir/libfoo.c" -shared -fPIC $DEP_ARGS -o \$@ + +install: libfoo.$LIBEXT + mkdir -p "\$(DESTDIR)$LIBDIR"; + mkdir -p "\$(DESTDIR)$LIBDIR/pkgconfig"; + mkdir -p "\$(DESTDIR)$INCDIR"; + cp \$< "\$(DESTDIR)$LIBDIR"; + cp "$srcdir/libfoo.h" "\$(DESTDIR)$INCDIR"; +EOL diff --git a/test cases/common/236 external project/libfoo/libfoo.c b/test cases/common/236 external project/libfoo/libfoo.c new file mode 100644 index 0000000..3f62282 --- /dev/null +++ b/test cases/common/236 external project/libfoo/libfoo.c @@ -0,0 +1,8 @@ +#include "libfoo.h" + +int func(void); + +int call_foo() +{ + return func() == 1 ? 42 : 0; +} diff --git a/test cases/common/236 external project/libfoo/libfoo.h b/test cases/common/236 external project/libfoo/libfoo.h new file mode 100644 index 0000000..8981f18 --- /dev/null +++ b/test cases/common/236 external project/libfoo/libfoo.h @@ -0,0 +1,3 @@ +#pragma once + +int call_foo(void); diff --git a/test cases/common/236 external project/libfoo/meson.build b/test cases/common/236 external project/libfoo/meson.build new file mode 100644 index 0000000..941e13f --- /dev/null +++ b/test cases/common/236 external project/libfoo/meson.build @@ -0,0 +1,22 @@ +mod = import('unstable_external_project') + +target_system = target_machine.system() +if target_system in ['windows', 'cygwin'] + libext = 'dll' +elif target_system == 'darwin' + libext = 'dylib' +else + libext = 'so' +endif + +p = mod.add_project('configure', + configure_options : [ + '--prefix=@PREFIX@', + '--libdir=@PREFIX@/@LIBDIR@', + '--includedir=@PREFIX@/@INCLUDEDIR@', + '--libext=' + libext, + ], +) + +libfoo_dep = declare_dependency(link_with : somelib, + dependencies : p.dependency('foo')) diff --git a/test cases/common/236 external project/meson.build b/test cases/common/236 external project/meson.build new file mode 100644 index 0000000..d1ed797 --- /dev/null +++ b/test cases/common/236 external project/meson.build @@ -0,0 +1,27 @@ +project('test external project', 'c') + +if not find_program('pkg-config', required: false).found() + error('MESON_SKIP_TEST: pkg-config not found') +endif + +if not find_program('make', required : false).found() + error('MESON_SKIP_TEST: make not found') +endif + +if host_machine.system() == 'windows' + error('MESON_SKIP_TEST: The fake configure script is too dumb to work on Windows') +endif + +if meson.is_cross_build() + # CI uses PKG_CONFIG_SYSROOT_DIR which breaks -uninstalled.pc usage. + error('MESON_SKIP_TEST: Cross build support is too limited for this test') +endif + +pkg = import('pkgconfig') + +somelib = library('somelib', 'func.c') +pkg.generate(somelib) + +subdir('libfoo') + +executable('test-find-library', 'app.c', dependencies : libfoo_dep) diff --git a/test cases/common/236 external project/test.json b/test cases/common/236 external project/test.json new file mode 100644 index 0000000..4888e87 --- /dev/null +++ b/test cases/common/236 external project/test.json @@ -0,0 +1,7 @@ +{ + "installed": [ + { "type": "shared_lib", "file": "usr/lib/foo" }, + { "type": "file", "file": "usr/include/libfoo.h" }, + { "type": "file", "file": "usr/lib/pkgconfig/somelib.pc" } + ] +} |