vs: Fix custom target generated object paths

The paths are already relative to the target dir.

Includes a test for this which generates and builds in subdirs. If all
the generation and usage is done in the build root, this bug will
obviously not be triggered.
This commit is contained in:
Nirbheek Chauhan 2017-03-23 12:44:13 +05:30 committed by Jussi Pakkanen
parent 6946029d16
commit 8a7ac6ba4c
7 changed files with 49 additions and 1 deletions

View File

@ -918,7 +918,7 @@ class Vs2010Backend(backends.Backend):
assert(isinstance(o, str))
additional_objects.append(o)
for o in custom_objs:
additional_objects.append(self.relpath(o, self.get_target_dir(target)))
additional_objects.append(o)
if len(additional_links) > 0:
additional_links.append('%(AdditionalDependencies)')
ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links)

View File

@ -0,0 +1,16 @@
project('custom target object output', 'c')
comp = find_program('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)
subdir('objdir')
subdir('progdir')
test('objgen', e)

View File

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

View File

@ -0,0 +1,5 @@
# Generate an object file manually.
object = custom_target('object',
input : 'source.c',
output : outputname,
command : [comp, cc, '@INPUT@', '@OUTPUT@'])

View File

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

View File

@ -0,0 +1 @@
e = executable('prog', 'prog.c', object)

View File

@ -0,0 +1,5 @@
int func1_in_obj();
int main(int argc, char **argv) {
return func1_in_obj();
}