aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/6 linkshared
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/common/6 linkshared
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/common/6 linkshared')
-rw-r--r--meson/test cases/common/6 linkshared/cpplib.cpp6
-rw-r--r--meson/test cases/common/6 linkshared/cpplib.h12
-rw-r--r--meson/test cases/common/6 linkshared/cppmain.cpp5
-rw-r--r--meson/test cases/common/6 linkshared/libfile.c14
-rw-r--r--meson/test cases/common/6 linkshared/main.c11
-rw-r--r--meson/test cases/common/6 linkshared/meson.build12
-rw-r--r--meson/test cases/common/6 linkshared/test.json6
7 files changed, 66 insertions, 0 deletions
diff --git a/meson/test cases/common/6 linkshared/cpplib.cpp b/meson/test cases/common/6 linkshared/cpplib.cpp
new file mode 100644
index 000000000..247f8201a
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/cpplib.cpp
@@ -0,0 +1,6 @@
+#define BUILDING_DLL
+#include "cpplib.h"
+
+int DLL_PUBLIC cppfunc(void) {
+ return 42;
+}
diff --git a/meson/test cases/common/6 linkshared/cpplib.h b/meson/test cases/common/6 linkshared/cpplib.h
new file mode 100644
index 000000000..e2b02060d
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/cpplib.h
@@ -0,0 +1,12 @@
+/* See http://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support */
+#if defined(_WIN32) || defined(__CYGWIN__)
+ #ifdef BUILDING_DLL
+ #define DLL_PUBLIC __declspec(dllexport)
+ #else
+ #define DLL_PUBLIC __declspec(dllimport)
+ #endif
+#else
+ #define DLL_PUBLIC __attribute__ ((visibility ("default")))
+#endif
+
+int DLL_PUBLIC cppfunc(void);
diff --git a/meson/test cases/common/6 linkshared/cppmain.cpp b/meson/test cases/common/6 linkshared/cppmain.cpp
new file mode 100644
index 000000000..29e9a4480
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/cppmain.cpp
@@ -0,0 +1,5 @@
+#include "cpplib.h"
+
+int main(void) {
+ return cppfunc() != 42;
+}
diff --git a/meson/test cases/common/6 linkshared/libfile.c b/meson/test cases/common/6 linkshared/libfile.c
new file mode 100644
index 000000000..91489b287
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/libfile.c
@@ -0,0 +1,14 @@
+#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
+
+int DLL_PUBLIC func(void) {
+ return 0;
+}
diff --git a/meson/test cases/common/6 linkshared/main.c b/meson/test cases/common/6 linkshared/main.c
new file mode 100644
index 000000000..77773274e
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/main.c
@@ -0,0 +1,11 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_IMPORT __declspec(dllimport)
+#else
+ #define DLL_IMPORT
+#endif
+
+int DLL_IMPORT func(void);
+
+int main(void) {
+ return func();
+}
diff --git a/meson/test cases/common/6 linkshared/meson.build b/meson/test cases/common/6 linkshared/meson.build
new file mode 100644
index 000000000..846b4a09b
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/meson.build
@@ -0,0 +1,12 @@
+project('shared library linking test', 'c', 'cpp')
+
+lib = shared_library('mylib',
+ 'libfile.c' # Split to different lines before and after the comma to test parser.
+ , install : false) # Don't install libraries in common tests; the path is platform-specific
+exe = executable('prog', 'main.c', link_with : lib, install : true)
+
+test('runtest', exe)
+
+cpplib = shared_library('mycpplib', 'cpplib.cpp')
+cppexe = executable('cppprog', 'cppmain.cpp', link_with : cpplib)
+test('cpptest', cppexe)
diff --git a/meson/test cases/common/6 linkshared/test.json b/meson/test cases/common/6 linkshared/test.json
new file mode 100644
index 000000000..067bca760
--- /dev/null
+++ b/meson/test cases/common/6 linkshared/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ { "type": "exe", "file": "usr/bin/prog" },
+ { "type": "pdb", "file": "usr/bin/prog" }
+ ]
+}