 ===================================================================
 --- pylib/gyp/generator/ninja.py	(revision 0)
 +++ pylib/gyp/generator/ninja.py	(revision 0)
-@@ -0,0 +1,337 @@
+@@ -0,0 +1,358 @@
 +#!/usr/bin/python
 +
 +# Copyright (c) 2010 Google Inc. All rights reserved.

+  def WriteRule(self, name, command):
+    self.WriteLn('rule %s' % name)
+    self.WriteLn('  command = %s' % command)
+    self.WriteLn()
+
+  def WriteEdge(self, outputs, command, inputs,
+                order_only_inputs=[],

+                     use_prebuild_stamp=False)
+      self.WriteLn()
+
+    sources_predepends = []
+    extra_sources = []
+    if 'actions' in spec:
+      sources_predepends.append(
+        self.WriteActions(local_name, spec['actions'], extra_sources))
+
+    link_deps = []
+    sources = spec.get('sources', []) + extra_sources
+    if sources:
+      link_deps = self.WriteSources(config, sources, sources_predepends)
+
+    return self.WriteTarget(spec, config, link_deps or sources_predepends)
+
+  def WriteActions(self, local_name, actions, extra_sources):
+    all_outputs = []
+    for action in actions:
+      # First write out a rule for the action.
+      name = action['action_name']
+      command = gyp.common.EncodePOSIXShellList(action['action'])
+      if self.base_dir:
+        command = 'cd %s; %s' % (self.base_dir, command)
+      self.WriteRule(name=name, command=command)
+
+      inputs = [self.FullPath(i) for i in action['inputs']]
+      if int(action.get('process_outputs_as_sources', False)):
+        extra_sources += action['outputs']
+      outputs = [self.FullPath(o) for o in action['outputs']]
+
+      # Then write out an edge using the rule.
+      self.WriteEdge(outputs, name, inputs)
+      all_outputs += outputs
+
+      self.WriteLn()
+
+    # Write out a stamp file for all the actions.
+    stamp = self.OutputPath(self.FullPath(local_name + '.actions.stamp'))
+    self.WriteEdge([stamp], 'stamp', all_outputs)
+    return stamp
+
+  def WriteSources(self, config, sources, predepends):
+    self.WriteVariableList('defines', ['-D' + d for d in config.get('defines', [])])
+    def FixInclude(path):
+      path = os.path.normpath(os.path.join(self.base_dir, path))
