| 1 |
project('preprocess', 'c') |
| 2 |
|
| 3 |
cc = meson.get_compiler('c') |
| 4 |
|
| 5 |
add_project_arguments(['-DFOO=0', '-DBAR=0'], language: 'c') |
| 6 |
|
| 7 |
fs = import('fs') |
| 8 |
bar_content = fs.read('bar.c') |
| 9 |
bar_x = custom_target( |
| 10 |
input: 'bar.c', |
| 11 |
output: 'bar.x', |
| 12 |
command: ['python3', '-c', '''import sys;print(sys.argv[1].replace('@BAR@', 'bar'))''', bar_content], |
| 13 |
capture: true, |
| 14 |
) |
| 15 |
|
| 16 |
foo_h = import('fs').copyfile('foo.x', 'foo.h') |
| 17 |
|
| 18 |
dep = declare_dependency(compile_args: '-DPLOP=0') |
| 19 |
|
| 20 |
pp_files = cc.preprocess('foo.c', bar_x, 'math.c', |
| 21 |
output: '@[email protected]', |
| 22 |
dependencies: dep, |
| 23 |
depends: foo_h, |
| 24 |
compile_args: ['-DBAZ=0'], |
| 25 |
) |
| 26 |
|
| 27 |
foreach f : pp_files |
| 28 |
message(f.full_path()) |
| 29 |
endforeach |
| 30 |
|
| 31 |
subdir('src') |
| 32 |
|
| 33 |
test('test-foo', executable('app', pp_files, link_depends: file_map)) |