Pipeline backend is done and works.

pull/15/head
Jussi Pakkanen 12 years ago
parent 15aa29bf15
commit 7abe15a7ba
  1. 24
      backends.py
  2. 6
      interpreter.py
  3. 2
      test cases/30 pipeline/meson.build

@ -85,6 +85,7 @@ class Backend():
return
self.process_target_dependencies(target, outfile)
print('Generating target', name)
self.generate_custom_generator_rules(target, outfile)
outname = self.get_target_filename(target)
obj_list = []
if target.has_pch():
@ -347,6 +348,29 @@ class NinjaBackend(Backend):
outfile.write('\n')
outfile.write('\n')
def generate_custom_generator_rules(self, target, outfile):
for genlist in target.get_generated_sources():
generator = genlist.get_generator()
exe = generator.get_exe()
infilelist = genlist.get_infilelist()
outfilelist = genlist.get_outfilelist()
if len(infilelist) != len(outfilelist):
raise RuntimeError('Internal data structures broken.')
exe_file = os.path.join(self.environment.get_build_dir(), self.get_target_filename(exe))
base_args = generator.get_arglist()
for i in range(len(infilelist)):
infilename = os.path.join(self.build_to_src, infilelist[i])
outfilename = os.path.join(self.get_target_dir(target), outfilelist[i])
args = [x.replace("@INPUTNAME@", infilename).replace('@OUTPUTNAME@', outfilename)\
for x in base_args]
cmdlist = [exe_file] + args
build = 'build %s: CUSTOM_COMMAND %s | %s\n' % \
(ninja_quote(outfilename), ninja_quote(infilename), ninja_quote(self.get_target_filename(exe)))
command = ' COMMAND = %s\n\n' % \
' '.join(["'%s'" % ninja_quote(i) for i in cmdlist])
outfile.write(build)
outfile.write(command)
def generate_single_compile(self, target, outfile, src, is_generated=False):
compiler = self.get_compiler_for_source(src)
commands = self.generate_basic_compiler_flags(target, compiler)

@ -50,6 +50,9 @@ class Generator(InterpreterObject):
self.methods.update({'process' : self.process_method})
self.process_kwargs(kwargs)
def get_exe(self):
return self.exe
def process_kwargs(self, kwargs):
if 'arguments' not in kwargs:
raise InvalidArguments('Generator must have "arguments" keyword argument.')
@ -90,6 +93,9 @@ class Generator(InterpreterObject):
[gl.add_file(a) for a in args]
return gl
def get_arglist(self):
return self.arglist
class GeneratedList(InterpreterObject):
def __init__(self, generator):
InterpreterObject.__init__(self)

@ -9,3 +9,5 @@ arguments : ['@INPUTNAME@', '@OUTPUTNAME@'])
generated = gen.process('input_src.dat')
e2 = executable('prog', 'prog.c', gen_src : generated)
add_test('pipelined', e2)

Loading…
Cancel
Save