Fix Rust dependency resolution.

Previously the Rust example always rebuilt all binaries
due to the .d file including a rule to regenerate itself.

Change-Id: Ia8389a9651528212c69079783fcc5a9e2426aa82
Bug: crbug.com/gn/89
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/7040
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Reviewed-by: Petr Hosek <phosek@google.com>
Commit-Queue: Petr Hosek <phosek@google.com>
diff --git a/examples/rust_example/build/BUILD.gn b/examples/rust_example/build/BUILD.gn
index 3b6b8dc..ebfaa64 100644
--- a/examples/rust_example/build/BUILD.gn
+++ b/examples/rust_example/build/BUILD.gn
@@ -2,7 +2,7 @@
   tool("rust_bin") {
     depfile = "{{target_out_dir}}/{{crate_name}}.d"
     outfile = "{{target_out_dir}}/{{crate_name}}"
-    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
+    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link -Z dep-info-omit-d-target {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
     description = "RUST $outfile"
     outputs = [ outfile ]
   }
@@ -10,7 +10,7 @@
   tool("rust_staticlib") {
     depfile = "{{target_out_dir}}/{{crate_name}}.d"
     outfile = "{{target_out_dir}}/{{crate_name}}.a"
-    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
+    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link -Z dep-info-omit-d-target {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
     description = "RUST $outfile"
     outputs = [ outfile ]
   }
@@ -18,7 +18,7 @@
   tool("rust_rlib") {
     depfile = "{{target_out_dir}}/{{crate_name}}.d"
     outfile = "{{target_out_dir}}/lib{{crate_name}}.rlib"
-    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
+    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link -Z dep-info-omit-d-target {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
     description = "RUST $outfile"
     outputs = [ outfile ]
   }
@@ -26,7 +26,7 @@
   tool("rust_cdylib") {
     depfile = "{{target_out_dir}}/{{crate_name}}.d"
     outfile = "{{target_out_dir}}/lib{{crate_name}}.so"
-    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
+    command = "rustc --crate-name {{crate_name}} {{source}} --crate-type {{crate_type}} --emit=dep-info=$depfile,link -Z dep-info-omit-d-target {{rustflags}} -o $outfile {{rustdeps}} {{externs}}"
     description = "RUST $outfile"
     outputs = [ outfile ]
   }