| 1 |
project('object generator', 'c') |
| 2 |
|
| 3 |
python = find_program('python3', required : false) |
| 4 |
if not python.found() |
| 5 |
python = find_program('python') |
| 6 |
endif |
| 7 |
|
| 8 |
# Note that this will not add a dependency to the compiler executable. |
| 9 |
# Code will not be rebuilt if it changes. |
| 10 |
comp = '@0@/@1@'.format(meson.current_source_dir(), 'obj_generator.py') |
| 11 |
|
| 12 |
if host_machine.system() == 'windows' |
| 13 |
outputname = '@[email protected]' |
| 14 |
else |
| 15 |
outputname = '@[email protected]' |
| 16 |
endif |
| 17 |
|
| 18 |
cc = meson.get_compiler('c').cmd_array().get(-1) |
| 19 |
# Generate an object file manually. |
| 20 |
gen = generator(python, |
| 21 |
output : outputname, |
| 22 |
arguments : [comp, cc, '@INPUT@', '@OUTPUT@']) |
| 23 |
|
| 24 |
generated = gen.process(['source.c', 'source2.c']) |
| 25 |
|
| 26 |
# Generate an object file with indexed OUTPUT replacement. |
| 27 |
gen2 = generator(python, |
| 28 |
output : outputname, |
| 29 |
arguments : [comp, cc, '@INPUT@', '@OUTPUT0@']) |
| 30 |
generated2 = gen2.process(['source3.c']) |
| 31 |
|
| 32 |
# Generate an object file ending with .o even on Windows. |
| 33 |
# The VS backend needs to handle .o objects differently from .obj objects. |
| 34 |
gen3 = generator(python, |
| 35 |
output : '@[email protected]', |
| 36 |
arguments : [comp, cc, '@INPUT@', '@OUTPUT@']) |
| 37 |
|
| 38 |
generated3 = gen3.process(['source4.c']) |
| 39 |
|
| 40 |
subdir('dir') |
| 41 |
|
| 42 |
e = executable('prog', 'prog.c', generated, generated2, generated3, generated4) |
| 43 |
|
| 44 |
test('objgen', e) |