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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 | 264 |
265 void NinjaBinaryTargetWriter::Run() { | 265 void NinjaBinaryTargetWriter::Run() { |
266 // Figure out what source types are needed. | 266 // Figure out what source types are needed. |
267 SourceFileTypeSet used_types; | 267 SourceFileTypeSet used_types; |
268 for (const auto& source : target_->sources()) | 268 for (const auto& source : target_->sources()) |
269 used_types.Set(GetSourceFileType(source)); | 269 used_types.Set(GetSourceFileType(source)); |
270 | 270 |
271 WriteCompilerVars(used_types); | 271 WriteCompilerVars(used_types); |
272 | 272 |
| 273 OutputFile input_dep = WriteInputsStampAndGetDep(); |
| 274 |
273 // The input dependencies will be an order-only dependency. This will cause | 275 // The input dependencies will be an order-only dependency. This will cause |
274 // Ninja to make sure the inputs are up to date before compiling this source, | 276 // Ninja to make sure the inputs are up to date before compiling this source, |
275 // but changes in the inputs deps won't cause the file to be recompiled. | 277 // but changes in the inputs deps won't cause the file to be recompiled. |
276 // | 278 // |
277 // This is important to prevent changes in unrelated actions that are | 279 // This is important to prevent changes in unrelated actions that are |
278 // upstream of this target from causing everything to be recompiled. | 280 // upstream of this target from causing everything to be recompiled. |
279 // | 281 // |
280 // Why can we get away with this rather than using implicit deps ("|", which | 282 // Why can we get away with this rather than using implicit deps ("|", which |
281 // will force rebuilds when the inputs change)? For source code, the | 283 // will force rebuilds when the inputs change)? For source code, the |
282 // computed dependencies of all headers will be computed by the compiler, | 284 // computed dependencies of all headers will be computed by the compiler, |
(...skipping 11 matching lines...) Expand all Loading... |
294 // built first. This is exactly what Ninja's order-only dependencies | 296 // built first. This is exactly what Ninja's order-only dependencies |
295 // expresses. | 297 // expresses. |
296 OutputFile order_only_dep = | 298 OutputFile order_only_dep = |
297 WriteInputDepsStampAndGetDep(std::vector<const Target*>()); | 299 WriteInputDepsStampAndGetDep(std::vector<const Target*>()); |
298 | 300 |
299 // For GCC builds, the .gch files are not object files, but still need to be | 301 // For GCC builds, the .gch files are not object files, but still need to be |
300 // added as explicit dependencies below. The .gch output files are placed in | 302 // added as explicit dependencies below. The .gch output files are placed in |
301 // |pch_other_files|. This is to prevent linking against them. | 303 // |pch_other_files|. This is to prevent linking against them. |
302 std::vector<OutputFile> pch_obj_files; | 304 std::vector<OutputFile> pch_obj_files; |
303 std::vector<OutputFile> pch_other_files; | 305 std::vector<OutputFile> pch_other_files; |
304 WritePCHCommands(used_types, order_only_dep, | 306 WritePCHCommands(used_types, input_dep, order_only_dep, |
305 &pch_obj_files, &pch_other_files); | 307 &pch_obj_files, &pch_other_files); |
306 std::vector<OutputFile>* pch_files = !pch_obj_files.empty() ? | 308 std::vector<OutputFile>* pch_files = !pch_obj_files.empty() ? |
307 &pch_obj_files : &pch_other_files; | 309 &pch_obj_files : &pch_other_files; |
308 | 310 |
309 // Treat all pch output files as explicit dependencies of all | 311 // Treat all pch output files as explicit dependencies of all |
310 // compiles that support them. Some notes: | 312 // compiles that support them. Some notes: |
311 // | 313 // |
312 // - On Windows, the .pch file is the input to the compile, not the | 314 // - On Windows, the .pch file is the input to the compile, not the |
313 // precompiled header's corresponding object file that we're using here. | 315 // precompiled header's corresponding object file that we're using here. |
314 // But Ninja's depslog doesn't support multiple outputs from the | 316 // But Ninja's depslog doesn't support multiple outputs from the |
315 // precompiled header compile step (it outputs both the .pch file and a | 317 // precompiled header compile step (it outputs both the .pch file and a |
316 // corresponding .obj file). So we consistently list the .obj file and the | 318 // corresponding .obj file). So we consistently list the .obj file and the |
317 // .pch file we really need comes along with it. | 319 // .pch file we really need comes along with it. |
318 // | 320 // |
319 // - GCC .gch files are not object files, therefore they are not added to the | 321 // - GCC .gch files are not object files, therefore they are not added to the |
320 // object file list. | 322 // object file list. |
321 std::vector<OutputFile> obj_files; | 323 std::vector<OutputFile> obj_files; |
322 std::vector<SourceFile> other_files; | 324 std::vector<SourceFile> other_files; |
323 WriteSources(*pch_files, order_only_dep, &obj_files, &other_files); | 325 WriteSources(*pch_files, input_dep, order_only_dep, &obj_files, &other_files); |
324 | 326 |
325 // Link all MSVC pch object files. The vector will be empty on GCC toolchains. | 327 // Link all MSVC pch object files. The vector will be empty on GCC toolchains. |
326 obj_files.insert(obj_files.end(), pch_obj_files.begin(), pch_obj_files.end()); | 328 obj_files.insert(obj_files.end(), pch_obj_files.begin(), pch_obj_files.end()); |
327 if (!CheckForDuplicateObjectFiles(obj_files)) | 329 if (!CheckForDuplicateObjectFiles(obj_files)) |
328 return; | 330 return; |
329 | 331 |
330 if (target_->output_type() == Target::SOURCE_SET) { | 332 if (target_->output_type() == Target::SOURCE_SET) { |
331 WriteSourceSetStamp(obj_files); | 333 WriteSourceSetStamp(obj_files); |
332 #ifndef NDEBUG | 334 #ifndef NDEBUG |
333 // Verify that the function that separately computes a source set's object | 335 // Verify that the function that separately computes a source set's object |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 Toolchain::TYPE_OBJC, &ConfigValues::cflags_objc, opts); | 396 Toolchain::TYPE_OBJC, &ConfigValues::cflags_objc, opts); |
395 } | 397 } |
396 if (used_types.Get(SOURCE_MM)) { | 398 if (used_types.Get(SOURCE_MM)) { |
397 WriteOneFlag(SUBSTITUTION_CFLAGS_OBJCC, has_precompiled_headers, | 399 WriteOneFlag(SUBSTITUTION_CFLAGS_OBJCC, has_precompiled_headers, |
398 Toolchain::TYPE_OBJCXX, &ConfigValues::cflags_objcc, opts); | 400 Toolchain::TYPE_OBJCXX, &ConfigValues::cflags_objcc, opts); |
399 } | 401 } |
400 | 402 |
401 WriteSharedVars(subst); | 403 WriteSharedVars(subst); |
402 } | 404 } |
403 | 405 |
| 406 OutputFile NinjaBinaryTargetWriter::WriteInputsStampAndGetDep() const { |
| 407 CHECK(target_->toolchain()) |
| 408 << "Toolchain not set on target " |
| 409 << target_->label().GetUserVisibleName(true); |
| 410 |
| 411 if (target_->inputs().size() == 0) |
| 412 return OutputFile(); // No inputs |
| 413 |
| 414 // If we only have one input, return it directly instead of writing a stamp |
| 415 // file for it. |
| 416 if (target_->inputs().size() == 1) |
| 417 return OutputFile(settings_->build_settings(), target_->inputs()[0]); |
| 418 |
| 419 // Make a stamp file. |
| 420 OutputFile input_stamp_file( |
| 421 RebasePath(GetTargetOutputDir(target_).value(), |
| 422 settings_->build_settings()->build_dir(), |
| 423 settings_->build_settings()->root_path_utf8())); |
| 424 input_stamp_file.value().append(target_->label().name()); |
| 425 input_stamp_file.value().append(".inputs.stamp"); |
| 426 |
| 427 out_ << "build "; |
| 428 path_output_.WriteFile(out_, input_stamp_file); |
| 429 out_ << ": " |
| 430 << GetNinjaRulePrefixForToolchain(settings_) |
| 431 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
| 432 |
| 433 // File inputs. |
| 434 for (const auto& input : target_->inputs()) { |
| 435 out_ << " "; |
| 436 path_output_.WriteFile(out_, input); |
| 437 } |
| 438 |
| 439 out_ << "\n"; |
| 440 return input_stamp_file; |
| 441 } |
| 442 |
404 void NinjaBinaryTargetWriter::WriteOneFlag( | 443 void NinjaBinaryTargetWriter::WriteOneFlag( |
405 SubstitutionType subst_enum, | 444 SubstitutionType subst_enum, |
406 bool has_precompiled_headers, | 445 bool has_precompiled_headers, |
407 Toolchain::ToolType tool_type, | 446 Toolchain::ToolType tool_type, |
408 const std::vector<std::string>& (ConfigValues::* getter)() const, | 447 const std::vector<std::string>& (ConfigValues::* getter)() const, |
409 EscapeOptions flag_escape_options) { | 448 EscapeOptions flag_escape_options) { |
410 if (!target_->toolchain()->substitution_bits().used[subst_enum]) | 449 if (!target_->toolchain()->substitution_bits().used[subst_enum]) |
411 return; | 450 return; |
412 | 451 |
413 out_ << kSubstitutionNinjaNames[subst_enum] << " ="; | 452 out_ << kSubstitutionNinjaNames[subst_enum] << " ="; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 485 } |
447 } else { | 486 } else { |
448 RecursiveTargetConfigStringsToStream(target_, getter, | 487 RecursiveTargetConfigStringsToStream(target_, getter, |
449 flag_escape_options, out_); | 488 flag_escape_options, out_); |
450 } | 489 } |
451 out_ << std::endl; | 490 out_ << std::endl; |
452 } | 491 } |
453 | 492 |
454 void NinjaBinaryTargetWriter::WritePCHCommands( | 493 void NinjaBinaryTargetWriter::WritePCHCommands( |
455 const SourceFileTypeSet& used_types, | 494 const SourceFileTypeSet& used_types, |
| 495 const OutputFile& input_dep, |
456 const OutputFile& order_only_dep, | 496 const OutputFile& order_only_dep, |
457 std::vector<OutputFile>* object_files, | 497 std::vector<OutputFile>* object_files, |
458 std::vector<OutputFile>* other_files) { | 498 std::vector<OutputFile>* other_files) { |
459 if (!target_->config_values().has_precompiled_headers()) | 499 if (!target_->config_values().has_precompiled_headers()) |
460 return; | 500 return; |
461 | 501 |
462 const Tool* tool_c = target_->toolchain()->GetTool(Toolchain::TYPE_CC); | 502 const Tool* tool_c = target_->toolchain()->GetTool(Toolchain::TYPE_CC); |
463 if (tool_c && | 503 if (tool_c && |
464 tool_c->precompiled_header_type() != Tool::PCH_NONE && | 504 tool_c->precompiled_header_type() != Tool::PCH_NONE && |
465 used_types.Get(SOURCE_C)) { | 505 used_types.Get(SOURCE_C)) { |
466 WritePCHCommand(SUBSTITUTION_CFLAGS_C, | 506 WritePCHCommand(SUBSTITUTION_CFLAGS_C, |
467 Toolchain::TYPE_CC, | 507 Toolchain::TYPE_CC, |
468 tool_c->precompiled_header_type(), | 508 tool_c->precompiled_header_type(), |
469 order_only_dep, object_files, other_files); | 509 input_dep, order_only_dep, object_files, other_files); |
470 } | 510 } |
471 const Tool* tool_cxx = target_->toolchain()->GetTool(Toolchain::TYPE_CXX); | 511 const Tool* tool_cxx = target_->toolchain()->GetTool(Toolchain::TYPE_CXX); |
472 if (tool_cxx && | 512 if (tool_cxx && |
473 tool_cxx->precompiled_header_type() != Tool::PCH_NONE && | 513 tool_cxx->precompiled_header_type() != Tool::PCH_NONE && |
474 used_types.Get(SOURCE_CPP)) { | 514 used_types.Get(SOURCE_CPP)) { |
475 WritePCHCommand(SUBSTITUTION_CFLAGS_CC, | 515 WritePCHCommand(SUBSTITUTION_CFLAGS_CC, |
476 Toolchain::TYPE_CXX, | 516 Toolchain::TYPE_CXX, |
477 tool_cxx->precompiled_header_type(), | 517 tool_cxx->precompiled_header_type(), |
478 order_only_dep, object_files, other_files); | 518 input_dep, order_only_dep, object_files, other_files); |
479 } | 519 } |
480 | 520 |
481 const Tool* tool_objc = target_->toolchain()->GetTool(Toolchain::TYPE_OBJC); | 521 const Tool* tool_objc = target_->toolchain()->GetTool(Toolchain::TYPE_OBJC); |
482 if (tool_objc && | 522 if (tool_objc && |
483 tool_objc->precompiled_header_type() == Tool::PCH_GCC && | 523 tool_objc->precompiled_header_type() == Tool::PCH_GCC && |
484 used_types.Get(SOURCE_M)) { | 524 used_types.Get(SOURCE_M)) { |
485 WritePCHCommand(SUBSTITUTION_CFLAGS_OBJC, | 525 WritePCHCommand(SUBSTITUTION_CFLAGS_OBJC, |
486 Toolchain::TYPE_OBJC, | 526 Toolchain::TYPE_OBJC, |
487 tool_objc->precompiled_header_type(), | 527 tool_objc->precompiled_header_type(), |
488 order_only_dep, object_files, other_files); | 528 input_dep, order_only_dep, object_files, other_files); |
489 } | 529 } |
490 | 530 |
491 const Tool* tool_objcxx = | 531 const Tool* tool_objcxx = |
492 target_->toolchain()->GetTool(Toolchain::TYPE_OBJCXX); | 532 target_->toolchain()->GetTool(Toolchain::TYPE_OBJCXX); |
493 if (tool_objcxx && | 533 if (tool_objcxx && |
494 tool_objcxx->precompiled_header_type() == Tool::PCH_GCC && | 534 tool_objcxx->precompiled_header_type() == Tool::PCH_GCC && |
495 used_types.Get(SOURCE_MM)) { | 535 used_types.Get(SOURCE_MM)) { |
496 WritePCHCommand(SUBSTITUTION_CFLAGS_OBJCC, | 536 WritePCHCommand(SUBSTITUTION_CFLAGS_OBJCC, |
497 Toolchain::TYPE_OBJCXX, | 537 Toolchain::TYPE_OBJCXX, |
498 tool_objcxx->precompiled_header_type(), | 538 tool_objcxx->precompiled_header_type(), |
499 order_only_dep, object_files, other_files); | 539 input_dep, order_only_dep, object_files, other_files); |
500 } | 540 } |
501 } | 541 } |
502 | 542 |
503 void NinjaBinaryTargetWriter::WritePCHCommand( | 543 void NinjaBinaryTargetWriter::WritePCHCommand( |
504 SubstitutionType flag_type, | 544 SubstitutionType flag_type, |
505 Toolchain::ToolType tool_type, | 545 Toolchain::ToolType tool_type, |
506 Tool::PrecompiledHeaderType header_type, | 546 Tool::PrecompiledHeaderType header_type, |
| 547 const OutputFile& input_dep, |
507 const OutputFile& order_only_dep, | 548 const OutputFile& order_only_dep, |
508 std::vector<OutputFile>* object_files, | 549 std::vector<OutputFile>* object_files, |
509 std::vector<OutputFile>* other_files) { | 550 std::vector<OutputFile>* other_files) { |
510 switch (header_type) { | 551 switch (header_type) { |
511 case Tool::PCH_MSVC: | 552 case Tool::PCH_MSVC: |
512 WriteWindowsPCHCommand(flag_type, tool_type, order_only_dep, | 553 WriteWindowsPCHCommand(flag_type, tool_type, input_dep, order_only_dep, |
513 object_files); | 554 object_files); |
514 break; | 555 break; |
515 case Tool::PCH_GCC: | 556 case Tool::PCH_GCC: |
516 WriteGCCPCHCommand(flag_type, tool_type, order_only_dep, | 557 WriteGCCPCHCommand(flag_type, tool_type, input_dep, order_only_dep, |
517 other_files); | 558 other_files); |
518 break; | 559 break; |
519 case Tool::PCH_NONE: | 560 case Tool::PCH_NONE: |
520 NOTREACHED() << "Cannot write a PCH command with no PCH header type"; | 561 NOTREACHED() << "Cannot write a PCH command with no PCH header type"; |
521 break; | 562 break; |
522 } | 563 } |
523 } | 564 } |
524 | 565 |
525 void NinjaBinaryTargetWriter::WriteGCCPCHCommand( | 566 void NinjaBinaryTargetWriter::WriteGCCPCHCommand( |
526 SubstitutionType flag_type, | 567 SubstitutionType flag_type, |
527 Toolchain::ToolType tool_type, | 568 Toolchain::ToolType tool_type, |
| 569 const OutputFile& input_dep, |
528 const OutputFile& order_only_dep, | 570 const OutputFile& order_only_dep, |
529 std::vector<OutputFile>* gch_files) { | 571 std::vector<OutputFile>* gch_files) { |
530 // Compute the pch output file (it will be language-specific). | 572 // Compute the pch output file (it will be language-specific). |
531 std::vector<OutputFile> outputs; | 573 std::vector<OutputFile> outputs; |
532 GetPCHOutputFiles(target_, tool_type, &outputs); | 574 GetPCHOutputFiles(target_, tool_type, &outputs); |
533 if (outputs.empty()) | 575 if (outputs.empty()) |
534 return; | 576 return; |
535 | 577 |
536 gch_files->insert(gch_files->end(), outputs.begin(), outputs.end()); | 578 gch_files->insert(gch_files->end(), outputs.begin(), outputs.end()); |
537 | 579 |
| 580 std::vector<OutputFile> extra_deps; |
| 581 if (!input_dep.value().empty()) |
| 582 extra_deps.push_back(input_dep); |
| 583 |
538 // Build line to compile the file. | 584 // Build line to compile the file. |
539 WriteCompilerBuildLine(target_->config_values().precompiled_source(), | 585 WriteCompilerBuildLine(target_->config_values().precompiled_source(), |
540 std::vector<OutputFile>(), order_only_dep, tool_type, | 586 extra_deps, order_only_dep, tool_type, outputs); |
541 outputs); | |
542 | 587 |
543 // This build line needs a custom language-specific flags value. Rule-specific | 588 // This build line needs a custom language-specific flags value. Rule-specific |
544 // variables are just indented underneath the rule line. | 589 // variables are just indented underneath the rule line. |
545 out_ << " " << kSubstitutionNinjaNames[flag_type] << " ="; | 590 out_ << " " << kSubstitutionNinjaNames[flag_type] << " ="; |
546 | 591 |
547 // Each substitution flag is overwritten in the target rule to replace the | 592 // Each substitution flag is overwritten in the target rule to replace the |
548 // implicitly generated -include flag with the -x <header lang> flag required | 593 // implicitly generated -include flag with the -x <header lang> flag required |
549 // for .gch targets. | 594 // for .gch targets. |
550 EscapeOptions opts = GetFlagOptions(); | 595 EscapeOptions opts = GetFlagOptions(); |
551 if (tool_type == Toolchain::TYPE_CC) { | 596 if (tool_type == Toolchain::TYPE_CC) { |
(...skipping 14 matching lines...) Expand all Loading... |
566 out_ << " -x " << GetPCHLangForToolType(tool_type); | 611 out_ << " -x " << GetPCHLangForToolType(tool_type); |
567 | 612 |
568 // Write two blank lines to help separate the PCH build lines from the | 613 // Write two blank lines to help separate the PCH build lines from the |
569 // regular source build lines. | 614 // regular source build lines. |
570 out_ << std::endl << std::endl; | 615 out_ << std::endl << std::endl; |
571 } | 616 } |
572 | 617 |
573 void NinjaBinaryTargetWriter::WriteWindowsPCHCommand( | 618 void NinjaBinaryTargetWriter::WriteWindowsPCHCommand( |
574 SubstitutionType flag_type, | 619 SubstitutionType flag_type, |
575 Toolchain::ToolType tool_type, | 620 Toolchain::ToolType tool_type, |
| 621 const OutputFile& input_dep, |
576 const OutputFile& order_only_dep, | 622 const OutputFile& order_only_dep, |
577 std::vector<OutputFile>* object_files) { | 623 std::vector<OutputFile>* object_files) { |
578 // Compute the pch output file (it will be language-specific). | 624 // Compute the pch output file (it will be language-specific). |
579 std::vector<OutputFile> outputs; | 625 std::vector<OutputFile> outputs; |
580 GetPCHOutputFiles(target_, tool_type, &outputs); | 626 GetPCHOutputFiles(target_, tool_type, &outputs); |
581 if (outputs.empty()) | 627 if (outputs.empty()) |
582 return; | 628 return; |
583 | 629 |
584 object_files->insert(object_files->end(), outputs.begin(), outputs.end()); | 630 object_files->insert(object_files->end(), outputs.begin(), outputs.end()); |
585 | 631 |
| 632 std::vector<OutputFile> extra_deps; |
| 633 if (!input_dep.value().empty()) |
| 634 extra_deps.push_back(input_dep); |
| 635 |
586 // Build line to compile the file. | 636 // Build line to compile the file. |
587 WriteCompilerBuildLine(target_->config_values().precompiled_source(), | 637 WriteCompilerBuildLine(target_->config_values().precompiled_source(), |
588 std::vector<OutputFile>(), order_only_dep, tool_type, | 638 extra_deps, order_only_dep, tool_type, outputs); |
589 outputs); | |
590 | 639 |
591 // This build line needs a custom language-specific flags value. Rule-specific | 640 // This build line needs a custom language-specific flags value. Rule-specific |
592 // variables are just indented underneath the rule line. | 641 // variables are just indented underneath the rule line. |
593 out_ << " " << kSubstitutionNinjaNames[flag_type] << " ="; | 642 out_ << " " << kSubstitutionNinjaNames[flag_type] << " ="; |
594 | 643 |
595 // Append the command to generate the .pch file. | 644 // Append the command to generate the .pch file. |
596 // This adds the value to the existing flag instead of overwriting it. | 645 // This adds the value to the existing flag instead of overwriting it. |
597 out_ << " ${" << kSubstitutionNinjaNames[flag_type] << "}"; | 646 out_ << " ${" << kSubstitutionNinjaNames[flag_type] << "}"; |
598 out_ << " /Yc" << target_->config_values().precompiled_header(); | 647 out_ << " /Yc" << target_->config_values().precompiled_header(); |
599 | 648 |
600 // Write two blank lines to help separate the PCH build lines from the | 649 // Write two blank lines to help separate the PCH build lines from the |
601 // regular source build lines. | 650 // regular source build lines. |
602 out_ << std::endl << std::endl; | 651 out_ << std::endl << std::endl; |
603 } | 652 } |
604 | 653 |
605 void NinjaBinaryTargetWriter::WriteSources( | 654 void NinjaBinaryTargetWriter::WriteSources( |
606 const std::vector<OutputFile>& pch_deps, | 655 const std::vector<OutputFile>& pch_deps, |
| 656 const OutputFile& input_dep, |
607 const OutputFile& order_only_dep, | 657 const OutputFile& order_only_dep, |
608 std::vector<OutputFile>* object_files, | 658 std::vector<OutputFile>* object_files, |
609 std::vector<SourceFile>* other_files) { | 659 std::vector<SourceFile>* other_files) { |
610 object_files->reserve(object_files->size() + target_->sources().size()); | 660 object_files->reserve(object_files->size() + target_->sources().size()); |
611 | 661 |
612 std::vector<OutputFile> tool_outputs; // Prevent reallocation in loop. | 662 std::vector<OutputFile> tool_outputs; // Prevent reallocation in loop. |
613 std::vector<OutputFile> deps; | 663 std::vector<OutputFile> deps; |
614 for (const auto& source : target_->sources()) { | 664 for (const auto& source : target_->sources()) { |
615 // Clear the vector but maintain the max capacity to prevent reallocations. | 665 // Clear the vector but maintain the max capacity to prevent reallocations. |
616 deps.resize(0); | 666 deps.resize(0); |
617 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; | 667 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; |
618 if (!target_->GetOutputFilesForSource(source, &tool_type, &tool_outputs)) { | 668 if (!target_->GetOutputFilesForSource(source, &tool_type, &tool_outputs)) { |
619 if (GetSourceFileType(source) == SOURCE_DEF) | 669 if (GetSourceFileType(source) == SOURCE_DEF) |
620 other_files->push_back(source); | 670 other_files->push_back(source); |
621 continue; // No output for this source. | 671 continue; // No output for this source. |
622 } | 672 } |
623 | 673 |
| 674 if (!input_dep.value().empty()) |
| 675 deps.push_back(input_dep); |
| 676 |
624 if (tool_type != Toolchain::TYPE_NONE) { | 677 if (tool_type != Toolchain::TYPE_NONE) { |
625 // Only include PCH deps that correspond to the tool type, for instance, | 678 // Only include PCH deps that correspond to the tool type, for instance, |
626 // do not specify target_name.precompile.cc.obj (a CXX PCH file) as a dep | 679 // do not specify target_name.precompile.cc.obj (a CXX PCH file) as a dep |
627 // for the output of a C tool type. | 680 // for the output of a C tool type. |
628 // | 681 // |
629 // This makes the assumption that pch_deps only contains pch output files | 682 // This makes the assumption that pch_deps only contains pch output files |
630 // with the naming scheme specified in GetWindowsPCHObjectExtension or | 683 // with the naming scheme specified in GetWindowsPCHObjectExtension or |
631 // GetGCCPCHOutputExtension. | 684 // GetGCCPCHOutputExtension. |
632 const Tool* tool = target_->toolchain()->GetTool(tool_type); | 685 const Tool* tool = target_->toolchain()->GetTool(tool_type); |
633 if (tool->precompiled_header_type() != Tool::PCH_NONE) { | 686 if (tool->precompiled_header_type() != Tool::PCH_NONE) { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 "\n" | 1068 "\n" |
1016 "In the latter case, either rename one of the files or move one of\n" | 1069 "In the latter case, either rename one of the files or move one of\n" |
1017 "the sources to a separate source_set to avoid them both being in\n" | 1070 "the sources to a separate source_set to avoid them both being in\n" |
1018 "the same target."); | 1071 "the same target."); |
1019 g_scheduler->FailWithError(err); | 1072 g_scheduler->FailWithError(err); |
1020 return false; | 1073 return false; |
1021 } | 1074 } |
1022 } | 1075 } |
1023 return true; | 1076 return true; |
1024 } | 1077 } |
OLD | NEW |