Can generate sources with moc and uic.

pull/15/head
Jussi Pakkanen 12 years ago
parent 8f63a4ff81
commit 6cf0182037
  1. 16
      backends.py
  2. 4
      dependencies.py

@ -126,6 +126,7 @@ class Backend():
name = target.get_basename() name = target.get_basename()
if name in self.processed_targets: if name in self.processed_targets:
return return
self.process_dep_gens(outfile, target)
self.process_target_dependencies(target, outfile) self.process_target_dependencies(target, outfile)
print('Generating target', name) print('Generating target', name)
self.generate_custom_generator_rules(target, outfile) self.generate_custom_generator_rules(target, outfile)
@ -650,6 +651,21 @@ class NinjaBackend(Backend):
gcda_elem.add_item('description', 'Deleting gcda files') gcda_elem.add_item('description', 'Deleting gcda files')
gcda_elem.write(outfile) gcda_elem.write(outfile)
def process_dep_gens(self, outfile, target):
for rule in self.dep_rules.values():
srcs = target.get_original_kwargs().get(rule.src_keyword, [])
if isinstance(srcs, str):
srcs = [srcs]
for src in srcs:
plainname = os.path.split(src)[1]
basename = plainname.split('.')[0]
outname = rule.name_templ.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname)
outfilename = os.path.join(self.get_target_private_dir(target), outname)
infilename = os.path.join(self.build_to_src, target.get_source_subdir(), src)
rule = rule.name
elem = NinjaBuildElement(outfilename, rule, infilename)
elem.write(outfile)
def generate_ending(self, outfile): def generate_ending(self, outfile):
targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()] targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()]
elem = NinjaBuildElement('all', 'phony', targetlist) elem = NinjaBuildElement('all', 'phony', targetlist)

@ -331,10 +331,10 @@ class Qt5Dependency(Dependency):
def get_generate_rules(self): def get_generate_rules(self):
moc_rule = CustomRule([self.moc.get_command(), '@INFILE@', '-o', '@OUTFILE@'], moc_rule = CustomRule([self.moc.get_command(), '@INFILE@', '-o', '@OUTFILE@'],
'moc_%BASENAME%.cpp', 'moc_headers', 'moc_compile', 'moc_@BASENAME@.cpp', 'moc_headers', 'moc_compile',
'Compiling @INFILE@ with the moc preprocessor') 'Compiling @INFILE@ with the moc preprocessor')
ui_rule = CustomRule([self.uic.get_command(), '@INFILE@', '-o', '@OUTFILE@'], ui_rule = CustomRule([self.uic.get_command(), '@INFILE@', '-o', '@OUTFILE@'],
'ui_%BASENAME%.h', 'ui_files', 'ui_compile', 'ui_@BASENAME@.h', 'ui_files', 'ui_compile',
'Compiling @INFILE@ with the ui compiler') 'Compiling @INFILE@ with the ui compiler')
return [moc_rule, ui_rule] return [moc_rule, ui_rule]

Loading…
Cancel
Save