| 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/ninja_binary_target_writer.h" | 5 #include "tools/gn/ninja_binary_target_writer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 for (size_t i = 0; i < non_linkable_deps.size(); i++) | 368 for (size_t i = 0; i < non_linkable_deps.size(); i++) |
| 369 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file()); | 369 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file()); |
| 370 | 370 |
| 371 WriteStampForTarget(object_files, order_only_deps); | 371 WriteStampForTarget(object_files, order_only_deps); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void NinjaBinaryTargetWriter::GetDeps( | 374 void NinjaBinaryTargetWriter::GetDeps( |
| 375 UniqueVector<OutputFile>* extra_object_files, | 375 UniqueVector<OutputFile>* extra_object_files, |
| 376 UniqueVector<const Target*>* linkable_deps, | 376 UniqueVector<const Target*>* linkable_deps, |
| 377 UniqueVector<const Target*>* non_linkable_deps) const { | 377 UniqueVector<const Target*>* non_linkable_deps) const { |
| 378 const UniqueVector<const Target*>& inherited = | |
| 379 target_->inherited_libraries(); | |
| 380 | |
| 381 // Normal public/private deps. | 378 // Normal public/private deps. |
| 382 for (DepsIterator iter(target_, DepsIterator::LINKED_ONLY); !iter.done(); | 379 for (const auto& pair : target_->GetDeps(Target::DEPS_LINKED)) { |
| 383 iter.Advance()) { | 380 ClassifyDependency(pair.ptr, extra_object_files, |
| 384 ClassifyDependency(iter.target(), extra_object_files, | |
| 385 linkable_deps, non_linkable_deps); | 381 linkable_deps, non_linkable_deps); |
| 386 } | 382 } |
| 387 | 383 |
| 388 // Inherited libraries. | 384 // Inherited libraries. |
| 389 for (size_t i = 0; i < inherited.size(); i++) { | 385 for (const auto& inherited_target : target_->inherited_libraries()) { |
| 390 ClassifyDependency(inherited[i], extra_object_files, | 386 ClassifyDependency(inherited_target, extra_object_files, |
| 391 linkable_deps, non_linkable_deps); | 387 linkable_deps, non_linkable_deps); |
| 392 } | 388 } |
| 393 | 389 |
| 394 // Data deps. | 390 // Data deps. |
| 395 const LabelTargetVector& data_deps = target_->data_deps(); | 391 for (const auto& data_dep_pair : target_->data_deps()) |
| 396 for (size_t i = 0; i < data_deps.size(); i++) | 392 non_linkable_deps->push_back(data_dep_pair.ptr); |
| 397 non_linkable_deps->push_back(data_deps[i].ptr); | |
| 398 } | 393 } |
| 399 | 394 |
| 400 void NinjaBinaryTargetWriter::ClassifyDependency( | 395 void NinjaBinaryTargetWriter::ClassifyDependency( |
| 401 const Target* dep, | 396 const Target* dep, |
| 402 UniqueVector<OutputFile>* extra_object_files, | 397 UniqueVector<OutputFile>* extra_object_files, |
| 403 UniqueVector<const Target*>* linkable_deps, | 398 UniqueVector<const Target*>* linkable_deps, |
| 404 UniqueVector<const Target*>* non_linkable_deps) const { | 399 UniqueVector<const Target*>* non_linkable_deps) const { |
| 405 // Only the following types of outputs have libraries linked into them: | 400 // Only the following types of outputs have libraries linked into them: |
| 406 // EXECUTABLE | 401 // EXECUTABLE |
| 407 // SHARED_LIBRARY | 402 // SHARED_LIBRARY |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 return false; // No tool for this file (it's a header file or something). | 472 return false; // No tool for this file (it's a header file or something). |
| 478 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); | 473 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); |
| 479 if (!tool) | 474 if (!tool) |
| 480 return false; // Tool does not apply for this toolchain.file. | 475 return false; // Tool does not apply for this toolchain.file. |
| 481 | 476 |
| 482 // Figure out what output(s) this compiler produces. | 477 // Figure out what output(s) this compiler produces. |
| 483 SubstitutionWriter::ApplyListToCompilerAsOutputFile( | 478 SubstitutionWriter::ApplyListToCompilerAsOutputFile( |
| 484 target, source, tool->outputs(), outputs); | 479 target, source, tool->outputs(), outputs); |
| 485 return !outputs->empty(); | 480 return !outputs->empty(); |
| 486 } | 481 } |
| OLD | NEW |