| 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 "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 Loading... |
| 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().bundle_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 Loading... |
| 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() { |
| 484 if (output_type_ != CREATE_BUNDLE) | 492 for (const auto& pair : GetDeps(DEPS_LINKED)) { |
| 485 return; | 493 // Don't propagate bundle_data once they are added to a bundle. |
| 494 if (pair.ptr->output_type() == CREATE_BUNDLE) |
| 495 continue; |
| 486 | 496 |
| 487 std::set<const Target*> visited; | 497 // Direct dependency on a bundle_data target. |
| 488 std::vector<const Target*> deps; | 498 if (pair.ptr->output_type() == BUNDLE_DATA) |
| 489 deps.push_back(this); | 499 bundle_data_.AddBundleData(pair.ptr); |
| 490 | 500 |
| 491 while (!deps.empty()) { | 501 // Recursive bundle_data informations from all dependencies. |
| 492 const Target* current = deps.back(); | 502 for (const auto& target : pair.ptr->bundle_data().bundle_deps()) |
| 493 deps.pop_back(); | 503 bundle_data_.AddBundleData(target); |
| 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 } | 504 } |
| 514 | 505 |
| 515 bundle_data_.GetSourceFiles(&sources_); | 506 bundle_data_.OnTargetResolved(this); |
| 516 } | 507 } |
| 517 | 508 |
| 518 void Target::FillOutputFiles() { | 509 void Target::FillOutputFiles() { |
| 519 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); | 510 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
| 520 bool check_tool_outputs = false; | 511 bool check_tool_outputs = false; |
| 521 switch (output_type_) { | 512 switch (output_type_) { |
| 522 case GROUP: | 513 case GROUP: |
| 523 case BUNDLE_DATA: | 514 case BUNDLE_DATA: |
| 524 case CREATE_BUNDLE: | 515 case CREATE_BUNDLE: |
| 525 case SOURCE_SET: | 516 case SOURCE_SET: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, | 755 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, |
| 765 &seen_targets)) { | 756 &seen_targets)) { |
| 766 // Check object files (much slower and very rare) only if the "normal" | 757 // Check object files (much slower and very rare) only if the "normal" |
| 767 // output check failed. | 758 // output check failed. |
| 768 seen_targets.clear(); | 759 seen_targets.clear(); |
| 769 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, | 760 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, |
| 770 &seen_targets)) | 761 &seen_targets)) |
| 771 g_scheduler->AddUnknownGeneratedInput(this, source); | 762 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 772 } | 763 } |
| 773 } | 764 } |
| OLD | NEW |