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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // complete static library, so copy its object files. | 421 // complete static library, so copy its object files. |
422 std::vector<OutputFile> tool_outputs; // Prevent allocation in loop. | 422 std::vector<OutputFile> tool_outputs; // Prevent allocation in loop. |
423 for (const auto& source : dep->sources()) { | 423 for (const auto& source : dep->sources()) { |
424 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; | 424 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; |
425 if (GetOutputFilesForSource(dep, source, &tool_type, &tool_outputs)) { | 425 if (GetOutputFilesForSource(dep, source, &tool_type, &tool_outputs)) { |
426 // Only link the first output if there are more than one. | 426 // Only link the first output if there are more than one. |
427 extra_object_files->push_back(tool_outputs[0]); | 427 extra_object_files->push_back(tool_outputs[0]); |
428 } | 428 } |
429 } | 429 } |
430 } | 430 } |
| 431 |
| 432 // Add the source set itself as a non-linkable dependency on the current |
| 433 // target. This will make sure that anything the source set's stamp file |
| 434 // depends on (like data deps) are also built before the current target |
| 435 // can be complete. Otherwise, these will be skipped since this target |
| 436 // will depend only on the source set's object files. |
| 437 non_linkable_deps->push_back(dep); |
431 } else if (can_link_libs && dep->IsLinkable()) { | 438 } else if (can_link_libs && dep->IsLinkable()) { |
432 linkable_deps->push_back(dep); | 439 linkable_deps->push_back(dep); |
433 } else { | 440 } else { |
434 non_linkable_deps->push_back(dep); | 441 non_linkable_deps->push_back(dep); |
435 } | 442 } |
436 } | 443 } |
437 | 444 |
438 void NinjaBinaryTargetWriter::WriteOrderOnlyDependencies( | 445 void NinjaBinaryTargetWriter::WriteOrderOnlyDependencies( |
439 const UniqueVector<const Target*>& non_linkable_deps) { | 446 const UniqueVector<const Target*>& non_linkable_deps) { |
440 const std::vector<SourceFile>& data = target_->data(); | 447 if (!non_linkable_deps.empty()) { |
441 if (!non_linkable_deps.empty() || !data.empty()) { | |
442 out_ << " ||"; | 448 out_ << " ||"; |
443 | 449 |
444 // Non-linkable targets. | 450 // Non-linkable targets. |
445 for (const auto& non_linkable_dep : non_linkable_deps) { | 451 for (const auto& non_linkable_dep : non_linkable_deps) { |
446 out_ << " "; | 452 out_ << " "; |
447 path_output_.WriteFile(out_, non_linkable_dep->dependency_output_file()); | 453 path_output_.WriteFile(out_, non_linkable_dep->dependency_output_file()); |
448 } | 454 } |
449 } | 455 } |
450 } | 456 } |
451 | 457 |
(...skipping 20 matching lines...) Expand all Loading... |
472 return false; // No tool for this file (it's a header file or something). | 478 return false; // No tool for this file (it's a header file or something). |
473 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); | 479 const Tool* tool = target->toolchain()->GetTool(*computed_tool_type); |
474 if (!tool) | 480 if (!tool) |
475 return false; // Tool does not apply for this toolchain.file. | 481 return false; // Tool does not apply for this toolchain.file. |
476 | 482 |
477 // Figure out what output(s) this compiler produces. | 483 // Figure out what output(s) this compiler produces. |
478 SubstitutionWriter::ApplyListToCompilerAsOutputFile( | 484 SubstitutionWriter::ApplyListToCompilerAsOutputFile( |
479 target, source, tool->outputs(), outputs); | 485 target, source, tool->outputs(), outputs); |
480 return !outputs->empty(); | 486 return !outputs->empty(); |
481 } | 487 } |
OLD | NEW |