diff options
Diffstat (limited to 'test cases/common/135 custom target object output')
6 files changed, 48 insertions, 0 deletions
diff --git a/test cases/common/135 custom target object output/meson.build b/test cases/common/135 custom target object output/meson.build new file mode 100644 index 0000000..ede165b --- /dev/null +++ b/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/test cases/common/135 custom target object output/obj_generator.py b/test cases/common/135 custom target object output/obj_generator.py new file mode 100644 index 0000000..a33872a --- /dev/null +++ b/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/test cases/common/135 custom target object output/objdir/meson.build b/test cases/common/135 custom target object output/objdir/meson.build new file mode 100644 index 0000000..0d7f6c2 --- /dev/null +++ b/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/test cases/common/135 custom target object output/objdir/source.c b/test cases/common/135 custom target object output/objdir/source.c new file mode 100644 index 0000000..1dc08e1 --- /dev/null +++ b/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/test cases/common/135 custom target object output/progdir/meson.build b/test cases/common/135 custom target object output/progdir/meson.build new file mode 100644 index 0000000..4216c24 --- /dev/null +++ b/test cases/common/135 custom target object output/progdir/meson.build @@ -0,0 +1 @@ +e = executable('prog', 'prog.c', object) diff --git a/test cases/common/135 custom target object output/progdir/prog.c b/test cases/common/135 custom target object output/progdir/prog.c new file mode 100644 index 0000000..bc3caf3 --- /dev/null +++ b/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(); +} |