Skip to content

Commit

Permalink
Revert of Add output reference to gen written files. (patchset #3 id:…
Browse files Browse the repository at this point in the history
…40001 of https://codereview.chromium.org/1220223002/)

Reason for revert:
Looks like this doesn't quite work on Windows:

http://build.chromium.org/p/tryserver.chromium.win/builders/win8_chromium_ng/builds/21206/steps/compile%20%28with%20patch%29/logs/stdio

Original issue's description:
> Add output reference to gen written files.
>
> By adding the outputs written at gn gen time to the build.ninja representation the build tool (ninja) can know how to recreate them if and when necessary.
>
> For example, if one or more of the <blah>.tmp files is removed, even as part of an entire hierarchy/subtree currently the build fails because ninja does not know how to re-make it.
>
> BUG=469621
> TEST=Build time only. See https://code.google.com/p/chromium/issues/detail?id=469621#c3
>
> Committed: https://crrev.com/517ac52f86903beb206b19e6ddeedbc709b253a1
> Cr-Commit-Position: refs/heads/master@{#338929}

TBR=brettw@chromium.org,petermayo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=469621

Review URL: https://codereview.chromium.org/1255113004

Cr-Commit-Position: refs/heads/master@{#340596}
  • Loading branch information
dpranke authored and Anton Obzhirov committed Aug 7, 2015
1 parent 8041187 commit e909388
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
8 changes: 8 additions & 0 deletions tools/gn/function_write_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ Value RunWriteFile(Scope* scope,
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) {
Expand Down
15 changes: 3 additions & 12 deletions tools/gn/ninja_build_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,10 @@ bool NinjaBuildWriter::RunAndWriteFile(
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.
std::vector<SourceFile> written_files = g_scheduler->GetWrittenFiles();
for (const auto& written_file : written_files)
out_ << " " << FilePathToUTF8(build_settings_->GetFullPath(written_file));

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";

Expand Down
5 changes: 0 additions & 5 deletions tools/gn/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ void Scheduler::AddWrittenFile(const SourceFile& file) {
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_);
Expand Down
1 change: 0 additions & 1 deletion tools/gn/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Scheduler {
// 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.
Expand Down

0 comments on commit e909388

Please sign in to comment.