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

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

Issue 1804263003: Consider bundle_data as public_deps of create_bundle targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@{interstitial}
Patch Set: Rebase on origin/master Created 4 years, 9 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
« tools/gn/bundle_data.h ('K') | « tools/gn/bundle_data.h ('k') | no next file » | 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/target.h" 5 #include "tools/gn/target.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 // Only check private deps if requested. 120 // Only check private deps if requested.
121 if (check_private_deps) { 121 if (check_private_deps) {
122 for (const auto& pair : target->private_deps()) { 122 for (const auto& pair : target->private_deps()) {
123 if (EnsureFileIsGeneratedByDependency(pair.ptr, file, false, 123 if (EnsureFileIsGeneratedByDependency(pair.ptr, file, false,
124 consider_object_files, 124 consider_object_files,
125 seen_targets)) 125 seen_targets))
126 return true; // Found a path. 126 return true; // Found a path.
127 } 127 }
128 if (target->output_type() == Target::CREATE_BUNDLE) {
129 for (const auto& dep : target->bundle_data().deps()) {
130 if (EnsureFileIsGeneratedByDependency(dep, file, false,
131 consider_object_files,
132 seen_targets))
133 return true; // Found a path.
134 }
135 }
128 } 136 }
129 return false; 137 return false;
130 } 138 }
131 139
132 // check_this indicates if the given target should be matched against the 140 // check_this indicates if the given target should be matched against the
133 // patterns. It should be set to false for the first call since assert_no_deps 141 // patterns. It should be set to false for the first call since assert_no_deps
134 // shouldn't match the target itself. 142 // shouldn't match the target itself.
135 // 143 //
136 // visited should point to an empty set, this will be used to prevent 144 // visited should point to an empty set, this will be used to prevent
137 // multiple visits. 145 // multiple visits.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (pair.ptr->hard_dep()) 482 if (pair.ptr->hard_dep())
475 recursive_hard_deps_.insert(pair.ptr); 483 recursive_hard_deps_.insert(pair.ptr);
476 484
477 // Recursive hard dependencies of all dependencies. 485 // Recursive hard dependencies of all dependencies.
478 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), 486 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(),
479 pair.ptr->recursive_hard_deps().end()); 487 pair.ptr->recursive_hard_deps().end());
480 } 488 }
481 } 489 }
482 490
483 void Target::PullRecursiveBundleData() { 491 void Target::PullRecursiveBundleData() {
492 UniqueVector<const Target*>& bundle_data_deps = bundle_data_.deps();
493 for (const auto& pair : GetDeps(DEPS_LINKED)) {
494 // Stop recursion at create_bundle targets.
brettw 2016/03/21 22:49:47 This would be more clear to me as something like "
495 if (pair.ptr->output_type() == CREATE_BUNDLE)
496 continue;
497
498 // Direct dependency on a bundle_data target.
499 if (pair.ptr->output_type() == BUNDLE_DATA)
500 bundle_data_deps.push_back(pair.ptr);
501
brettw 2016/03/21 22:49:47 Extra blank line in here.
502
503 // Recursive bundle_data informations from all dependencies.
504 bundle_data_deps.Append(pair.ptr->bundle_data().deps().begin(),
505 pair.ptr->bundle_data().deps().end());
506 }
507
484 if (output_type_ != CREATE_BUNDLE) 508 if (output_type_ != CREATE_BUNDLE)
485 return; 509 return;
486 510
487 std::set<const Target*> visited; 511 for (const auto& target : bundle_data_.deps())
488 std::vector<const Target*> deps; 512 bundle_data_.AddFileRuleFromTarget(target);
brettw 2016/03/21 22:49:47 Can this function be changed now? It's weird to pa
brettw 2016/03/21 22:59:08 By this I mean append that target to the bundle_de
sdefresne 2016/03/22 12:34:05 There was a small optimisation that this removed (
489 deps.push_back(this);
490
491 while (!deps.empty()) {
492 const Target* current = deps.back();
493 deps.pop_back();
494
495 if (visited.find(current) != visited.end())
496 continue;
497 visited.insert(current);
498
499 if (current->output_type_ == BUNDLE_DATA)
500 bundle_data_.AddFileRuleFromTarget(current);
501
502 for (const LabelTargetPair& pair : current->GetDeps(DEPS_ALL)) {
503 DCHECK(pair.ptr);
504 DCHECK(pair.ptr->toolchain_);
505 if (visited.find(pair.ptr) != visited.end())
506 continue;
507
508 if (pair.ptr->output_type() == CREATE_BUNDLE)
509 continue;
510
511 deps.push_back(pair.ptr);
512 }
513 }
514
515 bundle_data_.GetSourceFiles(&sources_); 513 bundle_data_.GetSourceFiles(&sources_);
516 } 514 }
517 515
518 void Target::FillOutputFiles() { 516 void Target::FillOutputFiles() {
519 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); 517 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this);
520 bool check_tool_outputs = false; 518 bool check_tool_outputs = false;
521 switch (output_type_) { 519 switch (output_type_) {
522 case GROUP: 520 case GROUP:
523 case BUNDLE_DATA: 521 case BUNDLE_DATA:
524 case CREATE_BUNDLE: 522 case CREATE_BUNDLE:
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, 762 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false,
765 &seen_targets)) { 763 &seen_targets)) {
766 // Check object files (much slower and very rare) only if the "normal" 764 // Check object files (much slower and very rare) only if the "normal"
767 // output check failed. 765 // output check failed.
768 seen_targets.clear(); 766 seen_targets.clear();
769 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, 767 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true,
770 &seen_targets)) 768 &seen_targets))
771 g_scheduler->AddUnknownGeneratedInput(this, source); 769 g_scheduler->AddUnknownGeneratedInput(this, source);
772 } 770 }
773 } 771 }
OLDNEW
« tools/gn/bundle_data.h ('K') | « tools/gn/bundle_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698