Debian Codegraph @

test cases/common/22 object extraction/meson.build

raw
1 project('object extraction', 'c')
2
3 if meson.is_unity()
4 error('MESON_SKIP_TEST, Skipping extraction test because this is a Unity build.')
5 endif
6
7 lib1 = library('somelib', 'src/lib.c')
8 lib2 = library('somelib2', 'lib.c', 'header.h', 'lib2.c')
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 e1 = executable('main1', 'main.c', objects : obj1)
16 e2 = executable('main2', 'main.c', objects : obj2)
17 e3 = executable('main3', 'main.c', objects : obj3)
18 e4 = executable('main4', 'main.c', objects : obj4)
19 e5 = executable('main5', 'main.c', objects : obj5)
20 e6 = executable('main6', 'main.c', objects : obj6)
21 ct_src = custom_target('lib3.c', output: 'lib3.c', capture: true,
22 command: [find_program('create-source.py'), 'lib.c'])
23 lib3 = library('somelib3', ct_src)
24 e7 = executable('main7', 'main.c', objects: lib3.extract_objects(ct_src[0]))
25 e8 = executable('main8', 'main.c', objects: lib3.extract_objects(ct_src))
26 gen = generator(find_program('create-source.py'), arguments: ['@INPUT@'],
27 output: '@[email protected]', capture: true)
28 gen_src = gen.process('lib.c')
29 lib4 = library('somelib4', gen_src)
30 e9 = executable('main9', 'main.c', objects: lib4.extract_objects(gen_src))
31 custom_target('custom_target with object inputs', output: 'objs',
32 input: [obj1, obj2, obj3, obj5, obj6],
33 build_by_default: true,
34 command: [find_program('check-obj.py'), meson.backend(), '@INPUT@'],
35 capture: true)
36 test('extraction test 1', e1)
37 test('extraction test 2', e2)
38 test('extraction test 3', e3)
39 test('extraction test 4', e4)
40 test('extraction test 5', e5)
41 test('extraction test 6', e6)
42 test('extraction test 7', e7)
43 test('extraction test 8', e8)
44 test('extraction test 9', e9)
45
46 lib = subproject('sub').get_variable('lib')
47 testcase expect_error('Tried to extract objects from a different subproject.')
48 lib.extract_objects()
49 endtestcase
50
51 cc = meson.get_compiler('c')
52 lib = cc.find_library('z', required: false)
53 if lib.found()
54 testcase expect_error('Unknown method .*', how: 're')
55 lib.extract_objects()
56 endtestcase
57 endif