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:
parent
6946029d16
commit
8a7ac6ba4c
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -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))
|
|
@ -0,0 +1,5 @@
|
|||
# Generate an object file manually.
|
||||
object = custom_target('object',
|
||||
input : 'source.c',
|
||||
output : outputname,
|
||||
command : [comp, cc, '@INPUT@', '@OUTPUT@'])
|
|
@ -0,0 +1,3 @@
|
|||
int func1_in_obj() {
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
e = executable('prog', 'prog.c', object)
|
|
@ -0,0 +1,5 @@
|
|||
int func1_in_obj();
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return func1_in_obj();
|
||||
}
|
Loading…
Reference in New Issue