 +      config_name = spec['default_configuration']
 +    config = spec['configurations'][config_name]
 +
-+    writer = NinjaWriter(linkable_outputs, order_only_outputs,
-+                         base_path, output_file)
++    writer = NinjaWriter(target_outputs, target_links, base_path, output_file)
 +    subninjas.add(ninja_path)
 +
-+    output = writer.WriteSpec(spec, config)
-+    if 'library' in spec['type']:
-+      linkable_outputs[qualified_target] = output
-+    else:
-+      order_only_outputs[qualified_target] = output
-+
-+    if qualified_target in all_targets:
-+      all_outputs.add(output)
++    output, output_link_deps = writer.WriteSpec(spec, config)
++    if output:
++      print output, '=>', output_link_deps
++      target_outputs[qualified_target] = output
++
++      if qualified_target in all_targets:
++        all_outputs.add(output)
++
++    if output_link_deps:
++      target_links[qualified_target] = output_link_deps
 +
 +  for ninja in subninjas:
 +    print >>master_ninja, 'subninja', ninja

+    # if any.
+    self.prebuild_stamp = None
+    if 'dependencies' in spec:
+      for d in spec['dependencies']:
+        dep = self.linkable_outputs.get(d)
+        if dep:
+          prebuild_deps.append(dep)
+        dep = self.order_only_outputs.get(d)
+        if dep:
+          prebuild_deps.append(dep)
+    if prebuild_deps:
+      self.prebuild_stamp = self.StampPath('predepends')
+      self.WriteEdge([self.prebuild_stamp], 'stamp', prebuild_deps,

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