Merge pull request #712 from QuLogic/capturing-custom-target
Allow capturing command output of a custom target.pull/727/head
commit
4e050c3d9b
9 changed files with 70 additions and 11 deletions
@ -0,0 +1 @@ |
|||||||
|
This is a text only input file. |
@ -0,0 +1 @@ |
|||||||
|
usr/subdir/data.dat |
@ -0,0 +1,16 @@ |
|||||||
|
project('custom target', 'c') |
||||||
|
|
||||||
|
python = find_program('python3') |
||||||
|
|
||||||
|
# Note that this will not add a dependency to the compiler executable. |
||||||
|
# Code will not be rebuilt if it changes. |
||||||
|
comp = '@0@/@1@'.format(meson.current_source_dir(), 'my_compiler.py') |
||||||
|
|
||||||
|
mytarget = custom_target('bindat', |
||||||
|
output : 'data.dat', |
||||||
|
input : 'data_source.txt', |
||||||
|
capture : true, |
||||||
|
command : [python, comp, '@INPUT@'], |
||||||
|
install : true, |
||||||
|
install_dir : 'subdir' |
||||||
|
) |
@ -0,0 +1,13 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
|
||||||
|
import sys |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
if len(sys.argv) != 2: |
||||||
|
print(sys.argv[0], 'input_file') |
||||||
|
sys.exit(1) |
||||||
|
ifile = open(sys.argv[1]).read() |
||||||
|
if ifile != 'This is a text only input file.\n': |
||||||
|
print('Malformed input') |
||||||
|
sys.exit(1) |
||||||
|
print('This is a binary output file.') |
Loading…
Reference in new issue