| 1 |
project('custom target') |
| 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(), 'my_compiler.py') |
| 11 |
# Test that files() in command: works. The compiler just discards it. |
| 12 |
useless = files('test.json') |
| 13 |
|
| 14 |
mytarget = custom_target('bindat', |
| 15 |
output : 'data.dat', |
| 16 |
input : 'data_source.txt', |
| 17 |
command : [python, comp, '--input=@INPUT@', '--output=@OUTPUT@', useless], |
| 18 |
env: {'MY_COMPILER_ENV': 'value'}, |
| 19 |
install : true, |
| 20 |
install_dir : 'subdir' |
| 21 |
) |
| 22 |
|
| 23 |
has_not_changed = false |
| 24 |
if is_disabler(mytarget) |
| 25 |
has_not_changed = true |
| 26 |
else |
| 27 |
has_not_changed = true |
| 28 |
endif |
| 29 |
assert(has_not_changed, 'Custom target has changed.') |
| 30 |
|
| 31 |
assert(not is_disabler(mytarget), 'Custom target is a disabler.') |
| 32 |
|
| 33 |
mytarget_disabler = custom_target('bindat', |
| 34 |
output : 'data.dat', |
| 35 |
input : 'data_source.txt', |
| 36 |
command : [disabler(), comp, '--input=@INPUT@', '--output=@OUTPUT@', useless], |
| 37 |
install : true, |
| 38 |
install_dir : 'subdir' |
| 39 |
) |
| 40 |
|
| 41 |
if mytarget_disabler.found() |
| 42 |
mytarget_disabled = false |
| 43 |
else |
| 44 |
mytarget_disabled = true |
| 45 |
endif |
| 46 |
|
| 47 |
assert(mytarget_disabled, 'Disabled custom target should not be found.') |
| 48 |
|
| 49 |
mytarget_ci = custom_target('bindat_ci', |
| 50 |
output : 'data_ci.dat', |
| 51 |
input : 'data_source.txt', |
| 52 |
command : [python, comp, '--input=@INPUT@', '--output=@OUTPUT@', mytarget.to_list()], |
| 53 |
) |
| 54 |
|
| 55 |
mytarget_disabler = custom_target('bindat', |
| 56 |
output : 'data.dat', |
| 57 |
input : disabler(), |
| 58 |
command : [python, comp, '--input=@INPUT@', '--output=@OUTPUT@', useless], |
| 59 |
install : true, |
| 60 |
install_dir : 'subdir' |
| 61 |
) |
| 62 |
|
| 63 |
assert(is_disabler(mytarget_disabler), 'Disabled custom target is not a disabler.') |
| 64 |
|
| 65 |
if mytarget_disabler.found() |
| 66 |
mytarget_disabled = false |
| 67 |
else |
| 68 |
mytarget_disabled = true |
| 69 |
endif |
| 70 |
|
| 71 |
assert(mytarget_disabled, 'Disabled custom target should not be found.') |
| 72 |
|
| 73 |
subdir('depfile') |