Debian Codegraph @

test cases/common/117 shared module/meson.build

raw
1 project('shared module', 'c')
2
3 c = meson.get_compiler('c')
4
5 # Windows UWP doesn't support the ToolHelp API we use in this test to emulate
6 # runtime symbol resolution.
7 if host_machine.system() == 'windows'
8 if not c.compiles('''
9 #include <windows.h>
10 #include <tlhelp32.h>
11
12 HANDLE func(void)
13 {
14 return CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
15 }
16 ''')
17 error('MESON_SKIP_TEST Windows UWP does not support this test.')
18 endif
19 endif
20
21 dl = c.find_library('dl', required : false)
22 l = shared_library('runtime', 'runtime.c')
23 # Do NOT link the module with the runtime library. This
24 # is a common approach for plugins that are only used
25 # with dlopen. Any symbols are resolved dynamically
26 # at runtime. This requires extra help on Windows, so
27 # should be avoided unless really necessary.
28 m = shared_module('mymodule', 'module.c')
29 e = executable('prog', 'prog.c',
30 link_with : l, export_dynamic : true, dependencies : dl)
31 test('import test', e, args : m)
32
33 # Same as above, but module created with build_target()
34 m2 = build_target('mymodule2', 'module.c', target_type: 'shared_module')
35 test('import test 2', e, args : m2)
36
37 # Same as above, but built and installed in a sub directory
38 m2_subdir = build_target('mymodule2', 'module.c',
39 target_type: 'shared_module',
40 build_subdir: 'subdir',
41 install: true,
42 install_dir: join_paths(get_option('libdir'), 'modules/subdir'))
43 test('import test 2 subdir', e, args : m2_subdir)
44
45 # Shared module that does not export any symbols
46 shared_module('nosyms', 'nosyms.c',
47 override_options: ['werror=false'],
48 install : true,
49 install_dir : join_paths(get_option('libdir'), 'modules'))