aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/common/135 custom target object output
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/common/135 custom target object output')
-rw-r--r--meson/test cases/common/135 custom target object output/meson.build16
-rw-r--r--meson/test cases/common/135 custom target object output/obj_generator.py18
-rw-r--r--meson/test cases/common/135 custom target object output/objdir/meson.build5
-rw-r--r--meson/test cases/common/135 custom target object output/objdir/source.c3
-rw-r--r--meson/test cases/common/135 custom target object output/progdir/meson.build1
-rw-r--r--meson/test cases/common/135 custom target object output/progdir/prog.c5
6 files changed, 48 insertions, 0 deletions
diff --git a/meson/test cases/common/135 custom target object output/meson.build b/meson/test cases/common/135 custom target object output/meson.build
new file mode 100644
index 000000000..ede165bd4
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/meson.build
@@ -0,0 +1,16 @@
+project('custom target object output', 'c')
+
+comp = find_program('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)
+
+subdir('objdir')
+subdir('progdir')
+
+test('objgen', e)
diff --git a/meson/test cases/common/135 custom target object output/obj_generator.py b/meson/test cases/common/135 custom target object output/obj_generator.py
new file mode 100644
index 000000000..a33872aac
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/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/135 custom target object output/objdir/meson.build b/meson/test cases/common/135 custom target object output/objdir/meson.build
new file mode 100644
index 000000000..0d7f6c259
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/objdir/meson.build
@@ -0,0 +1,5 @@
+# Generate an object file manually.
+object = custom_target('object',
+ input : 'source.c',
+ output : outputname,
+ command : [comp, cc, '@INPUT@', '@OUTPUT@'])
diff --git a/meson/test cases/common/135 custom target object output/objdir/source.c b/meson/test cases/common/135 custom target object output/objdir/source.c
new file mode 100644
index 000000000..1dc08e168
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/objdir/source.c
@@ -0,0 +1,3 @@
+int func1_in_obj(void) {
+ return 0;
+}
diff --git a/meson/test cases/common/135 custom target object output/progdir/meson.build b/meson/test cases/common/135 custom target object output/progdir/meson.build
new file mode 100644
index 000000000..4216c24a6
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/progdir/meson.build
@@ -0,0 +1 @@
+e = executable('prog', 'prog.c', object)
diff --git a/meson/test cases/common/135 custom target object output/progdir/prog.c b/meson/test cases/common/135 custom target object output/progdir/prog.c
new file mode 100644
index 000000000..bc3caf3e2
--- /dev/null
+++ b/meson/test cases/common/135 custom target object output/progdir/prog.c
@@ -0,0 +1,5 @@
+int func1_in_obj(void);
+
+int main(void) {
+ return func1_in_obj();
+}