parent
5f65255a66
commit
3a3be0f61b
6 changed files with 56 additions and 2 deletions
@ -0,0 +1,18 @@ |
||||
project('object generator', 'c') |
||||
|
||||
python = find_program('python3') |
||||
|
||||
# Note that this will not add a dependency to the compiler executable. |
||||
# Code will not be rebuilt if it changes. |
||||
comp = '@0@/@1@'.format(meson.current_source_dir(), 'obj_generator.py') |
||||
|
||||
# Generate a header file that needs to be included. |
||||
gen = generator(python, |
||||
output : '@BASENAME@.o', |
||||
arguments : [comp, '@INPUT@', '@OUTPUT@']) |
||||
|
||||
generated = gen.process('source.c') |
||||
|
||||
e = executable('prog', 'prog.c', generated) |
||||
|
||||
test('objgen', e) |
@ -0,0 +1,18 @@ |
||||
#!/usr/bin/python3 |
||||
|
||||
# Mimic a binary that generates an object file (e.g. windres). |
||||
|
||||
import sys, shutil, subprocess |
||||
|
||||
if __name__ == '__main__': |
||||
if len(sys.argv) != 3: |
||||
print(sys.argv[0], 'input_file output_file') |
||||
sys.exit(1) |
||||
ifile = sys.argv[1] |
||||
ofile = sys.argv[2] |
||||
if shutil.which('cl'): |
||||
cmd = ['cl', '/nologo', '/Fo'+ofile, '/c', ifile] |
||||
else: |
||||
cmd = ['cc', '-c', ifile, '-o', ofile] |
||||
sys.exit(subprocess.call(cmd)) |
||||
|
@ -0,0 +1,5 @@ |
||||
int func_in_obj(); |
||||
|
||||
int main(int argc, char **argv) { |
||||
return func_in_obj(); |
||||
} |
@ -0,0 +1,3 @@ |
||||
int func_in_obj() { |
||||
return 0; |
||||
} |
Loading…
Reference in new issue