1project('whole archive', 'c')
2
3if meson.backend() == 'xcode' or \
4   meson.backend() == 'vs2010' or \
5   meson.backend() == 'vs2012' or \
6   meson.backend() == 'vs2013'
7    error('MESON_SKIP_TEST: whole-archive not supported in Xcode nor pre-VS2015 IDE. Patches welcome.')
8endif
9
10add_project_arguments('-I' + meson.source_root(), language : 'c')
11
12# Test 1: link_whole keeps all symbols
13# Make static func1
14subdir('st_func1')
15# Make shared func2 linking whole func1 archive
16subdir('sh_func2_linked_func1')
17# Link exe with shared library only
18subdir('exe')
19# Test that both func1 and func2 are accessible from shared library
20test('prog', exe)
21
22# Test 2: link_whole can be used instead of source list, see #2180
23# Make static func2
24subdir('st_func2')
25# Link both func1 and func2 into same shared library
26# which does not have any sources other than 2 static libraries
27subdir('sh_only_link_whole')
28# Link exe2 with shared library only
29subdir('exe2')
30# Test that both func1 and func2 are accessible from shared library
31test('prog2', exe2)
32
33# Test 3: link_whole can be used in declare_dependency()
34func1_dep = declare_dependency(link_whole : [st_func1])
35# Use dependency to link func1 into shared library
36subdir('sh_func2_dep_func1')
37# Link exe3 with shared library
38subdir('exe3')
39# Test that both func1 and func2 are accessible from shared library
40test('prog3', exe3)
41
42# Test 4: link_whole can be used in transitive declare_dependency()
43func1_trans_dep = declare_dependency(dependencies : func1_dep)
44# Use transitive dependency to link func1 into shared library
45subdir('sh_func2_transdep_func1')
46# Link exe4 with shared library
47subdir('exe4')
48# Test that both func1 and func2 are accessible from shared library
49test('prog4', exe4)
50