| 1 |
project('object extraction', 'c') |
| 2 |
|
| 3 |
if meson.is_unity() |
| 4 |
message('Skipping extraction test because this is a Unity build.') |
| 5 |
else |
| 6 |
lib1 = library('somelib', 'src/lib.c') |
| 7 |
lib2 = library('somelib2', 'lib.c', 'header.h', 'lib2.c') |
| 8 |
|
| 9 |
obj1 = lib1.extract_objects('src/lib.c') |
| 10 |
obj2 = lib2.extract_objects(['lib.c']) |
| 11 |
obj3 = lib2.extract_objects(files('lib.c')) |
| 12 |
obj4 = lib2.extract_objects(['lib.c', 'lib.c']) |
| 13 |
obj5 = lib2.extract_objects(['lib.c', 'header.h']) |
| 14 |
obj6 = lib2.extract_all_objects(recursive: true) |
| 15 |
|
| 16 |
e1 = executable('main1', 'main.c', objects : obj1) |
| 17 |
e2 = executable('main2', 'main.c', objects : obj2) |
| 18 |
e3 = executable('main3', 'main.c', objects : obj3) |
| 19 |
e4 = executable('main4', 'main.c', objects : obj4) |
| 20 |
e5 = executable('main5', 'main.c', objects : obj5) |
| 21 |
e6 = executable('main6', 'main.c', objects : obj6) |
| 22 |
|
| 23 |
ct_src = custom_target('lib3.c', output: 'lib3.c', capture: true, |
| 24 |
command: [find_program('create-source.py'), 'lib.c']) |
| 25 |
lib3 = library('somelib3', ct_src) |
| 26 |
e7 = executable('main7', 'main.c', objects: lib3.extract_objects(ct_src[0])) |
| 27 |
e8 = executable('main8', 'main.c', objects: lib3.extract_objects(ct_src)) |
| 28 |
|
| 29 |
gen = generator(find_program('create-source.py'), arguments: ['@INPUT@'], |
| 30 |
output: '@[email protected]', capture: true) |
| 31 |
gen_src = gen.process('lib.c') |
| 32 |
lib4 = library('somelib4', gen_src) |
| 33 |
e9 = executable('main9', 'main.c', objects: lib4.extract_objects(gen_src)) |
| 34 |
|
| 35 |
custom_target('custom_target with object inputs', output: 'objs', |
| 36 |
input: [obj1, obj2, obj3, obj5, obj6], |
| 37 |
build_by_default: true, |
| 38 |
command: [find_program('check-obj.py'), meson.backend(), '@INPUT@'], |
| 39 |
capture: true) |
| 40 |
|
| 41 |
test('extraction test 1', e1) |
| 42 |
test('extraction test 2', e2) |
| 43 |
test('extraction test 3', e3) |
| 44 |
test('extraction test 4', e4) |
| 45 |
test('extraction test 5', e5) |
| 46 |
test('extraction test 6', e6) |
| 47 |
test('extraction test 7', e7) |
| 48 |
test('extraction test 8', e8) |
| 49 |
test('extraction test 9', e9) |
| 50 |
endif |