For commands that always output to stdout and don't have a "-o" or "--output" or some other similar option, this 'capture' setting allows the build to capture the result and place it in the output file.pull/712/head
parent
dcaf2d7b3d
commit
70d94a5550
8 changed files with 54 additions and 7 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