summaryrefslogtreecommitdiffstats
path: root/test cases/d/5 mixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/d/5 mixed
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--test cases/d/5 mixed/app.d8
-rw-r--r--test cases/d/5 mixed/libstuff.c18
-rw-r--r--test cases/d/5 mixed/meson.build9
-rw-r--r--test cases/d/5 mixed/test.json13
4 files changed, 48 insertions, 0 deletions
diff --git a/test cases/d/5 mixed/app.d b/test cases/d/5 mixed/app.d
new file mode 100644
index 0000000..6ab5d97
--- /dev/null
+++ b/test cases/d/5 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/5 mixed/libstuff.c b/test cases/d/5 mixed/libstuff.c
new file mode 100644
index 0000000..92d6600
--- /dev/null
+++ b/test cases/d/5 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/5 mixed/meson.build b/test cases/d/5 mixed/meson.build
new file mode 100644
index 0000000..3dad66d
--- /dev/null
+++ b/test cases/d/5 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)
diff --git a/test cases/d/5 mixed/test.json b/test cases/d/5 mixed/test.json
new file mode 100644
index 0000000..c95d0ca
--- /dev/null
+++ b/test cases/d/5 mixed/test.json
@@ -0,0 +1,13 @@
+{
+ "installed": [
+ {"type": "exe", "file": "usr/bin/appdc_d"},
+ {"type": "pdb", "file": "usr/bin/appdc_d", "language": "d"},
+ {"type": "exe", "file": "usr/bin/appdc_s"},
+ {"type": "pdb", "file": "usr/bin/appdc_s", "language": "d"},
+ {"type": "file", "file": "usr/lib/libstuff.a"},
+ {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/stuff"},
+ {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/stuff"},
+ {"type": "pdb", "file": "usr/bin/stuff", "language": "c"},
+ {"type": "file", "platform": "msvc", "file": "usr/lib/stuff.lib"}
+ ]
+}