aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2022-03-29 13:52:03 +0200
committerEli Schwartz <eschwartz93@gmail.com>2022-05-03 02:00:29 -0400
commit3a960023d3e78d04651850178db96c7d742725e6 (patch)
tree6701f36e22752547c9041844d9c70ba301f3e4a1 /test cases
parent06b76f7c9d7bbe74450ed49316eaeae28dccda7d (diff)
downloadmeson-3a960023d3e78d04651850178db96c7d742725e6.zip
meson-3a960023d3e78d04651850178db96c7d742725e6.tar.gz
meson-3a960023d3e78d04651850178db96c7d742725e6.tar.bz2
interpreter: new function add_project_dependencies()
This function can be used to add fundamental dependencies such as glib to all build products in one fell swoop. This can be useful whenever, due to a project's coding conventions, it is not really possible to compile any source file without including the dependency. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/251 add_project_dependencies/inc/lib.h2
-rw-r--r--test cases/common/251 add_project_dependencies/lib.c14
-rw-r--r--test cases/common/251 add_project_dependencies/main.c5
-rw-r--r--test cases/common/251 add_project_dependencies/meson.build22
4 files changed, 43 insertions, 0 deletions
diff --git a/test cases/common/251 add_project_dependencies/inc/lib.h b/test cases/common/251 add_project_dependencies/inc/lib.h
new file mode 100644
index 0000000..ceca99f
--- /dev/null
+++ b/test cases/common/251 add_project_dependencies/inc/lib.h
@@ -0,0 +1,2 @@
+#pragma once
+extern int ok(void);
diff --git a/test cases/common/251 add_project_dependencies/lib.c b/test cases/common/251 add_project_dependencies/lib.c
new file mode 100644
index 0000000..ac46bfc
--- /dev/null
+++ b/test cases/common/251 add_project_dependencies/lib.c
@@ -0,0 +1,14 @@
+#include <zlib.h>
+#include <math.h>
+
+#ifndef DEFINED
+#error expected compile_arg not found
+#endif
+
+double zero;
+int ok(void) {
+ void * something = deflate;
+ if(something != 0)
+ return 0;
+ return (int)cos(zero);
+}
diff --git a/test cases/common/251 add_project_dependencies/main.c b/test cases/common/251 add_project_dependencies/main.c
new file mode 100644
index 0000000..93b7f72
--- /dev/null
+++ b/test cases/common/251 add_project_dependencies/main.c
@@ -0,0 +1,5 @@
+#include "lib.h"
+
+int main(void) {
+ return ok();
+}
diff --git a/test cases/common/251 add_project_dependencies/meson.build b/test cases/common/251 add_project_dependencies/meson.build
new file mode 100644
index 0000000..4047e6d
--- /dev/null
+++ b/test cases/common/251 add_project_dependencies/meson.build
@@ -0,0 +1,22 @@
+project('zlib system dependency', 'c')
+
+cc = meson.get_compiler('c')
+
+m = cc.find_library('m', required: false)
+add_project_dependencies(m, language: ['c'])
+
+z = dependency('zlib', method: 'system', required: false)
+if not z.found()
+ error('MESON_SKIP_TEST zlib not present')
+endif
+
+z_c_args = z.partial_dependency(compile_args: true, includes: true)
+add_project_dependencies(z_c_args, language: 'c', native: false)
+
+global_dep = declare_dependency(include_directories: include_directories('inc'),
+ compile_args: '-DDEFINED')
+add_project_dependencies(global_dep, language: 'c', native: false)
+
+lib = static_library('rary', 'lib.c')
+exe = executable('prog', 'main.c', link_with: lib, dependencies: z)
+test('test', exe)