aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-04-04 22:47:59 +0300
committerGitHub <noreply@github.com>2018-04-04 22:47:59 +0300
commitaef1a81b3586aeb48988b60fbeaef5c19e112c45 (patch)
tree23abfa769e8b948a1d94afaa1bdc8ddcaa369429 /test cases
parentc1fcc8ab3e1cac0823f3527000e543cc96885d48 (diff)
parent68f9846b7c584815d821c60fcdff866fe629955a (diff)
downloadmeson-aef1a81b3586aeb48988b60fbeaef5c19e112c45.zip
meson-aef1a81b3586aeb48988b60fbeaef5c19e112c45.tar.gz
meson-aef1a81b3586aeb48988b60fbeaef5c19e112c45.tar.bz2
Merge pull request #2711 from xclaesse/both-library
Add both_library() to build both shared and static library
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/189 bothlibraries/libfile.c7
-rw-r--r--test cases/common/189 bothlibraries/main.c8
-rw-r--r--test cases/common/189 bothlibraries/meson.build12
-rw-r--r--test cases/common/189 bothlibraries/mylib.h13
4 files changed, 40 insertions, 0 deletions
diff --git a/test cases/common/189 bothlibraries/libfile.c b/test cases/common/189 bothlibraries/libfile.c
new file mode 100644
index 0000000..085ef3b
--- /dev/null
+++ b/test cases/common/189 bothlibraries/libfile.c
@@ -0,0 +1,7 @@
+#include "mylib.h"
+
+DO_EXPORT int retval = 42;
+
+DO_EXPORT int func() {
+ return retval;
+}
diff --git a/test cases/common/189 bothlibraries/main.c b/test cases/common/189 bothlibraries/main.c
new file mode 100644
index 0000000..03a8e02
--- /dev/null
+++ b/test cases/common/189 bothlibraries/main.c
@@ -0,0 +1,8 @@
+#include "mylib.h"
+
+DO_IMPORT int func();
+DO_IMPORT int retval;
+
+int main(int argc, char **arg) {
+ return func() == retval ? 0 : 1;
+}
diff --git a/test cases/common/189 bothlibraries/meson.build b/test cases/common/189 bothlibraries/meson.build
new file mode 100644
index 0000000..3a13d62
--- /dev/null
+++ b/test cases/common/189 bothlibraries/meson.build
@@ -0,0 +1,12 @@
+project('both libraries linking test', 'c')
+
+both_libs = both_libraries('mylib', 'libfile.c')
+exe_shared = executable('prog-shared', 'main.c', link_with : both_libs.get_shared_lib())
+exe_static = executable('prog-static', 'main.c',
+ c_args : ['-DSTATIC_COMPILATION'],
+ link_with : both_libs.get_static_lib())
+exe_both = executable('prog-both', 'main.c', link_with : both_libs)
+
+test('runtest-shared', exe_shared)
+test('runtest-static', exe_static)
+test('runtest-both', exe_both)
diff --git a/test cases/common/189 bothlibraries/mylib.h b/test cases/common/189 bothlibraries/mylib.h
new file mode 100644
index 0000000..1038a01
--- /dev/null
+++ b/test cases/common/189 bothlibraries/mylib.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifdef _WIN32
+ #ifdef STATIC_COMPILATION
+ #define DO_IMPORT extern
+ #else
+ #define DO_IMPORT __declspec(dllimport)
+ #endif
+ #define DO_EXPORT __declspec(dllexport)
+#else
+ #define DO_IMPORT extern
+ #define DO_EXPORT
+#endif