aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/50 custom target chain
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/50 custom target chain')
-rw-r--r--meson/test cases/common/50 custom target chain/data_source.txt1
-rw-r--r--meson/test cases/common/50 custom target chain/meson.build34
-rwxr-xr-xmeson/test cases/common/50 custom target chain/my_compiler.py15
-rwxr-xr-xmeson/test cases/common/50 custom target chain/my_compiler2.py15
-rw-r--r--meson/test cases/common/50 custom target chain/test.json6
-rw-r--r--meson/test cases/common/50 custom target chain/usetarget/meson.build8
-rw-r--r--meson/test cases/common/50 custom target chain/usetarget/myexe.c6
-rwxr-xr-xmeson/test cases/common/50 custom target chain/usetarget/subcomp.py7
8 files changed, 92 insertions, 0 deletions
diff --git a/meson/test cases/common/50 custom target chain/data_source.txt b/meson/test cases/common/50 custom target chain/data_source.txt
new file mode 100644
index 000000000..0c23cc0c3
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/data_source.txt
@@ -0,0 +1 @@
+This is a text only input file.
diff --git a/meson/test cases/common/50 custom target chain/meson.build b/meson/test cases/common/50 custom target chain/meson.build
new file mode 100644
index 000000000..138f795bd
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/meson.build
@@ -0,0 +1,34 @@
+project('custom target', 'c')
+
+python = find_program('python3', required : false)
+if not python.found()
+ python = find_program('python')
+endif
+
+# files() is the correct way to do this, but some people
+# do this so test that it works.
+comp = '@0@/@1@'.format(meson.current_source_dir(), 'my_compiler.py')
+comp2 = '@0@/@1@'.format(meson.current_source_dir(), 'my_compiler2.py')
+infile = files('data_source.txt')[0]
+
+mytarget = custom_target('bindat',
+ output : 'data.dat',
+ command : [python, comp, infile, '@OUTPUT@'],
+)
+
+mytarget2 = custom_target('bindat2',
+ output : 'data2.dat',
+ command : [python, comp2, mytarget, '@OUTPUT@'],
+ install : true,
+ install_dir : 'subdir'
+)
+
+mytarget3 = custom_target('bindat3',
+ output : 'data3.dat',
+ input : [mytarget],
+ command : [python, comp2, '@INPUT@', '@OUTPUT@'],
+ install : true,
+ install_dir : 'subdir'
+)
+
+subdir('usetarget')
diff --git a/meson/test cases/common/50 custom target chain/my_compiler.py b/meson/test cases/common/50 custom target chain/my_compiler.py
new file mode 100755
index 000000000..d99029bcc
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/my_compiler.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import sys
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print(sys.argv[0], 'input_file output_file')
+ sys.exit(1)
+ with open(sys.argv[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], 'w') as ofile:
+ ofile.write('This is a binary output file.\n')
diff --git a/meson/test cases/common/50 custom target chain/my_compiler2.py b/meson/test cases/common/50 custom target chain/my_compiler2.py
new file mode 100755
index 000000000..22ec7897b
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/my_compiler2.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import sys
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print(sys.argv[0], 'input_file output_file')
+ sys.exit(1)
+ with open(sys.argv[1]) as f:
+ ifile = f.read()
+ if ifile != 'This is a binary output file.\n':
+ print('Malformed input')
+ sys.exit(1)
+ with open(sys.argv[2], 'w') as ofile:
+ ofile.write('This is a different binary output file.\n')
diff --git a/meson/test cases/common/50 custom target chain/test.json b/meson/test cases/common/50 custom target chain/test.json
new file mode 100644
index 000000000..d6b0fa9b8
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/subdir/data2.dat"},
+ {"type": "file", "file": "usr/subdir/data3.dat"}
+ ]
+}
diff --git a/meson/test cases/common/50 custom target chain/usetarget/meson.build b/meson/test cases/common/50 custom target chain/usetarget/meson.build
new file mode 100644
index 000000000..9aece8ce9
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/usetarget/meson.build
@@ -0,0 +1,8 @@
+e = executable('myexe', 'myexe.c')
+subexe = find_program('subcomp.py')
+
+custom_target('use_exe',
+ input : e,
+ output : 'subout.res',
+ command : [subexe, '@INPUT@', '@OUTPUT@'],
+)
diff --git a/meson/test cases/common/50 custom target chain/usetarget/myexe.c b/meson/test cases/common/50 custom target chain/usetarget/myexe.c
new file mode 100644
index 000000000..33311332e
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/usetarget/myexe.c
@@ -0,0 +1,6 @@
+#include<stdio.h>
+
+int main(void) {
+ printf("I am myexe.\n");
+ return 0;
+}
diff --git a/meson/test cases/common/50 custom target chain/usetarget/subcomp.py b/meson/test cases/common/50 custom target chain/usetarget/subcomp.py
new file mode 100755
index 000000000..52dc0bbb5
--- /dev/null
+++ b/meson/test cases/common/50 custom target chain/usetarget/subcomp.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+
+import sys
+
+with open(sys.argv[1], 'rb') as ifile:
+ with open(sys.argv[2], 'w') as ofile:
+ ofile.write('Everything ok.\n')