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 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "tools/gn/config_values_extractors.h" | 10 #include "tools/gn/config_values_extractors.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 for (size_t i = 0; i < non_linkable_deps.size(); i++) | 359 for (size_t i = 0; i < non_linkable_deps.size(); i++) |
360 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file()); | 360 order_only_deps.push_back(non_linkable_deps[i]->dependency_output_file()); |
361 | 361 |
362 WriteStampForTarget(object_files, order_only_deps); | 362 WriteStampForTarget(object_files, order_only_deps); |
363 } | 363 } |
364 | 364 |
365 void NinjaBinaryTargetWriter::GetDeps( | 365 void NinjaBinaryTargetWriter::GetDeps( |
366 UniqueVector<OutputFile>* extra_object_files, | 366 UniqueVector<OutputFile>* extra_object_files, |
367 UniqueVector<const Target*>* linkable_deps, | 367 UniqueVector<const Target*>* linkable_deps, |
368 UniqueVector<const Target*>* non_linkable_deps) const { | 368 UniqueVector<const Target*>* non_linkable_deps) const { |
369 const LabelTargetVector& deps = target_->deps(); | |
370 const UniqueVector<const Target*>& inherited = | 369 const UniqueVector<const Target*>& inherited = |
371 target_->inherited_libraries(); | 370 target_->inherited_libraries(); |
372 | 371 |
373 // Normal deps. | 372 // Normal public/private deps. |
374 for (size_t i = 0; i < deps.size(); i++) { | 373 for (DepsIterator iter(target_, DepsIterator::LINKED_ONLY); !iter.done(); |
375 ClassifyDependency(deps[i].ptr, extra_object_files, | 374 iter.Advance()) { |
| 375 ClassifyDependency(iter.target(), extra_object_files, |
376 linkable_deps, non_linkable_deps); | 376 linkable_deps, non_linkable_deps); |
377 } | 377 } |
378 | 378 |
379 // Inherited libraries. | 379 // Inherited libraries. |
380 for (size_t i = 0; i < inherited.size(); i++) { | 380 for (size_t i = 0; i < inherited.size(); i++) { |
381 ClassifyDependency(inherited[i], extra_object_files, | 381 ClassifyDependency(inherited[i], extra_object_files, |
382 linkable_deps, non_linkable_deps); | 382 linkable_deps, non_linkable_deps); |
383 } | 383 } |
384 | 384 |
385 // Data deps. | 385 // Data deps. |
386 const LabelTargetVector& datadeps = target_->datadeps(); | 386 const LabelTargetVector& data_deps = target_->data_deps(); |
387 for (size_t i = 0; i < datadeps.size(); i++) | 387 for (size_t i = 0; i < data_deps.size(); i++) |
388 non_linkable_deps->push_back(datadeps[i].ptr); | 388 non_linkable_deps->push_back(data_deps[i].ptr); |
389 } | 389 } |
390 | 390 |
391 void NinjaBinaryTargetWriter::ClassifyDependency( | 391 void NinjaBinaryTargetWriter::ClassifyDependency( |
392 const Target* dep, | 392 const Target* dep, |
393 UniqueVector<OutputFile>* extra_object_files, | 393 UniqueVector<OutputFile>* extra_object_files, |
394 UniqueVector<const Target*>* linkable_deps, | 394 UniqueVector<const Target*>* linkable_deps, |
395 UniqueVector<const Target*>* non_linkable_deps) const { | 395 UniqueVector<const Target*>* non_linkable_deps) const { |
396 // Only the following types of outputs have libraries linked into them: | 396 // Only the following types of outputs have libraries linked into them: |
397 // EXECUTABLE | 397 // EXECUTABLE |
398 // SHARED_LIBRARY | 398 // SHARED_LIBRARY |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 return false; // No tool for this file (it's a header file or something). | 468 return false; // No tool for this file (it's a header file or something). |
469 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); | 469 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); |
470 if (!tool) | 470 if (!tool) |
471 return false; // Tool does not apply for this toolchain.file. | 471 return false; // Tool does not apply for this toolchain.file. |
472 | 472 |
473 // Figure out what output(s) this compiler produces. | 473 // Figure out what output(s) this compiler produces. |
474 SubstitutionWriter::ApplyListToCompilerAsOutputFile( | 474 SubstitutionWriter::ApplyListToCompilerAsOutputFile( |
475 target, source, tool->outputs(), outputs); | 475 target, source, tool->outputs(), outputs); |
476 return !outputs->empty(); | 476 return !outputs->empty(); |
477 } | 477 } |
OLD | NEW |