From b6cb7fd29e289cf01f2ef13ef002a658ccb2d9c8 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 28 Jul 2015 00:28:47 +0300 Subject: Fix symbol exportation and other things to make all tests pass on MSVC. --- test cases/common/46 library chain/subdir/lib1.c | 13 ++++++++++++- .../common/46 library chain/subdir/subdir2/lib2.c | 13 ++++++++++++- .../common/46 library chain/subdir/subdir3/lib3.c | 13 ++++++++++++- .../49 subproject/subprojects/sublib/include/subdefs.h | 17 ++++++++++++++++- .../common/49 subproject/subprojects/sublib/meson.build | 3 ++- .../common/49 subproject/subprojects/sublib/sublib.c | 2 +- .../common/53 subproject subproject/subprojects/a/a.c | 13 ++++++++++++- .../common/53 subproject subproject/subprojects/b/b.c | 13 ++++++++++++- test cases/common/60 install script/meson.build | 6 +++++- test cases/common/62 exe static shared/subdir/shlib.c | 13 ++++++++++++- .../common/79 shared subproject/subprojects/B/b.c | 14 +++++++++++++- .../common/79 shared subproject/subprojects/C/c.c | 13 ++++++++++++- .../common/80 shared subproject 2/subprojects/B/b.c | 13 ++++++++++++- .../common/80 shared subproject 2/subprojects/C/c.c | 13 ++++++++++++- .../custom_subproject_dir/B/b.c | 13 ++++++++++++- .../custom_subproject_dir/C/c.c | 13 ++++++++++++- test cases/common/86 same basename/lib.c | 13 ++++++++++++- 17 files changed, 181 insertions(+), 17 deletions(-) diff --git a/test cases/common/46 library chain/subdir/lib1.c b/test cases/common/46 library chain/subdir/lib1.c index a1fd5bc..499ef82 100644 --- a/test cases/common/46 library chain/subdir/lib1.c +++ b/test cases/common/46 library chain/subdir/lib1.c @@ -1,6 +1,17 @@ int lib2fun(); int lib3fun(); -int libfun() { +#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 libfun() { return lib2fun() + lib3fun(); } diff --git a/test cases/common/46 library chain/subdir/subdir2/lib2.c b/test cases/common/46 library chain/subdir/subdir2/lib2.c index 490e444..34fadf2 100644 --- a/test cases/common/46 library chain/subdir/subdir2/lib2.c +++ b/test cases/common/46 library chain/subdir/subdir2/lib2.c @@ -1,3 +1,14 @@ -int lib2fun() { +#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 lib2fun() { return 0; } diff --git a/test cases/common/46 library chain/subdir/subdir3/lib3.c b/test cases/common/46 library chain/subdir/subdir3/lib3.c index fed00d5..7bd88af 100644 --- a/test cases/common/46 library chain/subdir/subdir3/lib3.c +++ b/test cases/common/46 library chain/subdir/subdir3/lib3.c @@ -1,3 +1,14 @@ -int lib3fun() { +#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 lib3fun() { return 0; } diff --git a/test cases/common/49 subproject/subprojects/sublib/include/subdefs.h b/test cases/common/49 subproject/subprojects/sublib/include/subdefs.h index 9261c78..681c7b8 100644 --- a/test cases/common/49 subproject/subprojects/sublib/include/subdefs.h +++ b/test cases/common/49 subproject/subprojects/sublib/include/subdefs.h @@ -1,6 +1,21 @@ #ifndef SUBDEFS_H_ #define SUBDEFS_H_ -int subfunc(); +#if defined _WIN32 || defined __CYGWIN__ +#if defined BUILDING_SUB + #define DLL_PUBLIC __declspec(dllexport) +#else + #define DLL_PUBLIC __declspec(dllimport) +#endif +#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 subfunc(); #endif diff --git a/test cases/common/49 subproject/subprojects/sublib/meson.build b/test cases/common/49 subproject/subprojects/sublib/meson.build index d8e4140..0b6911d 100644 --- a/test cases/common/49 subproject/subprojects/sublib/meson.build +++ b/test cases/common/49 subproject/subprojects/sublib/meson.build @@ -5,6 +5,7 @@ if not meson.is_subproject() endif i = include_directories('include') -l = shared_library('sublib', 'sublib.c', include_directories : i, install : true) +l = shared_library('sublib', 'sublib.c', include_directories : i, install : true, + c_args : '-DBUILDING_SUB=2') t = executable('simpletest', 'simpletest.c', include_directories : i, link_with : l) test('plain', t) diff --git a/test cases/common/49 subproject/subprojects/sublib/sublib.c b/test cases/common/49 subproject/subprojects/sublib/sublib.c index 7045c61..c13326b 100644 --- a/test cases/common/49 subproject/subprojects/sublib/sublib.c +++ b/test cases/common/49 subproject/subprojects/sublib/sublib.c @@ -1,5 +1,5 @@ #include -int subfunc() { +int DLL_PUBLIC subfunc() { return 42; } diff --git a/test cases/common/53 subproject subproject/subprojects/a/a.c b/test cases/common/53 subproject subproject/subprojects/a/a.c index 751749d..7ac3e5e 100644 --- a/test cases/common/53 subproject subproject/subprojects/a/a.c +++ b/test cases/common/53 subproject subproject/subprojects/a/a.c @@ -1,4 +1,15 @@ int func2(); -int func() { return func2(); } +#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() { return func2(); } diff --git a/test cases/common/53 subproject subproject/subprojects/b/b.c b/test cases/common/53 subproject subproject/subprojects/b/b.c index 68e6ab9..a95651b 100644 --- a/test cases/common/53 subproject subproject/subprojects/b/b.c +++ b/test cases/common/53 subproject subproject/subprojects/b/b.c @@ -1,3 +1,14 @@ -int func2() { +#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 func2() { return 42; } diff --git a/test cases/common/60 install script/meson.build b/test cases/common/60 install script/meson.build index f140dd0..ed415b6 100644 --- a/test cases/common/60 install script/meson.build +++ b/test cases/common/60 install script/meson.build @@ -1,4 +1,8 @@ project('custom install script', 'c') -meson.set_install_script('myinstall.sh') +if meson.get_compiler('c').get_id() == 'msvc' + meson.set_install_script('myinstall.bat') +else + meson.set_install_script('myinstall.sh') +endif executable('prog', 'prog.c', install : true) diff --git a/test cases/common/62 exe static shared/subdir/shlib.c b/test cases/common/62 exe static shared/subdir/shlib.c index b513e13..d649c7d 100644 --- a/test cases/common/62 exe static shared/subdir/shlib.c +++ b/test cases/common/62 exe static shared/subdir/shlib.c @@ -1,3 +1,14 @@ -int shlibfunc() { +#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 shlibfunc() { return 42; } diff --git a/test cases/common/79 shared subproject/subprojects/B/b.c b/test cases/common/79 shared subproject/subprojects/B/b.c index 03b0cc7..a1f3a51 100644 --- a/test cases/common/79 shared subproject/subprojects/B/b.c +++ b/test cases/common/79 shared subproject/subprojects/B/b.c @@ -1,7 +1,19 @@ #include +#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 + + char func_c(); -char func_b() { +char DLL_PUBLIC func_b() { if(func_c() != 'c') { exit(3); } diff --git a/test cases/common/79 shared subproject/subprojects/C/c.c b/test cases/common/79 shared subproject/subprojects/C/c.c index 3bbac08..eebfb9f 100644 --- a/test cases/common/79 shared subproject/subprojects/C/c.c +++ b/test cases/common/79 shared subproject/subprojects/C/c.c @@ -1,3 +1,14 @@ -char func_c() { +#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 + +char DLL_PUBLIC func_c() { return 'c'; } diff --git a/test cases/common/80 shared subproject 2/subprojects/B/b.c b/test cases/common/80 shared subproject 2/subprojects/B/b.c index 03b0cc7..4c94ee9 100644 --- a/test cases/common/80 shared subproject 2/subprojects/B/b.c +++ b/test cases/common/80 shared subproject 2/subprojects/B/b.c @@ -1,7 +1,18 @@ #include char func_c(); -char func_b() { +#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 + +char DLL_PUBLIC func_b() { if(func_c() != 'c') { exit(3); } diff --git a/test cases/common/80 shared subproject 2/subprojects/C/c.c b/test cases/common/80 shared subproject 2/subprojects/C/c.c index 3bbac08..eebfb9f 100644 --- a/test cases/common/80 shared subproject 2/subprojects/C/c.c +++ b/test cases/common/80 shared subproject 2/subprojects/C/c.c @@ -1,3 +1,14 @@ -char func_c() { +#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 + +char DLL_PUBLIC func_c() { return 'c'; } diff --git a/test cases/common/82 custom subproject dir/custom_subproject_dir/B/b.c b/test cases/common/82 custom subproject dir/custom_subproject_dir/B/b.c index 03b0cc7..4c94ee9 100644 --- a/test cases/common/82 custom subproject dir/custom_subproject_dir/B/b.c +++ b/test cases/common/82 custom subproject dir/custom_subproject_dir/B/b.c @@ -1,7 +1,18 @@ #include char func_c(); -char func_b() { +#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 + +char DLL_PUBLIC func_b() { if(func_c() != 'c') { exit(3); } diff --git a/test cases/common/82 custom subproject dir/custom_subproject_dir/C/c.c b/test cases/common/82 custom subproject dir/custom_subproject_dir/C/c.c index 3bbac08..eebfb9f 100644 --- a/test cases/common/82 custom subproject dir/custom_subproject_dir/C/c.c +++ b/test cases/common/82 custom subproject dir/custom_subproject_dir/C/c.c @@ -1,3 +1,14 @@ -char func_c() { +#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 + +char DLL_PUBLIC func_c() { return 'c'; } diff --git a/test cases/common/86 same basename/lib.c b/test cases/common/86 same basename/lib.c index 11ce3b3..6fd432e 100644 --- a/test cases/common/86 same basename/lib.c +++ b/test cases/common/86 same basename/lib.c @@ -1,5 +1,16 @@ +#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 + #if defined SHAR -int func() { +int DLL_PUBLIC func() { return 1; } #elif defined STAT -- cgit v1.1