Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 case LOADABLE_MODULE: | 156 case LOADABLE_MODULE: |
| 157 return "Loadable module"; | 157 return "Loadable module"; |
| 158 case SHARED_LIBRARY: | 158 case SHARED_LIBRARY: |
| 159 return "Shared library"; | 159 return "Shared library"; |
| 160 case STATIC_LIBRARY: | 160 case STATIC_LIBRARY: |
| 161 return "Static library"; | 161 return "Static library"; |
| 162 case SOURCE_SET: | 162 case SOURCE_SET: |
| 163 return "Source set"; | 163 return "Source set"; |
| 164 case COPY_FILES: | 164 case COPY_FILES: |
| 165 return "Copy"; | 165 return "Copy"; |
| 166 case COPY_BUNDLE_DATA: | |
| 167 return "Copy bundle data"; | |
| 166 case ACTION: | 168 case ACTION: |
| 167 return "Action"; | 169 return "Action"; |
| 168 case ACTION_FOREACH: | 170 case ACTION_FOREACH: |
| 169 return "ActionForEach"; | 171 return "ActionForEach"; |
| 170 default: | 172 default: |
| 171 return ""; | 173 return ""; |
| 172 } | 174 } |
| 173 } | 175 } |
| 174 | 176 |
| 175 Target* Target::AsTarget() { | 177 Target* Target::AsTarget() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 // This needs to happen after we pull dependent target configs for the | 215 // This needs to happen after we pull dependent target configs for the |
| 214 // public config's libs to be included here. And it needs to happen | 216 // public config's libs to be included here. And it needs to happen |
| 215 // before pulling the dependent target libs so the libs are in the correct | 217 // before pulling the dependent target libs so the libs are in the correct |
| 216 // order (local ones first, then the dependency's). | 218 // order (local ones first, then the dependency's). |
| 217 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { | 219 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { |
| 218 const ConfigValues& cur = iter.cur(); | 220 const ConfigValues& cur = iter.cur(); |
| 219 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); | 221 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); |
| 220 all_libs_.append(cur.libs().begin(), cur.libs().end()); | 222 all_libs_.append(cur.libs().begin(), cur.libs().end()); |
| 221 } | 223 } |
| 222 | 224 |
| 225 PullRecursiveBundleData(); | |
| 223 PullDependentTargetLibs(); | 226 PullDependentTargetLibs(); |
| 224 PullRecursiveHardDeps(); | 227 PullRecursiveHardDeps(); |
| 225 if (!ResolvePrecompiledHeaders(err)) | 228 if (!ResolvePrecompiledHeaders(err)) |
| 226 return false; | 229 return false; |
| 227 | 230 |
| 228 FillOutputFiles(); | 231 FillOutputFiles(); |
| 229 | 232 |
| 230 if (settings()->build_settings()->check_for_bad_items()) { | 233 if (settings()->build_settings()->check_for_bad_items()) { |
| 231 if (!CheckVisibility(err)) | 234 if (!CheckVisibility(err)) |
| 232 return false; | 235 return false; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 252 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; | 255 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; |
| 253 } | 256 } |
| 254 | 257 |
| 255 bool Target::IsFinal() const { | 258 bool Target::IsFinal() const { |
| 256 return output_type_ == EXECUTABLE || | 259 return output_type_ == EXECUTABLE || |
| 257 output_type_ == SHARED_LIBRARY || | 260 output_type_ == SHARED_LIBRARY || |
| 258 output_type_ == LOADABLE_MODULE || | 261 output_type_ == LOADABLE_MODULE || |
| 259 output_type_ == ACTION || | 262 output_type_ == ACTION || |
| 260 output_type_ == ACTION_FOREACH || | 263 output_type_ == ACTION_FOREACH || |
| 261 output_type_ == COPY_FILES || | 264 output_type_ == COPY_FILES || |
| 265 output_type_ == COPY_BUNDLE_DATA || | |
| 262 (output_type_ == STATIC_LIBRARY && complete_static_lib_); | 266 (output_type_ == STATIC_LIBRARY && complete_static_lib_); |
| 263 } | 267 } |
| 264 | 268 |
| 265 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { | 269 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { |
| 266 if (type == DEPS_LINKED) { | 270 if (type == DEPS_LINKED) { |
| 267 return DepsIteratorRange(DepsIterator( | 271 return DepsIteratorRange(DepsIterator( |
| 268 &public_deps_, &private_deps_, nullptr)); | 272 &public_deps_, &private_deps_, nullptr)); |
| 269 } | 273 } |
| 270 // All deps. | 274 // All deps. |
| 271 return DepsIteratorRange(DepsIterator( | 275 return DepsIteratorRange(DepsIterator( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 // Direct hard dependencies. | 414 // Direct hard dependencies. |
| 411 if (pair.ptr->hard_dep()) | 415 if (pair.ptr->hard_dep()) |
| 412 recursive_hard_deps_.insert(pair.ptr); | 416 recursive_hard_deps_.insert(pair.ptr); |
| 413 | 417 |
| 414 // Recursive hard dependencies of all dependencies. | 418 // Recursive hard dependencies of all dependencies. |
| 415 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), | 419 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), |
| 416 pair.ptr->recursive_hard_deps().end()); | 420 pair.ptr->recursive_hard_deps().end()); |
| 417 } | 421 } |
| 418 } | 422 } |
| 419 | 423 |
| 424 void Target::PullRecursiveBundleData() { | |
|
brettw
2016/01/26 23:51:41
We should have a test in target_unittest.cc that t
sdefresne
2016/01/27 13:13:45
Done.
| |
| 425 for (const auto& pair : GetDeps(DEPS_LINKED)) { | |
| 426 if (pair.ptr->output_type() == EXECUTABLE || | |
| 427 pair.ptr->output_type() == SHARED_LIBRARY || | |
| 428 pair.ptr->output_type() == LOADABLE_MODULE || | |
| 429 pair.ptr->output_type() == COPY_BUNDLE_DATA) | |
| 430 continue; | |
| 431 | |
| 432 bundle_data_.insert(pair.ptr->bundle_data().begin(), | |
| 433 pair.ptr->bundle_data().end()); | |
| 434 } | |
| 435 | |
| 436 if (output_type_ != COPY_BUNDLE_DATA) | |
| 437 return; | |
| 438 | |
| 439 // TODO(sdefresne): .xcasset needs to have a specific treatment. This will | |
| 440 // requires a second target using the "bundle_data" information, and for a | |
| 441 // way to filter out .xcasset from "copy_bundle_data". | |
| 442 sources_.insert(sources_.end(), bundle_data_.begin(), bundle_data_.end()); | |
| 443 } | |
| 444 | |
| 420 void Target::FillOutputFiles() { | 445 void Target::FillOutputFiles() { |
| 421 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); | 446 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
| 422 bool check_tool_outputs = false; | 447 bool check_tool_outputs = false; |
| 423 switch (output_type_) { | 448 switch (output_type_) { |
| 424 case GROUP: | 449 case GROUP: |
| 425 case SOURCE_SET: | 450 case SOURCE_SET: |
| 426 case COPY_FILES: | 451 case COPY_FILES: |
| 452 case COPY_BUNDLE_DATA: | |
| 427 case ACTION: | 453 case ACTION: |
| 428 case ACTION_FOREACH: { | 454 case ACTION_FOREACH: { |
| 429 // These don't get linked to and use stamps which should be the first | 455 // These don't get linked to and use stamps which should be the first |
| 430 // entry in the outputs. These stamps are named | 456 // entry in the outputs. These stamps are named |
| 431 // "<target_out_dir>/<targetname>.stamp". | 457 // "<target_out_dir>/<targetname>.stamp". |
| 432 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); | 458 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); |
| 433 dependency_output_file_.value().append(GetComputedOutputName(true)); | 459 dependency_output_file_.value().append(GetComputedOutputName(true)); |
| 434 dependency_output_file_.value().append(".stamp"); | 460 dependency_output_file_.value().append(".stamp"); |
| 435 break; | 461 break; |
| 436 } | 462 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, | 658 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, false, |
| 633 &seen_targets)) { | 659 &seen_targets)) { |
| 634 // Check object files (much slower and very rare) only if the "normal" | 660 // Check object files (much slower and very rare) only if the "normal" |
| 635 // output check failed. | 661 // output check failed. |
| 636 seen_targets.clear(); | 662 seen_targets.clear(); |
| 637 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, | 663 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, true, |
| 638 &seen_targets)) | 664 &seen_targets)) |
| 639 g_scheduler->AddUnknownGeneratedInput(this, source); | 665 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 640 } | 666 } |
| 641 } | 667 } |
| OLD | NEW |