Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/gn/scheduler.cc

Issue 1804303004: 🚙 GN: Add write_runtime_deps variable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove {}s Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/scheduler.h ('k') | tools/gn/target.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/scheduler.h" 5 #include "tools/gn/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "tools/gn/standard_out.h" 13 #include "tools/gn/standard_out.h"
14 #include "tools/gn/switches.h" 14 #include "tools/gn/switches.h"
15 #include "tools/gn/target.h"
15 16
16 #if defined(OS_WIN) 17 #if defined(OS_WIN)
17 #include <windows.h> 18 #include <windows.h>
18 #else 19 #else
19 #include <unistd.h> 20 #include <unistd.h>
20 #endif 21 #endif
21 22
22 Scheduler* g_scheduler = nullptr; 23 Scheduler* g_scheduler = nullptr;
23 24
24 namespace { 25 namespace {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 base::AutoLock lock(lock_); 147 base::AutoLock lock(lock_);
147 written_files_.push_back(file); 148 written_files_.push_back(file);
148 } 149 }
149 150
150 void Scheduler::AddUnknownGeneratedInput(const Target* target, 151 void Scheduler::AddUnknownGeneratedInput(const Target* target,
151 const SourceFile& file) { 152 const SourceFile& file) {
152 base::AutoLock lock(lock_); 153 base::AutoLock lock(lock_);
153 unknown_generated_inputs_.insert(std::make_pair(file, target)); 154 unknown_generated_inputs_.insert(std::make_pair(file, target));
154 } 155 }
155 156
157 void Scheduler::AddWriteRuntimeDepsTarget(const Target* target) {
158 base::AutoLock lock(lock_);
159 write_runtime_deps_targets_.push_back(target);
160 }
161
162 std::vector<const Target*> Scheduler::GetWriteRuntimeDepsTargets() const {
163 base::AutoLock lock(lock_);
164 return write_runtime_deps_targets_;
165 }
166
167 bool Scheduler::IsFileGeneratedByWriteRuntimeDeps(
168 const OutputFile& file) const {
169 base::AutoLock lock(lock_);
170 // Number of targets should be quite small, so brute-force search is fine.
171 for (const Target* target : write_runtime_deps_targets_) {
172 if (file == target->write_runtime_deps_output()) {
173 return true;
174 }
175 }
176 return false;
177 }
178
156 std::multimap<SourceFile, const Target*> 179 std::multimap<SourceFile, const Target*>
157 Scheduler::GetUnknownGeneratedInputs() const { 180 Scheduler::GetUnknownGeneratedInputs() const {
158 base::AutoLock lock(lock_); 181 base::AutoLock lock(lock_);
159 182
160 // Remove all unknown inputs that were written files. These are OK as inputs 183 // Remove all unknown inputs that were written files. These are OK as inputs
161 // to build steps since they were written as a side-effect of running GN. 184 // to build steps since they were written as a side-effect of running GN.
162 // 185 //
163 // It's assumed that this function is called once during cleanup to check for 186 // It's assumed that this function is called once during cleanup to check for
164 // errors, so performing this work in the lock doesn't matter. 187 // errors, so performing this work in the lock doesn't matter.
165 std::multimap<SourceFile, const Target*> filtered = unknown_generated_inputs_; 188 std::multimap<SourceFile, const Target*> filtered = unknown_generated_inputs_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void Scheduler::DoWork(const base::Closure& closure) { 228 void Scheduler::DoWork(const base::Closure& closure) {
206 closure.Run(); 229 closure.Run();
207 DecrementWorkCount(); 230 DecrementWorkCount();
208 } 231 }
209 232
210 void Scheduler::OnComplete() { 233 void Scheduler::OnComplete() {
211 // Should be called on the main thread. 234 // Should be called on the main thread.
212 DCHECK(base::MessageLoop::current() == main_loop()); 235 DCHECK(base::MessageLoop::current() == main_loop());
213 runner_.Quit(); 236 runner_.Quit();
214 } 237 }
OLDNEW
« no previous file with comments | « tools/gn/scheduler.h ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698