diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-01-03 11:46:13 -0500 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2018-04-03 15:38:01 -0400 |
commit | 68f9846b7c584815d821c60fcdff866fe629955a (patch) | |
tree | d90a14a8d2e790bea3084e3226d0f5f326e5f482 /test cases | |
parent | 809f01833336be63eb07441e120de2e4f8c4b3c4 (diff) | |
download | meson-68f9846b7c584815d821c60fcdff866fe629955a.zip meson-68f9846b7c584815d821c60fcdff866fe629955a.tar.gz meson-68f9846b7c584815d821c60fcdff866fe629955a.tar.bz2 |
Add both_libraries() to build both shared and static libraries
Also support default_library='both' to make library() build both shared
and static libraries.
Closes #484
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/189 bothlibraries/libfile.c | 7 | ||||
-rw-r--r-- | test cases/common/189 bothlibraries/main.c | 8 | ||||
-rw-r--r-- | test cases/common/189 bothlibraries/meson.build | 12 | ||||
-rw-r--r-- | test cases/common/189 bothlibraries/mylib.h | 13 |
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 |