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

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

Issue 2195753002: GN: only write targets that should be generated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/builder.h ('k') | tools/gn/command_gen.cc » ('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/builder.h" 5 #include "tools/gn/builder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "tools/gn/config.h" 10 #include "tools/gn/config.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 BuilderRecord::ITEM_TOOLCHAIN, err); 397 BuilderRecord::ITEM_TOOLCHAIN, err);
398 if (!toolchain_record) 398 if (!toolchain_record)
399 return false; 399 return false;
400 record->AddDep(toolchain_record); 400 record->AddDep(toolchain_record);
401 401
402 return true; 402 return true;
403 } 403 }
404 404
405 void Builder::RecursiveSetShouldGenerate(BuilderRecord* record, 405 void Builder::RecursiveSetShouldGenerate(BuilderRecord* record,
406 bool force) { 406 bool force) {
407 if (!force && record->should_generate()) 407 if (!record->should_generate()) {
408 return; // Already set. 408 record->set_should_generate(true);
409 record->set_should_generate(true); 409
410 // This may have caused the item to go into "resolved and generated" state.
411 if (record->resolved() && !resolved_and_generated_callback_.is_null())
412 resolved_and_generated_callback_.Run(record);
413 } else if (!force) {
414 return; // Already set and we're not required to iterate dependencies.
415 }
410 416
411 for (auto* cur : record->all_deps()) { 417 for (auto* cur : record->all_deps()) {
412 if (!cur->should_generate()) { 418 if (!cur->should_generate()) {
413 ScheduleItemLoadIfNecessary(cur); 419 ScheduleItemLoadIfNecessary(cur);
414 RecursiveSetShouldGenerate(cur, false); 420 RecursiveSetShouldGenerate(cur, false);
415 } 421 }
416 } 422 }
417 } 423 }
418 424
419 void Builder::ScheduleItemLoadIfNecessary(BuilderRecord* record) { 425 void Builder::ScheduleItemLoadIfNecessary(BuilderRecord* record) {
(...skipping 24 matching lines...) Expand all
444 if (!ResolveDeps(&toolchain->deps(), err)) 450 if (!ResolveDeps(&toolchain->deps(), err))
445 return false; 451 return false;
446 if (!ResolvePools(toolchain, err)) 452 if (!ResolvePools(toolchain, err))
447 return false; 453 return false;
448 } 454 }
449 455
450 record->set_resolved(true); 456 record->set_resolved(true);
451 457
452 if (!record->item()->OnResolved(err)) 458 if (!record->item()->OnResolved(err))
453 return false; 459 return false;
454 if (!resolved_callback_.is_null()) 460 if (record->should_generate() && !resolved_and_generated_callback_.is_null())
455 resolved_callback_.Run(record); 461 resolved_and_generated_callback_.Run(record);
456 462
457 // Recursively update everybody waiting on this item to be resolved. 463 // Recursively update everybody waiting on this item to be resolved.
458 for (BuilderRecord* waiting : record->waiting_on_resolution()) { 464 for (BuilderRecord* waiting : record->waiting_on_resolution()) {
459 DCHECK(waiting->unresolved_deps().find(record) != 465 DCHECK(waiting->unresolved_deps().find(record) !=
460 waiting->unresolved_deps().end()); 466 waiting->unresolved_deps().end());
461 waiting->unresolved_deps().erase(record); 467 waiting->unresolved_deps().erase(record);
462 468
463 if (waiting->can_resolve()) { 469 if (waiting->can_resolve()) {
464 if (!ResolveItem(waiting, err)) 470 if (!ResolveItem(waiting, err))
465 return false; 471 return false;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 std::string ret; 551 std::string ret;
546 for (size_t i = 0; i < cycle.size(); i++) { 552 for (size_t i = 0; i < cycle.size(); i++) {
547 ret += " " + cycle[i]->label().GetUserVisibleName(false); 553 ret += " " + cycle[i]->label().GetUserVisibleName(false);
548 if (i != cycle.size() - 1) 554 if (i != cycle.size() - 1)
549 ret += " ->"; 555 ret += " ->";
550 ret += "\n"; 556 ret += "\n";
551 } 557 }
552 558
553 return ret; 559 return ret;
554 } 560 }
OLDNEW
« no previous file with comments | « tools/gn/builder.h ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698