summaryrefslogtreecommitdiffstats
path: root/test cases/common/121 object only target/meson.build
blob: c3c4e52ce3f35ccc3ffe29a1b2cf61084ef14437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
project('object generator', 'c')

if meson.backend() == 'xcode'
    error('MESON_SKIP_TEST object-only libraries not supported in Xcode. Patches welcome.')
endif

# FIXME: Note that this will not add a dependency to the compiler executable.
# Code will not be rebuilt if it changes.
comp = find_program('obj_generator.py')

if host_machine.system() == 'windows'
  ext = '.obj'
else
  ext = '.o'
endif

cc = meson.get_compiler('c').cmd_array().get(-1)

# Generate an object file with configure_file to mimic prebuilt objects
# provided by the source tree
source1 = configure_file(input : 'source.c',
  output : 'source' + ext,
  command : [comp, cc, files('source.c'),
             join_paths(meson.current_build_dir(), 'source' + ext)])

obj = static_library('obj', objects : source1)

# Generate an object file manually.
gen = generator(comp,
 output : '@BASENAME@' + ext,
 arguments : [cc, '@INPUT@', '@OUTPUT@'])

generated = gen.process(['source2.c'])

shr = shared_library('shr', generated,
  vs_module_defs : 'source2.def')

# Generate an object file with indexed OUTPUT replacement.
gen2 = generator(comp,
 output : '@BASENAME@' + ext,
 arguments : [cc, '@INPUT@', '@OUTPUT0@'])
generated2 = gen2.process(['source3.c'])

stc = static_library('stc', generated2)

subdir('objdir')

e = executable('prog', 'prog.c', link_with : [obj, shr, stc, subdirfilebuilt_obj, subdirfile_obj, subdirstr_obj],
  install : true)

test('objgen', e)