diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/common/52 object generator | |
parent | Initial commit. (diff) | |
download | meson-upstream.tar.xz meson-upstream.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test cases/common/52 object generator/meson.build | 34 | ||||
-rwxr-xr-x | test cases/common/52 object generator/obj_generator.py | 18 | ||||
-rw-r--r-- | test cases/common/52 object generator/prog.c | 7 | ||||
-rw-r--r-- | test cases/common/52 object generator/source.c | 3 | ||||
-rw-r--r-- | test cases/common/52 object generator/source2.c | 3 | ||||
-rw-r--r-- | test cases/common/52 object generator/source3.c | 3 |
6 files changed, 68 insertions, 0 deletions
diff --git a/test cases/common/52 object generator/meson.build b/test cases/common/52 object generator/meson.build new file mode 100644 index 0000000..e20da6f --- /dev/null +++ b/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/test cases/common/52 object generator/obj_generator.py b/test cases/common/52 object generator/obj_generator.py new file mode 100755 index 0000000..a33872a --- /dev/null +++ b/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/test cases/common/52 object generator/prog.c b/test cases/common/52 object generator/prog.c new file mode 100644 index 0000000..9841180 --- /dev/null +++ b/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/test cases/common/52 object generator/source.c b/test cases/common/52 object generator/source.c new file mode 100644 index 0000000..1dc08e1 --- /dev/null +++ b/test cases/common/52 object generator/source.c @@ -0,0 +1,3 @@ +int func1_in_obj(void) { + return 0; +} diff --git a/test cases/common/52 object generator/source2.c b/test cases/common/52 object generator/source2.c new file mode 100644 index 0000000..8024b97 --- /dev/null +++ b/test cases/common/52 object generator/source2.c @@ -0,0 +1,3 @@ +int func2_in_obj(void) { + return 0; +} diff --git a/test cases/common/52 object generator/source3.c b/test cases/common/52 object generator/source3.c new file mode 100644 index 0000000..c4362c4 --- /dev/null +++ b/test cases/common/52 object generator/source3.c @@ -0,0 +1,3 @@ +int func3_in_obj(void) { + return 0; +} |