aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/105 generatorcustom
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/105 generatorcustom')
-rwxr-xr-xmeson/test cases/common/105 generatorcustom/catter.py14
-rwxr-xr-xmeson/test cases/common/105 generatorcustom/gen-resx.py9
-rwxr-xr-xmeson/test cases/common/105 generatorcustom/gen.py13
-rw-r--r--meson/test cases/common/105 generatorcustom/main.c8
-rw-r--r--meson/test cases/common/105 generatorcustom/meson.build28
-rw-r--r--meson/test cases/common/105 generatorcustom/res1.txt1
-rw-r--r--meson/test cases/common/105 generatorcustom/res2.txt1
7 files changed, 74 insertions, 0 deletions
diff --git a/meson/test cases/common/105 generatorcustom/catter.py b/meson/test cases/common/105 generatorcustom/catter.py
new file mode 100755
index 000000000..c2726723c
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/catter.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import sys
+
+output = sys.argv[-1]
+inputs = sys.argv[1:-1]
+
+with open(output, 'w') as ofile:
+ ofile.write('#pragma once\n')
+ for i in inputs:
+ with open(i) as ifile:
+ content = ifile.read()
+ ofile.write(content)
+ ofile.write('\n')
diff --git a/meson/test cases/common/105 generatorcustom/gen-resx.py b/meson/test cases/common/105 generatorcustom/gen-resx.py
new file mode 100755
index 000000000..242a962d8
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/gen-resx.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import sys
+
+ofile = sys.argv[1]
+num = sys.argv[2]
+
+with open(ofile, 'w') as f:
+ f.write(f'res{num}\n')
diff --git a/meson/test cases/common/105 generatorcustom/gen.py b/meson/test cases/common/105 generatorcustom/gen.py
new file mode 100755
index 000000000..1464008f9
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/gen.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import sys
+
+ifile = sys.argv[1]
+ofile = sys.argv[2]
+
+with open(ifile) as f:
+ resname = f.readline().strip()
+
+templ = 'const char %s[] = "%s";\n'
+with open(ofile, 'w') as f:
+ f.write(templ % (resname, resname))
diff --git a/meson/test cases/common/105 generatorcustom/main.c b/meson/test cases/common/105 generatorcustom/main.c
new file mode 100644
index 000000000..153dc12cb
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+#include "alltogether.h"
+
+int main(void) {
+ printf("%s - %s - %s - %s\n", res1, res2, res3, res4);
+ return 0;
+}
diff --git a/meson/test cases/common/105 generatorcustom/meson.build b/meson/test cases/common/105 generatorcustom/meson.build
new file mode 100644
index 000000000..2128d2164
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/meson.build
@@ -0,0 +1,28 @@
+project('generatorcustom', 'c')
+
+creator = find_program('gen.py')
+catter = find_program('catter.py')
+gen_resx = find_program('gen-resx.py')
+
+gen = generator(creator,
+ output: '@BASENAME@.h',
+ arguments : ['@INPUT@', '@OUTPUT@'])
+
+res3 = custom_target('gen-res3',
+ output : 'res3.txt',
+ command : [gen_resx, '@OUTPUT@', '3'])
+
+res4 = custom_target('gen-res4',
+ output : 'res4.txt',
+ command : [gen_resx, '@OUTPUT@', '4'])
+
+hs = gen.process('res1.txt', 'res2.txt', res3, res4[0])
+
+allinone = custom_target('alltogether',
+ input : hs,
+ output : 'alltogether.h',
+ command : [catter, '@INPUT@', '@OUTPUT@'])
+
+proggie = executable('proggie', 'main.c', allinone)
+
+test('proggie', proggie)
diff --git a/meson/test cases/common/105 generatorcustom/res1.txt b/meson/test cases/common/105 generatorcustom/res1.txt
new file mode 100644
index 000000000..6487c56ba
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/res1.txt
@@ -0,0 +1 @@
+res1
diff --git a/meson/test cases/common/105 generatorcustom/res2.txt b/meson/test cases/common/105 generatorcustom/res2.txt
new file mode 100644
index 000000000..0a8879d51
--- /dev/null
+++ b/meson/test cases/common/105 generatorcustom/res2.txt
@@ -0,0 +1 @@
+res2