aboutsummaryrefslogtreecommitdiff
path: root/test cases/unit/17 prebuilt shared
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-11-08 13:43:58 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2021-11-24 02:23:57 +0530
commitbd9d9818711eaba18b774e17c9ce405c5020c6f9 (patch)
tree47cc4426a2889fa8f97a193591c99611b9ab1b3c /test cases/unit/17 prebuilt shared
parent73bac14c8fe7279037433b15b6c15bc93e9156a1 (diff)
downloadmeson-bd9d9818711eaba18b774e17c9ce405c5020c6f9.zip
meson-bd9d9818711eaba18b774e17c9ce405c5020c6f9.tar.gz
meson-bd9d9818711eaba18b774e17c9ce405c5020c6f9.tar.bz2
unit tests: Extend prebuilt test to test intermediate
This provides coverage for the bug: https://github.com/mesonbuild/meson/issues/9542
Diffstat (limited to 'test cases/unit/17 prebuilt shared')
-rw-r--r--test cases/unit/17 prebuilt shared/meson.build27
-rw-r--r--test cases/unit/17 prebuilt shared/meson_options.txt1
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.c8
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.h6
-rw-r--r--test cases/unit/17 prebuilt shared/rejected_main.c6
5 files changed, 47 insertions, 1 deletions
diff --git a/test cases/unit/17 prebuilt shared/meson.build b/test cases/unit/17 prebuilt shared/meson.build
index 9a4eca0..7badcb7 100644
--- a/test cases/unit/17 prebuilt shared/meson.build
+++ b/test cases/unit/17 prebuilt shared/meson.build
@@ -1,7 +1,12 @@
project('prebuilt shared library', 'c')
+search_dir = get_option('search_dir')
+if search_dir == 'auto'
+ search_dir = meson.current_source_dir()
+endif
+
cc = meson.get_compiler('c')
-shlib = cc.find_library('alexandria', dirs : meson.current_source_dir())
+shlib = cc.find_library('alexandria', dirs : search_dir)
exe = executable('patron', 'patron.c', dependencies : shlib)
test('visitation', exe)
@@ -11,3 +16,23 @@ d = declare_dependency(dependencies : shlib)
exe2 = executable('another_visitor', 'another_visitor.c',
dependencies : d)
test('another', exe2)
+
+stlib = static_library(
+ 'rejected',
+ 'rejected.c',
+ dependencies : shlib,
+)
+
+rejected = executable(
+ 'rejected',
+ 'rejected_main.c',
+ link_with : stlib,
+)
+test('rejected', rejected)
+
+rejected_whole = executable(
+ 'rejected_whole',
+ 'rejected_main.c',
+ link_whole : stlib,
+)
+test('rejected (whole archive)', rejected_whole)
diff --git a/test cases/unit/17 prebuilt shared/meson_options.txt b/test cases/unit/17 prebuilt shared/meson_options.txt
new file mode 100644
index 0000000..7876a6f
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/meson_options.txt
@@ -0,0 +1 @@
+option('search_dir', type : 'string', value : 'auto')
diff --git a/test cases/unit/17 prebuilt shared/rejected.c b/test cases/unit/17 prebuilt shared/rejected.c
new file mode 100644
index 0000000..9d7ac94
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.c
@@ -0,0 +1,8 @@
+#include "rejected.h"
+
+void say(void) {
+ printf("You are standing outside the Great Library of Alexandria.\n");
+ printf("You decide to go inside.\n\n");
+ alexandria_visit();
+ printf("The librarian tells you it's time to leave\n");
+}
diff --git a/test cases/unit/17 prebuilt shared/rejected.h b/test cases/unit/17 prebuilt shared/rejected.h
new file mode 100644
index 0000000..b9ccf31
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.h
@@ -0,0 +1,6 @@
+#include <stdio.h>
+#include <alexandria.h>
+
+#pragma once
+
+void say(void);
diff --git a/test cases/unit/17 prebuilt shared/rejected_main.c b/test cases/unit/17 prebuilt shared/rejected_main.c
new file mode 100644
index 0000000..4d35061
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected_main.c
@@ -0,0 +1,6 @@
+#include "rejected.h"
+
+int main(void) {
+ say();
+ return 0;
+}