diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-02-15 09:05:10 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2016-03-30 16:24:35 +0530 |
commit | 1713fa02970ca2a045b1635186fef718620bf1b3 (patch) | |
tree | 6e0395fd46efec1338dab2db8f5b984e7115c1de /test cases | |
parent | 8945c85f968e851010b101ac2654aa3758470589 (diff) | |
download | meson-1713fa02970ca2a045b1635186fef718620bf1b3.zip meson-1713fa02970ca2a045b1635186fef718620bf1b3.tar.gz meson-1713fa02970ca2a045b1635186fef718620bf1b3.tar.bz2 |
Add shared_library argument for a Visual Studio module definitions file
On MSVC, shared libraries only export symbols that have been explicitly exported
either as part of the symbol prototype or via a module definitions file.
On compilers other than MSVC, all symbols are exported in the shared library by
default and the format for the list of symbols to export is different, so this
is only used with the VisualStudio compiler.
The module defs file path can either be relative to the current source directory
or an absolute path using meson.source_root() + '/some/path'
Diffstat (limited to 'test cases')
9 files changed, 43 insertions, 0 deletions
diff --git a/test cases/failing/28 no vs module defs/meson.build b/test cases/failing/28 no vs module defs/meson.build new file mode 100644 index 0000000..7864daa --- /dev/null +++ b/test cases/failing/28 no vs module defs/meson.build @@ -0,0 +1,9 @@ +project('dll_no_module_def', 'c') + +if meson.get_compiler('c').get_id() != 'msvc' + error('Need to use the Visual Studio compiler') +endif + +subdir('subdir') +exe = executable('prog', 'prog.c', link_with : shlib) +test('runtest', exe) diff --git a/test cases/failing/28 no vs module defs/prog.c b/test cases/failing/28 no vs module defs/prog.c new file mode 100644 index 0000000..f35f4a0 --- /dev/null +++ b/test cases/failing/28 no vs module defs/prog.c @@ -0,0 +1,5 @@ +int somedllfunc(); + +int main(int argc, char **argv) { + return somedllfunc() == 42 ? 0 : 1; +} diff --git a/test cases/failing/28 no vs module defs/subdir/meson.build b/test cases/failing/28 no vs module defs/subdir/meson.build new file mode 100644 index 0000000..8395d59 --- /dev/null +++ b/test cases/failing/28 no vs module defs/subdir/meson.build @@ -0,0 +1 @@ +shlib = shared_library('somedll', 'somedll.c') diff --git a/test cases/failing/28 no vs module defs/subdir/somedll.c b/test cases/failing/28 no vs module defs/subdir/somedll.c new file mode 100644 index 0000000..5c469b1 --- /dev/null +++ b/test cases/failing/28 no vs module defs/subdir/somedll.c @@ -0,0 +1,7 @@ +/* With MSVC, the DLL created from this will not export any symbols + * without a module definitions file specified while linking */ +#ifdef _MSC_VER +int somedllfunc() { + return 42; +} +#endif diff --git a/test cases/windows/6 vs module defs/meson.build b/test cases/windows/6 vs module defs/meson.build new file mode 100644 index 0000000..4b9e735 --- /dev/null +++ b/test cases/windows/6 vs module defs/meson.build @@ -0,0 +1,7 @@ +project('dll_module_defs', 'c') + +if meson.get_compiler('c').get_id() == 'msvc' + subdir('subdir') + exe = executable('prog', 'prog.c', link_with : shlib) + test('runtest', exe) +endif diff --git a/test cases/windows/6 vs module defs/prog.c b/test cases/windows/6 vs module defs/prog.c new file mode 100644 index 0000000..f35f4a0 --- /dev/null +++ b/test cases/windows/6 vs module defs/prog.c @@ -0,0 +1,5 @@ +int somedllfunc(); + +int main(int argc, char **argv) { + return somedllfunc() == 42 ? 0 : 1; +} diff --git a/test cases/windows/6 vs module defs/subdir/meson.build b/test cases/windows/6 vs module defs/subdir/meson.build new file mode 100644 index 0000000..60633c3 --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/meson.build @@ -0,0 +1 @@ +shlib = shared_library('somedll', 'somedll.c', vs_module_defs : 'somedll.def') diff --git a/test cases/windows/6 vs module defs/subdir/somedll.c b/test cases/windows/6 vs module defs/subdir/somedll.c new file mode 100644 index 0000000..df255e3 --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/somedll.c @@ -0,0 +1,5 @@ +#ifdef _MSC_VER +int somedllfunc() { + return 42; +} +#endif diff --git a/test cases/windows/6 vs module defs/subdir/somedll.def b/test cases/windows/6 vs module defs/subdir/somedll.def new file mode 100644 index 0000000..217801b --- /dev/null +++ b/test cases/windows/6 vs module defs/subdir/somedll.def @@ -0,0 +1,3 @@ +EXPORTS + somedllfunc + |