1project('object generator', 'c') 2 3python = find_program('python3', required : false) 4if not python.found() 5 python = find_program('python') 6endif 7 8# Note that this will not add a dependency to the compiler executable. 9# Code will not be rebuilt if it changes. 10comp = '@0@/@1@'.format(meson.current_source_dir(), 'obj_generator.py') 11 12if host_machine.system() == 'windows' 13 outputname = '@BASENAME@.obj' 14else 15 outputname = '@BASENAME@.o' 16endif 17 18cc = meson.get_compiler('c').cmd_array().get(-1) 19# Generate an object file manually. 20gen = generator(python, 21 output : outputname, 22 arguments : [comp, cc, '@INPUT@', '@OUTPUT@']) 23 24generated = gen.process(['source.c', 'source2.c']) 25 26# Generate an object file with indexed OUTPUT replacement. 27gen2 = generator(python, 28 output : outputname, 29 arguments : [comp, cc, '@INPUT@', '@OUTPUT0@']) 30generated2 = gen2.process(['source3.c']) 31 32e = executable('prog', 'prog.c', generated, generated2) 33 34test('objgen', e)