From 3eb90414f62f857abbb1c62e8e4c823b7b1473e6 Mon Sep 17 00:00:00 2001 From: Matthias Klumpp Date: Fri, 19 Aug 2016 03:03:35 +0200 Subject: [PATCH] Add testcase for mixed C and D compilation --- test cases/d/3 mixed/app.d | 8 ++++++++ test cases/d/3 mixed/installed_files.txt | 4 ++++ test cases/d/3 mixed/libstuff.c | 18 ++++++++++++++++++ test cases/d/3 mixed/meson.build | 9 +++++++++ 4 files changed, 39 insertions(+) create mode 100644 test cases/d/3 mixed/app.d create mode 100644 test cases/d/3 mixed/installed_files.txt create mode 100644 test cases/d/3 mixed/libstuff.c create mode 100644 test cases/d/3 mixed/meson.build diff --git a/test cases/d/3 mixed/app.d b/test cases/d/3 mixed/app.d new file mode 100644 index 000000000..6ab5d97d6 --- /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 000000000..9e7fccc9a --- /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 000000000..92d6600ce --- /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 + +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 000000000..3dad66d0c --- /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)