summaryrefslogtreecommitdiff
path: root/test cases/common
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-02-15 21:26:31 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2017-02-17 15:42:12 -0500
commit15b6915954c7c3d7a06455aeb7995524ac43ff3b (patch)
tree13d44490c03fe116e5961ec80f82c22f3cf25bd8 /test cases/common
parent16adedf6bc941745d3f10a2ad70fe710dfe1b206 (diff)
downloadmeson-15b6915954c7c3d7a06455aeb7995524ac43ff3b.tar.gz
custom_target: Recursively flatten `command:`
Without this, files() in the arguments give an error because it's a list of mesonlib.File objects: Array as argument 1 contains a non-string. It also breaks in nested lists. Includes a test for this.
Diffstat (limited to 'test cases/common')
-rw-r--r--test cases/common/56 custom target/meson.build4
-rwxr-xr-xtest cases/common/56 custom target/my_compiler.py15
2 files changed, 13 insertions, 6 deletions
diff --git a/test cases/common/56 custom target/meson.build b/test cases/common/56 custom target/meson.build
index fd59fbd80..2e6f69cf9 100644
--- a/test cases/common/56 custom target/meson.build
+++ b/test cases/common/56 custom target/meson.build
@@ -8,11 +8,13 @@ endif
# 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')
+# Test that files() in command: works. The compiler just discards it.
+useless = files('installed_files.txt')
mytarget = custom_target('bindat',
output : 'data.dat',
input : 'data_source.txt',
-command : [python, comp, '--input=@INPUT@', '--output=@OUTPUT@'],
+command : [python, comp, '--input=@INPUT@', '--output=@OUTPUT@', useless],
install : true,
install_dir : 'subdir'
)
diff --git a/test cases/common/56 custom target/my_compiler.py b/test cases/common/56 custom target/my_compiler.py
index 4ba2da64e..f46d23a91 100755
--- a/test cases/common/56 custom target/my_compiler.py
+++ b/test cases/common/56 custom target/my_compiler.py
@@ -1,16 +1,21 @@
#!/usr/bin/env python3
+import os
import sys
+assert(os.path.exists(sys.argv[3]))
+
+args = sys.argv[:-1]
+
if __name__ == '__main__':
- if len(sys.argv) != 3 or not sys.argv[1].startswith('--input') or \
- not sys.argv[2].startswith('--output'):
- print(sys.argv[0], '--input=input_file --output=output_file')
+ if len(args) != 3 or not args[1].startswith('--input') or \
+ not args[2].startswith('--output'):
+ print(args[0], '--input=input_file --output=output_file')
sys.exit(1)
- with open(sys.argv[1].split('=')[1]) as f:
+ with open(args[1].split('=')[1]) as f:
ifile = f.read()
if ifile != 'This is a text only input file.\n':
print('Malformed input')
sys.exit(1)
- with open(sys.argv[2].split('=')[1], 'w') as ofile:
+ with open(args[2].split('=')[1], 'w') as ofile:
ofile.write('This is a binary output file.\n')