From 3d5dd90432e5b18cc0d80ac562410776f93c9449 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 6 Feb 2013 20:00:59 +0200 Subject: [PATCH] Generate compile rules. --- generators.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/generators.py b/generators.py index 168c4b6ee..92bc51822 100755 --- a/generators.py +++ b/generators.py @@ -54,9 +54,27 @@ class NinjaGenerator(Generator): def __init__(self, build, interp): Generator.__init__(self, build, interp) + self.ninja_filename = 'build.ninja' def generate(self): - pass + outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename) + outfile = open(outfilename, 'w') + self.generate_rules(outfile) + + def generate_rules(self, outfile): + for compiler in self.build.compilers: + langname = compiler.get_language() + rule = 'rule %s_COMPILER\n' % langname + command = ' command = %s $FLAGS %s $out %s $in\n' % \ + (' '.join(compiler.get_exelist()),\ + ' '.join(compiler.get_output_flags()),\ + ' '.join(compiler.get_compile_only_flags())) + description = ' description = compiling %s object' % langname + outfile.write(rule) + outfile.write(command) + outfile.write(description) + outfile.write('\n') + outfile.write('\n') class ShellGenerator(Generator): def __init__(self, build, interp):