summaryrefslogtreecommitdiffstats
path: root/test cases/common/121 object only target
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/common/121 object only target')
-rw-r--r--test cases/common/121 object only target/meson.build51
-rwxr-xr-xtest cases/common/121 object only target/obj_generator.py20
-rw-r--r--test cases/common/121 object only target/objdir/meson.build27
-rw-r--r--test cases/common/121 object only target/objdir/source4.c3
-rw-r--r--test cases/common/121 object only target/objdir/source5.c3
-rw-r--r--test cases/common/121 object only target/objdir/source6.c3
-rw-r--r--test cases/common/121 object only target/prog.c11
-rw-r--r--test cases/common/121 object only target/source.c3
-rw-r--r--test cases/common/121 object only target/source2.c3
-rw-r--r--test cases/common/121 object only target/source2.def2
-rw-r--r--test cases/common/121 object only target/source3.c3
-rw-r--r--test cases/common/121 object only target/test.json6
12 files changed, 135 insertions, 0 deletions
diff --git a/test cases/common/121 object only target/meson.build b/test cases/common/121 object only target/meson.build
new file mode 100644
index 0000000..c3c4e52
--- /dev/null
+++ b/test cases/common/121 object only target/meson.build
@@ -0,0 +1,51 @@
+project('object generator', 'c')
+
+if meson.backend() == 'xcode'
+ error('MESON_SKIP_TEST object-only libraries not supported in Xcode. Patches welcome.')
+endif
+
+# FIXME: Note that this will not add a dependency to the compiler executable.
+# Code will not be rebuilt if it changes.
+comp = find_program('obj_generator.py')
+
+if host_machine.system() == 'windows'
+ ext = '.obj'
+else
+ ext = '.o'
+endif
+
+cc = meson.get_compiler('c').cmd_array().get(-1)
+
+# Generate an object file with configure_file to mimic prebuilt objects
+# provided by the source tree
+source1 = configure_file(input : 'source.c',
+ output : 'source' + ext,
+ command : [comp, cc, files('source.c'),
+ join_paths(meson.current_build_dir(), 'source' + ext)])
+
+obj = static_library('obj', objects : source1)
+
+# Generate an object file manually.
+gen = generator(comp,
+ output : '@BASENAME@' + ext,
+ arguments : [cc, '@INPUT@', '@OUTPUT@'])
+
+generated = gen.process(['source2.c'])
+
+shr = shared_library('shr', generated,
+ vs_module_defs : 'source2.def')
+
+# Generate an object file with indexed OUTPUT replacement.
+gen2 = generator(comp,
+ output : '@BASENAME@' + ext,
+ arguments : [cc, '@INPUT@', '@OUTPUT0@'])
+generated2 = gen2.process(['source3.c'])
+
+stc = static_library('stc', generated2)
+
+subdir('objdir')
+
+e = executable('prog', 'prog.c', link_with : [obj, shr, stc, subdirfilebuilt_obj, subdirfile_obj, subdirstr_obj],
+ install : true)
+
+test('objgen', e)
diff --git a/test cases/common/121 object only target/obj_generator.py b/test cases/common/121 object only target/obj_generator.py
new file mode 100755
index 0000000..afdbc09
--- /dev/null
+++ b/test cases/common/121 object only target/obj_generator.py
@@ -0,0 +1,20 @@
+#!/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]
+ elif sys.platform == 'sunos5':
+ cmd = [compiler, '-fpic', '-c', ifile, '-o', ofile]
+ else:
+ cmd = [compiler, '-c', ifile, '-o', ofile]
+ sys.exit(subprocess.call(cmd))
diff --git a/test cases/common/121 object only target/objdir/meson.build b/test cases/common/121 object only target/objdir/meson.build
new file mode 100644
index 0000000..631c1a1
--- /dev/null
+++ b/test cases/common/121 object only target/objdir/meson.build
@@ -0,0 +1,27 @@
+
+#mesonlib.File built
+source4 = configure_file(input : 'source4.c',
+ output : 'source4' + ext,
+ command : [comp, cc, files('source4.c'),
+ join_paths(meson.current_build_dir(), 'source4' + ext)])
+
+subdirfilebuilt_obj = static_library('subdirfilebuilt_obj', objects : source4)
+
+
+#mesonlib.File not built
+configure_file(input : 'source5.c',
+ output : 'source5' + ext,
+ command : [comp, cc, files('source5.c'),
+ join_paths(meson.current_build_dir(), 'source5' + ext)])
+
+subdirfile_obj = static_library('subdirfile_obj', objects : files(meson.current_build_dir()/'source5' + ext))
+
+
+#str
+configure_file(input : 'source6.c',
+ output : 'source6' + ext,
+ command : [comp, cc, files('source6.c'),
+ join_paths(meson.current_build_dir(), 'source6' + ext)])
+
+
+subdirstr_obj = static_library('subdirstr_obj', objects : meson.current_build_dir()/'source6' + ext)
diff --git a/test cases/common/121 object only target/objdir/source4.c b/test cases/common/121 object only target/objdir/source4.c
new file mode 100644
index 0000000..83f4fab
--- /dev/null
+++ b/test cases/common/121 object only target/objdir/source4.c
@@ -0,0 +1,3 @@
+int func4_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/objdir/source5.c b/test cases/common/121 object only target/objdir/source5.c
new file mode 100644
index 0000000..c512fc3
--- /dev/null
+++ b/test cases/common/121 object only target/objdir/source5.c
@@ -0,0 +1,3 @@
+int func5_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/objdir/source6.c b/test cases/common/121 object only target/objdir/source6.c
new file mode 100644
index 0000000..adcf2cd
--- /dev/null
+++ b/test cases/common/121 object only target/objdir/source6.c
@@ -0,0 +1,3 @@
+int func6_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/prog.c b/test cases/common/121 object only target/prog.c
new file mode 100644
index 0000000..a27663b
--- /dev/null
+++ b/test cases/common/121 object only target/prog.c
@@ -0,0 +1,11 @@
+int func1_in_obj(void);
+int func2_in_obj(void);
+int func3_in_obj(void);
+int func4_in_obj(void);
+int func5_in_obj(void);
+int func6_in_obj(void);
+
+int main(void) {
+ return func1_in_obj() + func2_in_obj() + func3_in_obj()
+ + func4_in_obj() + func5_in_obj() + func6_in_obj();
+}
diff --git a/test cases/common/121 object only target/source.c b/test cases/common/121 object only target/source.c
new file mode 100644
index 0000000..1dc08e1
--- /dev/null
+++ b/test cases/common/121 object only target/source.c
@@ -0,0 +1,3 @@
+int func1_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/source2.c b/test cases/common/121 object only target/source2.c
new file mode 100644
index 0000000..8024b97
--- /dev/null
+++ b/test cases/common/121 object only target/source2.c
@@ -0,0 +1,3 @@
+int func2_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/source2.def b/test cases/common/121 object only target/source2.def
new file mode 100644
index 0000000..a993ab8
--- /dev/null
+++ b/test cases/common/121 object only target/source2.def
@@ -0,0 +1,2 @@
+EXPORTS
+ func2_in_obj
diff --git a/test cases/common/121 object only target/source3.c b/test cases/common/121 object only target/source3.c
new file mode 100644
index 0000000..c4362c4
--- /dev/null
+++ b/test cases/common/121 object only target/source3.c
@@ -0,0 +1,3 @@
+int func3_in_obj(void) {
+ return 0;
+}
diff --git a/test cases/common/121 object only target/test.json b/test cases/common/121 object only target/test.json
new file mode 100644
index 0000000..135300d
--- /dev/null
+++ b/test cases/common/121 object only target/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ {"type": "exe", "file": "usr/bin/prog"},
+ {"type": "pdb", "file": "usr/bin/prog"}
+ ]
+}