| 1 |
project('generator link_whole', 'c') |
| 2 |
|
| 3 |
if meson.backend() == 'xcode' |
| 4 |
error('MESON_SKIP_TEST: whole-archive not supported in Xcode. Patches welcome.') |
| 5 |
endif |
| 6 |
|
| 7 |
# This just generates foo.h and foo.c with int foo() defined. |
| 8 |
gen_py = find_program('generator.py') |
| 9 |
gen = generator(gen_py, |
| 10 |
output: ['@[email protected]', '@[email protected]'], |
| 11 |
arguments : ['@INPUT@', '@BUILD_DIR@']) |
| 12 |
|
| 13 |
# Test 1: link directly into executable |
| 14 |
srcs = gen.process('meson_test_function.tmpl') |
| 15 |
exe = executable('exe1', [srcs, 'main.c'], c_args : '-DBUILDING_EMBEDDED') |
| 16 |
test('test1', exe) |
| 17 |
|
| 18 |
# Test 2: link into shared library and access from executable |
| 19 |
srcs = gen.process('meson_test_function.tmpl') |
| 20 |
shlib2 = shared_library('shlib2', [srcs], c_args : '-DBUILDING_DLL') |
| 21 |
exe = executable('exe2', 'main.c', |
| 22 |
link_with : shlib2, |
| 23 |
include_directories : shlib2.private_dir_include(), |
| 24 |
) |
| 25 |
test('test2', exe) |
| 26 |
|
| 27 |
# Test 3: link into static library and access from executable |
| 28 |
srcs = gen.process('meson_test_function.tmpl') |
| 29 |
stlib3 = static_library('stlib3', [srcs], c_args : '-DBUILDING_EMBEDDED') |
| 30 |
exe = executable('exe3', 'main.c', |
| 31 |
c_args : '-DBUILDING_EMBEDDED', |
| 32 |
link_with : stlib3, |
| 33 |
include_directories : stlib3.private_dir_include(), |
| 34 |
) |
| 35 |
test('test3', exe) |
| 36 |
|
| 37 |
# Test 4: link into static library, link into shared |
| 38 |
# and access from executable. To make sure static_library |
| 39 |
# is not dropped use pull_meson_test_function helper. |
| 40 |
srcs = gen.process('meson_test_function.tmpl') |
| 41 |
stlib4 = static_library('stlib4', [srcs], c_args : '-DBUILDING_DLL') |
| 42 |
shlib4 = shared_library('shlib4', 'pull_meson_test_function.c', |
| 43 |
c_args : '-DBUILDING_DLL', |
| 44 |
link_with : stlib4, |
| 45 |
include_directories : stlib4.private_dir_include(), |
| 46 |
) |
| 47 |
exe = executable('exe4', 'main.c', |
| 48 |
link_with : shlib4, |
| 49 |
include_directories : stlib4.private_dir_include(), |
| 50 |
) |
| 51 |
test('test4', exe) |
| 52 |
|
| 53 |
# Test 5: link into static library, link_whole into shared |
| 54 |
# and access from executable |
| 55 |
srcs = gen.process('meson_test_function.tmpl') |
| 56 |
stlib5 = static_library('stlib5', [srcs], c_args : '-DBUILDING_DLL') |
| 57 |
shlib5 = shared_library('shlib5', link_whole : stlib5) |
| 58 |
exe = executable('exe5', 'main.c', |
| 59 |
link_with : shlib5, |
| 60 |
include_directories : stlib5.private_dir_include(), |
| 61 |
) |
| 62 |
test('test5', exe) |