Revert "Add output reference to gen written files." This reverts commit c497d21798caf871326443ad98bd58f546d7b38e. AKA https://codereview.chromium.org/1252403005/ TBR=dpranke@chromium.org BUG=533067 TEST=local re-run of gn gen in a few scenarios Review URL: https://codereview.chromium.org/1381443002 Cr-Original-Commit-Position: refs/heads/master@{#351319} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: a4a5e48c471822d1c51dd00233bf3a167e00d80e
diff --git a/tools/gn/function_write_file.cc b/tools/gn/function_write_file.cc index 45387a3..d24abc1 100644 --- a/tools/gn/function_write_file.cc +++ b/tools/gn/function_write_file.cc
@@ -115,6 +115,14 @@ return Value(); g_scheduler->AddWrittenFile(source_file); // Track that we wrote this file. + // Track how to recreate this file, since we write it a gen time. + // Note this is a hack since the correct output is not a dependency proper, + // but an addition of this file to the output of the gn rule that writes it. + // This dependency will, however, cause the gen step to be re-run and the + // build restarted if the file is missing. + g_scheduler->AddGenDependency( + scope->settings()->build_settings()->GetFullPath(source_file)); + // Compute output. std::ostringstream contents; if (args[1].type() == Value::LIST) {
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc index d27ebdc..50638fb 100644 --- a/tools/gn/ninja_build_writer.cc +++ b/tools/gn/ninja_build_writer.cc
@@ -180,23 +180,10 @@ void NinjaBuildWriter::WriteNinjaRules() { out_ << "rule gn\n"; out_ << " command = " << GetSelfInvocationCommand(build_settings_) << "\n"; - out_ << " description = Regenerating ninja files\n"; - out_ << " restat = 1\n\n"; + out_ << " description = Regenerating ninja files\n\n"; - // This rule will regenerate the ninja files when any input file has changed, - // or is missing. - out_ << "build build.ninja"; - - // Other files read by the build. - EscapeOptions path_escaping; - path_escaping.mode = ESCAPE_NINJA_COMMAND; - std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles(); - for (const auto& written_file : written_files) - out_ << " " << EscapeString(RebasePath(written_file.value(), - build_settings_->build_dir(), build_settings_->root_path_utf8()), - path_escaping, nullptr); - - out_ << ": gn\n" + // This rule will regenerate the ninja files when any input file has changed. + out_ << "build build.ninja: gn\n" << " generator = 1\n" << " depfile = build.ninja.d\n";
diff --git a/tools/gn/scheduler.cc b/tools/gn/scheduler.cc index db0929d..622019e 100644 --- a/tools/gn/scheduler.cc +++ b/tools/gn/scheduler.cc
@@ -113,11 +113,6 @@ written_files_.push_back(file); } -std::vector<SourceFile> Scheduler::GetWrittenFiles() const { - base::AutoLock lock(lock_); - return written_files_; -} - void Scheduler::AddUnknownGeneratedInput(const Target* target, const SourceFile& file) { base::AutoLock lock(lock_);
diff --git a/tools/gn/scheduler.h b/tools/gn/scheduler.h index 7e29ab5..5d0502f 100644 --- a/tools/gn/scheduler.h +++ b/tools/gn/scheduler.h
@@ -56,7 +56,6 @@ // Tracks calls to write_file for resolving with the unknown generated // inputs (see AddUnknownGeneratedInput below). void AddWrittenFile(const SourceFile& file); - std::vector<SourceFile> GetWrittenFiles() const; // Unknown generated inputs are files that a target declares as an input // in the output directory, but which aren't generated by any dependency.