| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 case LOADABLE_MODULE: | 211 case LOADABLE_MODULE: |
| 212 return "Loadable module"; | 212 return "Loadable module"; |
| 213 case SHARED_LIBRARY: | 213 case SHARED_LIBRARY: |
| 214 return "Shared library"; | 214 return "Shared library"; |
| 215 case STATIC_LIBRARY: | 215 case STATIC_LIBRARY: |
| 216 return "Static library"; | 216 return "Static library"; |
| 217 case SOURCE_SET: | 217 case SOURCE_SET: |
| 218 return "Source set"; | 218 return "Source set"; |
| 219 case COPY_FILES: | 219 case COPY_FILES: |
| 220 return "Copy"; | 220 return "Copy"; |
| 221 case COPY_BUNDLE_DATA: |
| 222 return "Copy bundle data"; |
| 221 case ACTION: | 223 case ACTION: |
| 222 return "Action"; | 224 return "Action"; |
| 223 case ACTION_FOREACH: | 225 case ACTION_FOREACH: |
| 224 return "ActionForEach"; | 226 return "ActionForEach"; |
| 225 default: | 227 default: |
| 226 return ""; | 228 return ""; |
| 227 } | 229 } |
| 228 } | 230 } |
| 229 | 231 |
| 230 Target* Target::AsTarget() { | 232 Target* Target::AsTarget() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // This needs to happen after we pull dependent target configs for the | 270 // This needs to happen after we pull dependent target configs for the |
| 269 // public config's libs to be included here. And it needs to happen | 271 // public config's libs to be included here. And it needs to happen |
| 270 // before pulling the dependent target libs so the libs are in the correct | 272 // before pulling the dependent target libs so the libs are in the correct |
| 271 // order (local ones first, then the dependency's). | 273 // order (local ones first, then the dependency's). |
| 272 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { | 274 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { |
| 273 const ConfigValues& cur = iter.cur(); | 275 const ConfigValues& cur = iter.cur(); |
| 274 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); | 276 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); |
| 275 all_libs_.append(cur.libs().begin(), cur.libs().end()); | 277 all_libs_.append(cur.libs().begin(), cur.libs().end()); |
| 276 } | 278 } |
| 277 | 279 |
| 280 PullRecursiveBundleData(); |
| 278 PullDependentTargetLibs(); | 281 PullDependentTargetLibs(); |
| 279 PullRecursiveHardDeps(); | 282 PullRecursiveHardDeps(); |
| 280 if (!ResolvePrecompiledHeaders(err)) | 283 if (!ResolvePrecompiledHeaders(err)) |
| 281 return false; | 284 return false; |
| 282 | 285 |
| 283 FillOutputFiles(); | 286 FillOutputFiles(); |
| 284 | 287 |
| 285 if (settings()->build_settings()->check_for_bad_items()) { | 288 if (settings()->build_settings()->check_for_bad_items()) { |
| 286 if (!CheckVisibility(err)) | 289 if (!CheckVisibility(err)) |
| 287 return false; | 290 return false; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 309 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; | 312 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; |
| 310 } | 313 } |
| 311 | 314 |
| 312 bool Target::IsFinal() const { | 315 bool Target::IsFinal() const { |
| 313 return output_type_ == EXECUTABLE || | 316 return output_type_ == EXECUTABLE || |
| 314 output_type_ == SHARED_LIBRARY || | 317 output_type_ == SHARED_LIBRARY || |
| 315 output_type_ == LOADABLE_MODULE || | 318 output_type_ == LOADABLE_MODULE || |
| 316 output_type_ == ACTION || | 319 output_type_ == ACTION || |
| 317 output_type_ == ACTION_FOREACH || | 320 output_type_ == ACTION_FOREACH || |
| 318 output_type_ == COPY_FILES || | 321 output_type_ == COPY_FILES || |
| 322 output_type_ == COPY_BUNDLE_DATA || |
| 319 (output_type_ == STATIC_LIBRARY && complete_static_lib_); | 323 (output_type_ == STATIC_LIBRARY && complete_static_lib_); |
| 320 } | 324 } |
| 321 | 325 |
| 322 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { | 326 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { |
| 323 if (type == DEPS_LINKED) { | 327 if (type == DEPS_LINKED) { |
| 324 return DepsIteratorRange(DepsIterator( | 328 return DepsIteratorRange(DepsIterator( |
| 325 &public_deps_, &private_deps_, nullptr)); | 329 &public_deps_, &private_deps_, nullptr)); |
| 326 } | 330 } |
| 327 // All deps. | 331 // All deps. |
| 328 return DepsIteratorRange(DepsIterator( | 332 return DepsIteratorRange(DepsIterator( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // Direct hard dependencies. | 471 // Direct hard dependencies. |
| 468 if (pair.ptr->hard_dep()) | 472 if (pair.ptr->hard_dep()) |
| 469 recursive_hard_deps_.insert(pair.ptr); | 473 recursive_hard_deps_.insert(pair.ptr); |
| 470 | 474 |
| 471 // Recursive hard dependencies of all dependencies. | 475 // Recursive hard dependencies of all dependencies. |
| 472 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), | 476 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), |
| 473 pair.ptr->recursive_hard_deps().end()); | 477 pair.ptr->recursive_hard_deps().end()); |
| 474 } | 478 } |
| 475 } | 479 } |
| 476 | 480 |
| 481 void Target::PullRecursiveBundleData() { |
| 482 for (const auto& pair : GetDeps(DEPS_LINKED)) { |
| 483 if (pair.ptr->output_type() == EXECUTABLE || |
| 484 pair.ptr->output_type() == SHARED_LIBRARY || |
| 485 pair.ptr->output_type() == LOADABLE_MODULE || |
| 486 pair.ptr->output_type() == COPY_BUNDLE_DATA) |
| 487 continue; |
| 488 |
| 489 bundle_data_.insert(pair.ptr->bundle_data().begin(), |
| 490 pair.ptr->bundle_data().end()); |
| 491 } |
| 492 |
| 493 if (output_type_ != COPY_BUNDLE_DATA) |
| 494 return; |
| 495 |
| 496 const PatternList& filter = bundle_data_filter(); |
| 497 if (filter.is_empty()) { |
| 498 sources_.insert(sources_.end(), bundle_data_.begin(), bundle_data_.end()); |
| 499 } else { |
| 500 sources_.reserve(sources_.size() + bundle_data_.size()); |
| 501 for (const SourceFile& source_file : bundle_data_) { |
| 502 if (!filter.MatchesString(source_file.value())) |
| 503 sources_.push_back(source_file); |
| 504 } |
| 505 } |
| 506 } |
| 507 |
| 477 void Target::FillOutputFiles() { | 508 void Target::FillOutputFiles() { |
| 478 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); | 509 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
| 479 bool check_tool_outputs = false; | 510 bool check_tool_outputs = false; |
| 480 switch (output_type_) { | 511 switch (output_type_) { |
| 481 case GROUP: | 512 case GROUP: |
| 482 case SOURCE_SET: | 513 case SOURCE_SET: |
| 483 case COPY_FILES: | 514 case COPY_FILES: |
| 515 case COPY_BUNDLE_DATA: |
| 484 case ACTION: | 516 case ACTION: |
| 485 case ACTION_FOREACH: { | 517 case ACTION_FOREACH: { |
| 486 // These don't get linked to and use stamps which should be the first | 518 // These don't get linked to and use stamps which should be the first |
| 487 // entry in the outputs. These stamps are named | 519 // entry in the outputs. These stamps are named |
| 488 // "<target_out_dir>/<targetname>.stamp". | 520 // "<target_out_dir>/<targetname>.stamp". |
| 489 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); | 521 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); |
| 490 dependency_output_file_.value().append(GetComputedOutputName(true)); | 522 dependency_output_file_.value().append(GetComputedOutputName(true)); |
| 491 dependency_output_file_.value().append(".stamp"); | 523 dependency_output_file_.value().append(".stamp"); |
| 492 break; | 524 break; |
| 493 } | 525 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, | 742 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, |
| 711 &seen_targets)) { | 743 &seen_targets)) { |
| 712 // Check object files (much slower and very rare) only if the "normal" | 744 // Check object files (much slower and very rare) only if the "normal" |
| 713 // output check failed. | 745 // output check failed. |
| 714 seen_targets.clear(); | 746 seen_targets.clear(); |
| 715 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, | 747 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, |
| 716 &seen_targets)) | 748 &seen_targets)) |
| 717 g_scheduler->AddUnknownGeneratedInput(this, source); | 749 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 718 } | 750 } |
| 719 } | 751 } |
| OLD | NEW |