From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- meson/test cases/common/6 linkshared/cpplib.cpp | 6 ++++++ meson/test cases/common/6 linkshared/cpplib.h | 12 ++++++++++++ meson/test cases/common/6 linkshared/cppmain.cpp | 5 +++++ meson/test cases/common/6 linkshared/libfile.c | 14 ++++++++++++++ meson/test cases/common/6 linkshared/main.c | 11 +++++++++++ meson/test cases/common/6 linkshared/meson.build | 12 ++++++++++++ meson/test cases/common/6 linkshared/test.json | 6 ++++++ 7 files changed, 66 insertions(+) create mode 100644 meson/test cases/common/6 linkshared/cpplib.cpp create mode 100644 meson/test cases/common/6 linkshared/cpplib.h create mode 100644 meson/test cases/common/6 linkshared/cppmain.cpp create mode 100644 meson/test cases/common/6 linkshared/libfile.c create mode 100644 meson/test cases/common/6 linkshared/main.c create mode 100644 meson/test cases/common/6 linkshared/meson.build create mode 100644 meson/test cases/common/6 linkshared/test.json (limited to 'meson/test cases/common/6 linkshared') 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" } + ] +} -- cgit 1.2.3-korg