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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 { | 60 { |
61 base::AutoLock lock(write_info->lock); | 61 base::AutoLock lock(write_info->lock); |
62 write_info->rules[target->toolchain()].emplace_back( | 62 write_info->rules[target->toolchain()].emplace_back( |
63 target, std::move(rule)); | 63 target, std::move(rule)); |
64 } | 64 } |
65 | 65 |
66 g_scheduler->DecrementWorkCount(); | 66 g_scheduler->DecrementWorkCount(); |
67 } | 67 } |
68 | 68 |
69 // Called on the main thread. | 69 // Called on the main thread. |
70 void ItemResolvedCallback(TargetWriteInfo* write_info, | 70 void ItemResolvedAndGeneratedCallback(TargetWriteInfo* write_info, |
71 const BuilderRecord* record) { | 71 const BuilderRecord* record) { |
72 const Item* item = record->item(); | 72 const Item* item = record->item(); |
73 const Target* target = item->AsTarget(); | 73 const Target* target = item->AsTarget(); |
74 if (target) { | 74 if (target) { |
75 g_scheduler->IncrementWorkCount(); | 75 g_scheduler->IncrementWorkCount(); |
76 g_scheduler->ScheduleWork(base::Bind(&BackgroundDoWrite, | 76 g_scheduler->ScheduleWork(base::Bind(&BackgroundDoWrite, |
77 write_info, target)); | 77 write_info, target)); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 // Returns a pointer to the target with the given file as an output, or null | 81 // Returns a pointer to the target with the given file as an output, or null |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 if (!setup->DoSetup(args[0], true)) | 380 if (!setup->DoSetup(args[0], true)) |
381 return 1; | 381 return 1; |
382 | 382 |
383 const base::CommandLine* command_line = | 383 const base::CommandLine* command_line = |
384 base::CommandLine::ForCurrentProcess(); | 384 base::CommandLine::ForCurrentProcess(); |
385 if (command_line->HasSwitch(kSwitchCheck)) | 385 if (command_line->HasSwitch(kSwitchCheck)) |
386 setup->set_check_public_headers(true); | 386 setup->set_check_public_headers(true); |
387 | 387 |
388 // Cause the load to also generate the ninja files for each target. | 388 // Cause the load to also generate the ninja files for each target. |
389 TargetWriteInfo write_info; | 389 TargetWriteInfo write_info; |
390 setup->builder().set_resolved_callback( | 390 setup->builder().set_resolved_and_generated_callback( |
391 base::Bind(&ItemResolvedCallback, &write_info)); | 391 base::Bind(&ItemResolvedAndGeneratedCallback, &write_info)); |
392 | 392 |
393 // Do the actual load. This will also write out the target ninja files. | 393 // Do the actual load. This will also write out the target ninja files. |
394 if (!setup->Run()) | 394 if (!setup->Run()) |
395 return 1; | 395 return 1; |
396 | 396 |
397 // Sort the targets in each toolchain according to their label. This makes | 397 // Sort the targets in each toolchain according to their label. This makes |
398 // the ninja files have deterministic content. | 398 // the ninja files have deterministic content. |
399 for (auto& cur_toolchain : write_info.rules) { | 399 for (auto& cur_toolchain : write_info.rules) { |
400 std::sort(cur_toolchain.second.begin(), cur_toolchain.second.end(), | 400 std::sort(cur_toolchain.second.begin(), cur_toolchain.second.end(), |
401 [](const NinjaWriter::TargetRulePair& a, | 401 [](const NinjaWriter::TargetRulePair& a, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 444 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
445 " files in " + | 445 " files in " + |
446 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 446 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
447 OutputString(stats); | 447 OutputString(stats); |
448 } | 448 } |
449 | 449 |
450 return 0; | 450 return 0; |
451 } | 451 } |
452 | 452 |
453 } // namespace commands | 453 } // namespace commands |
OLD | NEW |