diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-12-13 12:22:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-13 12:22:11 +0200 |
| commit | de83e94b5a9ce0f540814cee40ef3746b6ebb824 (patch) | |
| tree | be5504f488f980b6e394b4a2801864485c4dd792 /test cases | |
| parent | 07679f0330ccc4ee3839e702d79ecdd349437593 (diff) | |
| parent | 2c83bd16fc03afd2d8605734dce1ffc1946bf3d2 (diff) | |
| download | meson-de83e94b5a9ce0f540814cee40ef3746b6ebb824.tar.gz | |
Merge pull request #1171 from centricular/fix-extracted-generated-prebuilt-object-targets-linking
Several fixes to how we handle objects in build targets
Diffstat (limited to 'test cases')
16 files changed, 133 insertions, 0 deletions
diff --git a/test cases/common/128 extract all shared library/extractor.h b/test cases/common/128 extract all shared library/extractor.h new file mode 100644 index 000000000..d0917a11b --- /dev/null +++ b/test cases/common/128 extract all shared library/extractor.h @@ -0,0 +1,6 @@ +#pragma once + +int func1(); +int func2(); +int func3(); +int func4(); diff --git a/test cases/common/128 extract all shared library/four.c b/test cases/common/128 extract all shared library/four.c new file mode 100644 index 000000000..5ca6696d9 --- /dev/null +++ b/test cases/common/128 extract all shared library/four.c @@ -0,0 +1,5 @@ +#include"extractor.h" + +int func4() { + return 4; +} diff --git a/test cases/common/128 extract all shared library/func1234.def b/test cases/common/128 extract all shared library/func1234.def new file mode 100644 index 000000000..d62c08d78 --- /dev/null +++ b/test cases/common/128 extract all shared library/func1234.def @@ -0,0 +1,5 @@ +EXPORTS + func1 + func2 + func3 + func4 diff --git a/test cases/common/128 extract all shared library/meson.build b/test cases/common/128 extract all shared library/meson.build new file mode 100644 index 000000000..7c24fdeeb --- /dev/null +++ b/test cases/common/128 extract all shared library/meson.build @@ -0,0 +1,10 @@ +project('extract all', 'c', 'cpp') + +a = static_library('a', 'one.c', 'two.c') +b = static_library('b', 'three.c', 'four.c') +c = shared_library('c', + objects : [a.extract_all_objects(), b.extract_all_objects()], + vs_module_defs : 'func1234.def') + +e = executable('proggie', 'prog.c', link_with : c) +test('extall', e) diff --git a/test cases/common/128 extract all shared library/one.c b/test cases/common/128 extract all shared library/one.c new file mode 100644 index 000000000..cfb01571d --- /dev/null +++ b/test cases/common/128 extract all shared library/one.c @@ -0,0 +1,5 @@ +#include"extractor.h" + +int func1() { + return 1; +} diff --git a/test cases/common/128 extract all shared library/prog.c b/test cases/common/128 extract all shared library/prog.c new file mode 100644 index 000000000..57a4c64dc --- /dev/null +++ b/test cases/common/128 extract all shared library/prog.c @@ -0,0 +1,10 @@ +#include"extractor.h" +#include<stdio.h> + +int main(int argc, char **argv) { + if((1+2+3+4) != (func1() + func2() + func3() + func4())) { + printf("Arithmetic is fail.\n"); + return 1; + } + return 0; +} diff --git a/test cases/common/128 extract all shared library/three.c b/test cases/common/128 extract all shared library/three.c new file mode 100644 index 000000000..c41004651 --- /dev/null +++ b/test cases/common/128 extract all shared library/three.c @@ -0,0 +1,5 @@ +#include"extractor.h" + +int func3() { + return 3; +} diff --git a/test cases/common/128 extract all shared library/two.c b/test cases/common/128 extract all shared library/two.c new file mode 100644 index 000000000..3ece5121f --- /dev/null +++ b/test cases/common/128 extract all shared library/two.c @@ -0,0 +1,5 @@ +#include"extractor.h" + +int func2() { + return 2; +} 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; +} |
