| OLD | NEW |
| 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 "base/atomicops.h" | 5 #include "base/atomicops.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Called on worker thread to write the ninja file. | 56 // Called on worker thread to write the ninja file. |
| 57 void BackgroundDoWrite(TargetWriteInfo* write_info, const Target* target) { | 57 void BackgroundDoWrite(TargetWriteInfo* write_info, const Target* target) { |
| 58 std::string rule = NinjaTargetWriter::RunAndWriteFile(target); | 58 std::string rule = NinjaTargetWriter::RunAndWriteFile(target); |
| 59 DCHECK(!rule.empty()); | 59 DCHECK(!rule.empty()); |
| 60 | 60 |
| 61 { | 61 { |
| 62 base::AutoLock lock(write_info->lock); | 62 base::AutoLock lock(write_info->lock); |
| 63 write_info->rules[target->toolchain()].emplace_back( | 63 write_info->rules[target->toolchain()].emplace_back( |
| 64 target, std::move(rule)); | 64 target, std::move(rule)); |
| 65 } | 65 } |
| 66 | |
| 67 g_scheduler->DecrementWorkCount(); | |
| 68 } | 66 } |
| 69 | 67 |
| 70 // Called on the main thread. | 68 // Called on the main thread. |
| 71 void ItemResolvedAndGeneratedCallback(TargetWriteInfo* write_info, | 69 void ItemResolvedAndGeneratedCallback(TargetWriteInfo* write_info, |
| 72 const BuilderRecord* record) { | 70 const BuilderRecord* record) { |
| 73 const Item* item = record->item(); | 71 const Item* item = record->item(); |
| 74 const Target* target = item->AsTarget(); | 72 const Target* target = item->AsTarget(); |
| 75 if (target) { | 73 if (target) { |
| 76 g_scheduler->IncrementWorkCount(); | |
| 77 g_scheduler->ScheduleWork(base::Bind(&BackgroundDoWrite, | 74 g_scheduler->ScheduleWork(base::Bind(&BackgroundDoWrite, |
| 78 write_info, target)); | 75 write_info, target)); |
| 79 } | 76 } |
| 80 } | 77 } |
| 81 | 78 |
| 82 // Returns a pointer to the target with the given file as an output, or null | 79 // Returns a pointer to the target with the given file as an output, or null |
| 83 // if no targets generate the file. This is brute force since this is an | 80 // if no targets generate the file. This is brute force since this is an |
| 84 // error condition and performance shouldn't matter. | 81 // error condition and performance shouldn't matter. |
| 85 const Target* FindTargetThatGeneratesFile(const Builder& builder, | 82 const Target* FindTargetThatGeneratesFile(const Builder& builder, |
| 86 const SourceFile& file) { | 83 const SourceFile& file) { |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 444 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
| 448 " files in " + | 445 " files in " + |
| 449 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 446 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
| 450 OutputString(stats); | 447 OutputString(stats); |
| 451 } | 448 } |
| 452 | 449 |
| 453 return 0; | 450 return 0; |
| 454 } | 451 } |
| 455 | 452 |
| 456 } // namespace commands | 453 } // namespace commands |
| OLD | NEW |