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 | |
parent | 3fad3cbb8184c412061ac5543b7f7d73efa4c946 (diff) | |
download | meson-2c83bd16fc03afd2d8605734dce1ffc1946bf3d2.zip meson-2c83bd16fc03afd2d8605734dce1ffc1946bf3d2.tar.gz meson-2c83bd16fc03afd2d8605734dce1ffc1946bf3d2.tar.bz2 |
Test targets with only generated and prebuilt objects
-rw-r--r-- | mesonbuild/build.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 2 | ||||
-rw-r--r-- | test cases/common/129 object only target/installed_files.txt | 1 | ||||
-rw-r--r-- | test cases/common/129 object only target/meson.build | 45 | ||||
-rwxr-xr-x | test cases/common/129 object only target/obj_generator.py | 18 | ||||
-rw-r--r-- | test cases/common/129 object only target/prog.c | 7 | ||||
-rw-r--r-- | test cases/common/129 object only target/source.c | 3 | ||||
-rw-r--r-- | test cases/common/129 object only target/source2.c | 3 | ||||
-rw-r--r-- | test cases/common/129 object only target/source2.def | 2 | ||||
-rw-r--r-- | test cases/common/129 object only target/source3.c | 3 |
10 files changed, 84 insertions, 2 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 5e270a2..106386c 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -327,7 +327,7 @@ class BuildTarget(): for s in objects: if hasattr(s, 'held_object'): s = s.held_object - if isinstance(s, (str, ExtractedObjects)): + if isinstance(s, (str, File, ExtractedObjects)): self.objects.append(s) elif isinstance(s, (GeneratedList, CustomTarget)): msg = 'Generated files are not allowed in the \'objects\' kwarg ' + \ diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 97814f4..af1e8fb 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -526,7 +526,7 @@ class InterpreterBase: def flatten(self, args): if isinstance(args, mparser.StringNode): return args.value - if isinstance(args, (int, str, InterpreterObject)): + if isinstance(args, (int, str, mesonlib.File, InterpreterObject)): return args result = [] for a in args: 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 0000000..c7dab9f --- /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 0000000..58d01d9 --- /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 0000000..0a4537b --- /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 0000000..60459d6 --- /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 0000000..7779b33 --- /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 0000000..29aad40 --- /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 0000000..a993ab8 --- /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 0000000..1580f1e --- /dev/null +++ b/test cases/common/129 object only target/source3.c @@ -0,0 +1,3 @@ +int func3_in_obj() { + return 0; +} |