diff options
| author | Charles Brunet <charles.brunet@optelgroup.com> | 2023-12-12 15:49:59 -0500 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-09-06 10:56:44 -0700 |
| commit | 2d6915a5983a64b58ecafd1b1dc92e9c48579ff2 (patch) | |
| tree | 8ed2d004c51ef4d36c502b5851ff9f43adf361d4 /test cases | |
| parent | 7b3169f464810dfed0daf3075a5a6e5ed91dbc9b (diff) | |
| download | meson-2d6915a5983a64b58ecafd1b1dc92e9c48579ff2.tar.gz | |
add default_both_libraries core option
Diffstat (limited to 'test cases')
| -rw-r--r-- | test cases/common/273 both libraries/meson.build | 44 | ||||
| -rw-r--r-- | test cases/common/273 both libraries/src/api.h | 15 | ||||
| -rw-r--r-- | test cases/common/273 both libraries/src/library.c | 10 | ||||
| -rw-r--r-- | test cases/common/273 both libraries/src/library.h | 5 | ||||
| -rw-r--r-- | test cases/common/273 both libraries/src/main.c | 8 | ||||
| -rw-r--r-- | test cases/common/273 both libraries/test.json | 16 |
6 files changed, 98 insertions, 0 deletions
diff --git a/test cases/common/273 both libraries/meson.build b/test cases/common/273 both libraries/meson.build new file mode 100644 index 000000000..b80a9ce7d --- /dev/null +++ b/test cases/common/273 both libraries/meson.build @@ -0,0 +1,44 @@ +project( + 'test both libraries', + 'c', + meson_version: '>= 1.6.0', +) + +expected = 0 + + +with_library = library( + 'with_library', + files('src/library.c'), + c_shared_args: ['-DEXPORT'], +) + +with_library_dep = declare_dependency( + link_with: with_library, +) + +if get_option('default_library') == 'shared' + expected += 1 +elif get_option('default_library') == 'both' + if get_option('default_both_libraries') in ['shared', 'auto'] + expected += 1 + endif +endif + + + +mainlink = executable( + 'mainlink', + files('src/main.c'), + c_args: [f'-DEXPECTED=@expected@'], + link_with: [with_library], +) +test('link with', mainlink) + +maindep = executable( + 'maindep', + files('src/main.c'), + c_args: [f'-DEXPECTED=@expected@'], + dependencies: [with_library_dep], +) +test('use dep', maindep) diff --git a/test cases/common/273 both libraries/src/api.h b/test cases/common/273 both libraries/src/api.h new file mode 100644 index 000000000..a20ded364 --- /dev/null +++ b/test cases/common/273 both libraries/src/api.h @@ -0,0 +1,15 @@ +#pragma once + +#if defined EXPORT + #if defined _WIN32 || defined __CYGWIN__ + #define API __declspec(dllexport) + #else + #if defined __GNUC__ + #define API __attribute__((visibility("default"))) + #else + #define API + #endif + #endif +#else + #define API +#endif diff --git a/test cases/common/273 both libraries/src/library.c b/test cases/common/273 both libraries/src/library.c new file mode 100644 index 000000000..decdb6ce9 --- /dev/null +++ b/test cases/common/273 both libraries/src/library.c @@ -0,0 +1,10 @@ +#include "library.h" + +int library_function(void) +{ +#if defined EXPORT + return 1; +#else + return 0; +#endif +} diff --git a/test cases/common/273 both libraries/src/library.h b/test cases/common/273 both libraries/src/library.h new file mode 100644 index 000000000..7f57af4f1 --- /dev/null +++ b/test cases/common/273 both libraries/src/library.h @@ -0,0 +1,5 @@ +#pragma once + +#include "api.h" + +int API library_function(void); diff --git a/test cases/common/273 both libraries/src/main.c b/test cases/common/273 both libraries/src/main.c new file mode 100644 index 000000000..340322e45 --- /dev/null +++ b/test cases/common/273 both libraries/src/main.c @@ -0,0 +1,8 @@ +#include "library.h" + + +int main(void) +{ + int sum = library_function(); + return sum == EXPECTED ? 0 : sum; +} diff --git a/test cases/common/273 both libraries/test.json b/test cases/common/273 both libraries/test.json new file mode 100644 index 000000000..08aa54790 --- /dev/null +++ b/test cases/common/273 both libraries/test.json @@ -0,0 +1,16 @@ +{ + "matrix": { + "options": { + "default_library": [ + { "val": "shared" }, + { "val": "static" }, + { "val": "both" } + ], + "default_both_libraries": [ + { "val": "shared" }, + { "val": "static" }, + { "val": "auto" } + ] + } + } +} |
