parent
7b3169f464
commit
2d6915a598
11 changed files with 123 additions and 3 deletions
@ -0,0 +1,4 @@ |
||||
## New built-in option for default both_libraries |
||||
|
||||
`both_libraries` targets used to be considered as a shared library by default. |
||||
There is now the `default_both_libraries` option to change this default. |
@ -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) |
@ -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 |
@ -0,0 +1,10 @@ |
||||
#include "library.h" |
||||
|
||||
int library_function(void) |
||||
{ |
||||
#if defined EXPORT |
||||
return 1; |
||||
#else |
||||
return 0; |
||||
#endif |
||||
} |
@ -0,0 +1,5 @@ |
||||
#pragma once |
||||
|
||||
#include "api.h" |
||||
|
||||
int API library_function(void); |
@ -0,0 +1,8 @@ |
||||
#include "library.h" |
||||
|
||||
|
||||
int main(void) |
||||
{ |
||||
int sum = library_function(); |
||||
return sum == EXPECTED ? 0 : sum; |
||||
} |
@ -0,0 +1,16 @@ |
||||
{ |
||||
"matrix": { |
||||
"options": { |
||||
"default_library": [ |
||||
{ "val": "shared" }, |
||||
{ "val": "static" }, |
||||
{ "val": "both" } |
||||
], |
||||
"default_both_libraries": [ |
||||
{ "val": "shared" }, |
||||
{ "val": "static" }, |
||||
{ "val": "auto" } |
||||
] |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue