Print args.gn if gn clean fails to write it For mysterious reasons "gn clean" sometimes fails to write args.gn, which is a surprisingly frustrating bit of data loss. This change gets gn to do the most that it can in this case - print args.gn to the console. I tested by forcing a failure to write args.gn and verified that the printout looked good and was usable. Bug: 627656 Change-Id: Ifbd6ddd8c851da13e482e8a0f617b218e29ede08 Reviewed-on: https://chromium-review.googlesource.com/862697 Reviewed-by: Dirk Pranke <dpranke@chromium.org> Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#528842} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: b7c2c4ec1b901041af24793d679e3acaec4b750d
diff --git a/tools/gn/command_clean.cc b/tools/gn/command_clean.cc index 70def6d..f4b64af 100644 --- a/tools/gn/command_clean.cc +++ b/tools/gn/command_clean.cc
@@ -105,7 +105,11 @@ if (!args_contents.empty()) { if (base::WriteFile(gn_args_file, args_contents.data(), static_cast<int>(args_contents.size())) == -1) { - Err(Location(), std::string("Failed to write args.gn.")).PrintToStdout(); + // Print the previous contents of args.gn since otherwise it is lost for + // good which can be quite frustrating. + Err(Location(), + "Failed to write args.gn. Old contents was:\n\n" + args_contents) + .PrintToStdout(); return 1; } }