Debian Codegraph @

test cases/common/121 object only target/meson.build

raw
1 project('object generator', 'c')
2
3 if meson.backend() == 'xcode'
4 error('MESON_SKIP_TEST object-only libraries not supported in Xcode. Patches welcome.')
5 endif
6
7 # FIXME: Note that this will not add a dependency to the compiler executable.
8 # Code will not be rebuilt if it changes.
9 comp = find_program('obj_generator.py')
10
11 if host_machine.system() == 'windows'
12 ext = '.obj'
13 else
14 ext = '.o'
15 endif
16
17 cc = meson.get_compiler('c').cmd_array().get(-1)
18
19 # Generate an object file with configure_file to mimic prebuilt objects
20 # provided by the source tree
21 source1 = configure_file(input : 'source.c',
22 output : 'source' + ext,
23 command : [comp, cc, files('source.c'),
24 join_paths(meson.current_build_dir(), 'source' + ext)])
25
26 obj = static_library('obj', objects : source1)
27
28 # Generate an object file manually.
29 gen = generator(comp,
30 output : '@BASENAME@' + ext,
31 arguments : [cc, '@INPUT@', '@OUTPUT@'])
32
33 generated = gen.process(['source2.c'])
34
35 shr = shared_library('shr', generated,
36 vs_module_defs : 'source2.def')
37
38 # Generate an object file with indexed OUTPUT replacement.
39 gen2 = generator(comp,
40 output : '@BASENAME@' + ext,
41 arguments : [cc, '@INPUT@', '@OUTPUT0@'])
42 generated2 = gen2.process(['source3.c'])
43
44 stc = static_library('stc', generated2)
45
46 subdir('objdir')
47
48 e = executable('prog', 'prog.c', link_with : [obj, shr, stc, subdirfilebuilt_obj, subdirfile_obj, subdirstr_obj],
49 install : true)
50
51 test('objgen', e)