aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/98 subproject subdir
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/98 subproject subdir')
-rw-r--r--meson/test cases/common/98 subproject subdir/meson.build67
-rw-r--r--meson/test cases/common/98 subproject subdir/prog.c5
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub/lib/meson.build3
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.c5
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.h6
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub/meson.build2
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit.wrap6
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson.build13
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson_options.txt1
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/foo.h1
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/meson.build7
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/packagefiles/subsubsub-1.0.zipbin0 -> 455 bytes
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/subsubsub.wrap4
-rw-r--r--meson/test cases/common/98 subproject subdir/subprojects/sub_novar/meson.build4
-rw-r--r--meson/test cases/common/98 subproject subdir/test.json5
15 files changed, 129 insertions, 0 deletions
diff --git a/meson/test cases/common/98 subproject subdir/meson.build b/meson/test cases/common/98 subproject subdir/meson.build
new file mode 100644
index 000000000..6c3811f3f
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/meson.build
@@ -0,0 +1,67 @@
+project('proj', 'c')
+subproject('sub')
+libSub = dependency('sub', fallback: ['sub', 'libSub'])
+
+exe = executable('prog', 'prog.c', dependencies: libSub)
+test('subproject subdir', exe)
+
+# Verify the subproject has placed dependency override.
+dependency('sub-1.0')
+
+# Verify we can now take 'sub' dependency without fallback, but only version 1.0.
+dependency('sub')
+d = dependency('sub', version : '>=2.0', required : false)
+assert(not d.found(), 'version should not match')
+
+# Verify that not-found does not get cached, we can still fallback afterward.
+dependency('sub2', required : false)
+d = dependency('sub2', fallback: ['sub', 'libSub'])
+assert(d.found(), 'Should fallback even if a previous call returned not-found')
+
+# Verify we can get a fallback dependency without specifying the variable name,
+# because the subproject overridden 'sub-novar'.
+dependency('sub-novar', fallback : 'sub_novar')
+
+# Verify a subproject can force a dependency to be not-found
+d = dependency('sub-notfound', fallback : 'sub_novar', required : false)
+assert(not d.found(), 'Dependency should be not-found')
+
+# Verify that implicit fallback works because subprojects/sub_implicit directory exists
+d = dependency('sub_implicit', default_options: 'opt=overriden')
+assert(d.found(), 'Should implicitly fallback')
+
+# Verify that implicit fallback works because sub_implicit.wrap has
+# `dependency_names=sub_implicit_provide1` and the subproject overrides sub_implicit_provide1.
+d = dependency('sub_implicit_provide1')
+assert(d.found(), 'Should implicitly fallback')
+
+# Verify that implicit fallback works because sub_implicit.wrap has
+# `sub_implicit_provide2=sub_implicit_provide2_dep` and does not override
+# sub_implicit_provide2.
+d = dependency('sub_implicit_provide2')
+assert(d.found(), 'Should implicitly fallback')
+
+# sub_implicit.wrap provides glib-2.0 and we already configured that subproject,
+# so we must not return the system dependency here. Using glib-2.0 here because
+# some CI runners have it installed.
+d = dependency('glib-2.0', required : false)
+assert(d.found())
+assert(d.type_name() == 'internal')
+
+# sub_implicit.wrap provides gobject-2.0 and we already configured that subproject,
+# so we must not return the system dependency here. But since the subproject did
+# not override that dependency and its not required, not-found should be returned.
+# Using gobject-2.0 here because some CI runners have it installed.
+d = dependency('gobject-2.0', required : false)
+assert(not d.found())
+
+# Verify that implicit fallback works because subprojects/sub_implicit/subprojects/subsub
+# directory exists.
+d = dependency('subsub')
+assert(d.found(), 'Should be able to fallback to sub-subproject')
+
+# Verify that implicit fallback works because
+# subprojects/sub_implicit/subprojects/subsub/subprojects/subsubsub.wrap
+# file exists.
+d = dependency('subsubsub')
+assert(d.found(), 'Should be able to fallback to sub-sub-subproject')
diff --git a/meson/test cases/common/98 subproject subdir/prog.c b/meson/test cases/common/98 subproject subdir/prog.c
new file mode 100644
index 000000000..9035ff114
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/prog.c
@@ -0,0 +1,5 @@
+#include <sub.h>
+
+int main(void) {
+ return sub();
+}
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/meson.build b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/meson.build
new file mode 100644
index 000000000..53233ab4e
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/meson.build
@@ -0,0 +1,3 @@
+lib = static_library('sub', 'sub.c')
+libSub = declare_dependency(include_directories: include_directories('.'), link_with: lib)
+meson.override_dependency('sub-1.0', libSub)
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.c b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.c
new file mode 100644
index 000000000..e748ac750
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.c
@@ -0,0 +1,5 @@
+#include "sub.h"
+
+int sub(void) {
+ return 0;
+}
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.h b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.h
new file mode 100644
index 000000000..2b59a3a32
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub/lib/sub.h
@@ -0,0 +1,6 @@
+#ifndef SUB_H
+#define SUB_H
+
+int sub(void);
+
+#endif
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub/meson.build b/meson/test cases/common/98 subproject subdir/subprojects/sub/meson.build
new file mode 100644
index 000000000..d8c4dce70
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub/meson.build
@@ -0,0 +1,2 @@
+project('sub', 'c', version : '1.0')
+subdir('lib')
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit.wrap b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit.wrap
new file mode 100644
index 000000000..a809c43b1
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit.wrap
@@ -0,0 +1,6 @@
+[wrap-file]
+
+[provide]
+glib-2.0 = glib_dep
+dependency_names = sub_implicit_provide1, gobject-2.0
+sub_implicit_provide2 = sub_implicit_provide2_dep
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson.build b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson.build
new file mode 100644
index 000000000..9f436042f
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson.build
@@ -0,0 +1,13 @@
+project('sub_implicit', 'c', version : '1.0')
+
+dep = declare_dependency()
+meson.override_dependency('sub_implicit', dep)
+meson.override_dependency('sub_implicit_provide1', dep)
+
+# This one is not overridden but the wrap file tells the variable name to use.
+sub_implicit_provide2_dep = dep
+
+# This one is not overridden but the wrap file tells the variable name to use.
+glib_dep = dep
+
+assert(get_option('opt') == 'overriden') \ No newline at end of file
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson_options.txt b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson_options.txt
new file mode 100644
index 000000000..770178ce7
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/meson_options.txt
@@ -0,0 +1 @@
+option('opt', type: 'string', value: 'default') \ No newline at end of file
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/foo.h b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/foo.h
new file mode 100644
index 000000000..a8ad3daba
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/foo.h
@@ -0,0 +1 @@
+#define DUMMY 42
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/meson.build b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/meson.build
new file mode 100644
index 000000000..fdbb03fe6
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/meson.build
@@ -0,0 +1,7 @@
+project('subsub')
+
+meson.override_dependency('subsub', declare_dependency())
+
+# Regression test: Installing a header from nested sub-subproject used to raise:
+# ERROR: Sandbox violation: Tried to grab file foo.h from a nested subproject.
+install_headers('foo.h')
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/packagefiles/subsubsub-1.0.zip b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/packagefiles/subsubsub-1.0.zip
new file mode 100644
index 000000000..dfb7576f3
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/packagefiles/subsubsub-1.0.zip
Binary files differ
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/subsubsub.wrap b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/subsubsub.wrap
new file mode 100644
index 000000000..6567ed010
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_implicit/subprojects/subsub/subprojects/subsubsub.wrap
@@ -0,0 +1,4 @@
+[wrap-file]
+directory = subsubsub-1.0
+source_filename = subsubsub-1.0.zip
+source_hash = c073a96b7251937e53216578f6f03d91b84816618a0f1ce3ecfb867beddf1498
diff --git a/meson/test cases/common/98 subproject subdir/subprojects/sub_novar/meson.build b/meson/test cases/common/98 subproject subdir/subprojects/sub_novar/meson.build
new file mode 100644
index 000000000..6450a1032
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/subprojects/sub_novar/meson.build
@@ -0,0 +1,4 @@
+project('sub-novar', 'c', version : '1.0')
+
+meson.override_dependency('sub-novar', declare_dependency())
+meson.override_dependency('sub-notfound', dependency('', required : false))
diff --git a/meson/test cases/common/98 subproject subdir/test.json b/meson/test cases/common/98 subproject subdir/test.json
new file mode 100644
index 000000000..1921fe559
--- /dev/null
+++ b/meson/test cases/common/98 subproject subdir/test.json
@@ -0,0 +1,5 @@
+{
+ "installed": [
+ { "type": "file", "file": "usr/include/foo.h" }
+ ]
+}