aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Klumpp <matthias@tenstral.net>2016-08-19 03:03:35 +0200
committerMatthias Klumpp <matthias@tenstral.net>2016-08-19 03:03:35 +0200
commit3eb90414f62f857abbb1c62e8e4c823b7b1473e6 (patch)
treef9597eb38127e1e58778bd3e4297a65c772df3c8
parent56823272ab96892e4f6c8dd86842d8c930281209 (diff)
downloadmeson-3eb90414f62f857abbb1c62e8e4c823b7b1473e6.zip
meson-3eb90414f62f857abbb1c62e8e4c823b7b1473e6.tar.gz
meson-3eb90414f62f857abbb1c62e8e4c823b7b1473e6.tar.bz2
Add testcase for mixed C and D compilation
-rw-r--r--test cases/d/3 mixed/app.d8
-rw-r--r--test cases/d/3 mixed/installed_files.txt4
-rw-r--r--test cases/d/3 mixed/libstuff.c18
-rw-r--r--test cases/d/3 mixed/meson.build9
4 files changed, 39 insertions, 0 deletions
diff --git a/test cases/d/3 mixed/app.d b/test cases/d/3 mixed/app.d
new file mode 100644
index 0000000..6ab5d97
--- /dev/null
+++ b/test cases/d/3 mixed/app.d
@@ -0,0 +1,8 @@
+
+extern(C) int printLibraryString(const char *str);
+
+void main ()
+{
+ immutable ret = printLibraryString ("C foo");
+ assert (ret == 3);
+}
diff --git a/test cases/d/3 mixed/installed_files.txt b/test cases/d/3 mixed/installed_files.txt
new file mode 100644
index 0000000..9e7fccc
--- /dev/null
+++ b/test cases/d/3 mixed/installed_files.txt
@@ -0,0 +1,4 @@
+usr/bin/appdc_d?exe
+usr/lib/libstuff.so
+usr/bin/appdc_s?exe
+usr/lib/libstuff.a
diff --git a/test cases/d/3 mixed/libstuff.c b/test cases/d/3 mixed/libstuff.c
new file mode 100644
index 0000000..92d6600
--- /dev/null
+++ b/test cases/d/3 mixed/libstuff.c
@@ -0,0 +1,18 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_PUBLIC __declspec(dllexport)
+#else
+ #if defined __GNUC__
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
+ #else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define DLL_PUBLIC
+ #endif
+#endif
+
+#include <stdio.h>
+
+int DLL_PUBLIC printLibraryString(const char *str)
+{
+ printf("C library says: %s", str);
+ return 3;
+}
diff --git a/test cases/d/3 mixed/meson.build b/test cases/d/3 mixed/meson.build
new file mode 100644
index 0000000..3dad66d
--- /dev/null
+++ b/test cases/d/3 mixed/meson.build
@@ -0,0 +1,9 @@
+project('Mixing C and D', 'd', 'c')
+
+ldyn = shared_library('stuff', 'libstuff.c', install : true)
+ed = executable('appdc_d', 'app.d', link_with : ldyn, install : true)
+test('linktest_cdyn', ed)
+
+lstatic = static_library('stuff', 'libstuff.c', install : true)
+es = executable('appdc_s', 'app.d', link_with : lstatic, install : true)
+test('linktest_cstatic', es)