diff options
| author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-09 13:36:13 +0530 |
|---|---|---|
| committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-13 09:37:48 +0530 |
| commit | 2c83bd16fc03afd2d8605734dce1ffc1946bf3d2 (patch) | |
| tree | 8eefd42ddd79dfda4b4fb90dada8e2efb082bfb7 /test cases | |
| parent | 3fad3cbb8184c412061ac5543b7f7d73efa4c946 (diff) | |
| download | meson-2c83bd16fc03afd2d8605734dce1ffc1946bf3d2.tar.gz | |
Test targets with only generated and prebuilt objects
Diffstat (limited to 'test cases')
8 files changed, 82 insertions, 0 deletions
diff --git a/test cases/common/129 object only target/installed_files.txt b/test cases/common/129 object only target/installed_files.txt new file mode 100644 index 000000000..c7dab9f6f --- /dev/null +++ b/test cases/common/129 object only target/installed_files.txt @@ -0,0 +1 @@ +usr/bin/prog?exe diff --git a/test cases/common/129 object only target/meson.build b/test cases/common/129 object only target/meson.build new file mode 100644 index 000000000..58d01d930 --- /dev/null +++ b/test cases/common/129 object only target/meson.build @@ -0,0 +1,45 @@ +project('object generator', 'c') + +# 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, '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) + +e = executable('prog', 'prog.c', link_with : [obj, shr, stc], + install : true) + +test('objgen', e) diff --git a/test cases/common/129 object only target/obj_generator.py b/test cases/common/129 object only target/obj_generator.py new file mode 100755 index 000000000..0a4537bb6 --- /dev/null +++ b/test cases/common/129 object only target/obj_generator.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Mimic a binary that generates an object file (e.g. windres). + +import sys, shutil, 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/129 object only target/prog.c b/test cases/common/129 object only target/prog.c new file mode 100644 index 000000000..60459d6ed --- /dev/null +++ b/test cases/common/129 object only target/prog.c @@ -0,0 +1,7 @@ +int func1_in_obj(); +int func2_in_obj(); +int func3_in_obj(); + +int main(int argc, char **argv) { + return func1_in_obj() + func2_in_obj() + func3_in_obj(); +} diff --git a/test cases/common/129 object only target/source.c b/test cases/common/129 object only target/source.c new file mode 100644 index 000000000..7779b332c --- /dev/null +++ b/test cases/common/129 object only target/source.c @@ -0,0 +1,3 @@ +int func1_in_obj() { + return 0; +} diff --git a/test cases/common/129 object only target/source2.c b/test cases/common/129 object only target/source2.c new file mode 100644 index 000000000..29aad40f3 --- /dev/null +++ b/test cases/common/129 object only target/source2.c @@ -0,0 +1,3 @@ +int func2_in_obj() { + return 0; +} diff --git a/test cases/common/129 object only target/source2.def b/test cases/common/129 object only target/source2.def new file mode 100644 index 000000000..a993ab8ca --- /dev/null +++ b/test cases/common/129 object only target/source2.def @@ -0,0 +1,2 @@ +EXPORTS + func2_in_obj diff --git a/test cases/common/129 object only target/source3.c b/test cases/common/129 object only target/source3.c new file mode 100644 index 000000000..1580f1ed4 --- /dev/null +++ b/test cases/common/129 object only target/source3.c @@ -0,0 +1,3 @@ +int func3_in_obj() { + return 0; +} |
