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