Test targets with only generated and prebuilt objects

pull/1171/head
Nirbheek Chauhan 8 years ago
parent 3fad3cbb81
commit 2c83bd16fc
  1. 2
      mesonbuild/build.py
  2. 2
      mesonbuild/interpreterbase.py
  3. 1
      test cases/common/129 object only target/installed_files.txt
  4. 45
      test cases/common/129 object only target/meson.build
  5. 18
      test cases/common/129 object only target/obj_generator.py
  6. 7
      test cases/common/129 object only target/prog.c
  7. 3
      test cases/common/129 object only target/source.c
  8. 3
      test cases/common/129 object only target/source2.c
  9. 2
      test cases/common/129 object only target/source2.def
  10. 3
      test cases/common/129 object only target/source3.c

@ -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 ' + \

@ -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:

@ -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)

@ -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))

@ -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();
}

@ -0,0 +1,3 @@
int func1_in_obj() {
return 0;
}

@ -0,0 +1,3 @@
int func2_in_obj() {
return 0;
}

@ -0,0 +1,3 @@
int func3_in_obj() {
return 0;
}
Loading…
Cancel
Save