aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/52 object generator
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/52 object generator')
-rw-r--r--meson/test cases/common/52 object generator/meson.build34
-rwxr-xr-xmeson/test cases/common/52 object generator/obj_generator.py18
-rw-r--r--meson/test cases/common/52 object generator/prog.c7
-rw-r--r--meson/test cases/common/52 object generator/source.c3
-rw-r--r--meson/test cases/common/52 object generator/source2.c3
-rw-r--r--meson/test cases/common/52 object generator/source3.c3
6 files changed, 68 insertions, 0 deletions
diff --git a/meson/test cases/common/52 object generator/meson.build b/meson/test cases/common/52 object generator/meson.build
new file mode 100644
index 000000000..e20da6f46
--- /dev/null
+++ b/meson/test cases/common/52 object generator/meson.build
@@ -0,0 +1,34 @@
+project('object generator', 'c')
+
+python = find_program('python3', required : false)
+if not python.found()
+ python = find_program('python')
+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(), 'obj_generator.py')
+
+if host_machine.system() == 'windows'
+ outputname = '@BASENAME@.obj'
+else
+ outputname = '@BASENAME@.o'
+endif
+
+cc = meson.get_compiler('c').cmd_array().get(-1)
+# Generate an object file manually.
+gen = generator(python,
+ output : outputname,
+ arguments : [comp, cc, '@INPUT@', '@OUTPUT@'])
+
+generated = gen.process(['source.c', 'source2.c'])
+
+# Generate an object file with indexed OUTPUT replacement.
+gen2 = generator(python,
+ output : outputname,
+ arguments : [comp, cc, '@INPUT@', '@OUTPUT0@'])
+generated2 = gen2.process(['source3.c'])
+
+e = executable('prog', 'prog.c', generated, generated2)
+
+test('objgen', e) \ No newline at end of file
diff --git a/meson/test cases/common/52 object generator/obj_generator.py b/meson/test cases/common/52 object generator/obj_generator.py
new file mode 100755
index 000000000..a33872aac
--- /dev/null
+++ b/meson/test cases/common/52 object generator/obj_generator.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+# Mimic a binary that generates an object file (e.g. windres).
+
+import sys, subprocess
+
+if __name__ == '__main__':
+ if len(sys.argv) != 4:
+ print(sys.argv[0], 'compiler input_file output_file')
+ sys.exit(1)
+ compiler = sys.argv[1]
+ ifile = sys.argv[2]
+ ofile = sys.argv[3]
+ if compiler.endswith('cl'):
+ cmd = [compiler, '/nologo', '/MDd', '/Fo' + ofile, '/c', ifile]
+ else:
+ cmd = [compiler, '-c', ifile, '-o', ofile]
+ sys.exit(subprocess.call(cmd))
diff --git a/meson/test cases/common/52 object generator/prog.c b/meson/test cases/common/52 object generator/prog.c
new file mode 100644
index 000000000..9841180d0
--- /dev/null
+++ b/meson/test cases/common/52 object generator/prog.c
@@ -0,0 +1,7 @@
+int func1_in_obj(void);
+int func2_in_obj(void);
+int func3_in_obj(void);
+
+int main(void) {
+ return func1_in_obj() + func2_in_obj() + func3_in_obj();
+}
diff --git a/meson/test cases/common/52 object generator/source.c b/meson/test cases/common/52 object generator/source.c
new file mode 100644
index 000000000..1dc08e168
--- /dev/null
+++ b/meson/test cases/common/52 object generator/source.c
@@ -0,0 +1,3 @@
+int func1_in_obj(void) {
+ return 0;
+}
diff --git a/meson/test cases/common/52 object generator/source2.c b/meson/test cases/common/52 object generator/source2.c
new file mode 100644
index 000000000..8024b9714
--- /dev/null
+++ b/meson/test cases/common/52 object generator/source2.c
@@ -0,0 +1,3 @@
+int func2_in_obj(void) {
+ return 0;
+}
diff --git a/meson/test cases/common/52 object generator/source3.c b/meson/test cases/common/52 object generator/source3.c
new file mode 100644
index 000000000..c4362c4d6
--- /dev/null
+++ b/meson/test cases/common/52 object generator/source3.c
@@ -0,0 +1,3 @@
+int func3_in_obj(void) {
+ return 0;
+}