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.pull/1523/head
parent
6946029d16
commit
8a7ac6ba4c
7 changed files with 49 additions and 1 deletions
@ -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