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 <sstream> | 7 #include <sstream> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 TestWithScope setup; | 469 TestWithScope setup; |
470 | 470 |
471 // A precompiled header toolchain. | 471 // A precompiled header toolchain. |
472 Settings pch_settings(setup.build_settings(), "withpch/"); | 472 Settings pch_settings(setup.build_settings(), "withpch/"); |
473 Toolchain pch_toolchain(&pch_settings, | 473 Toolchain pch_toolchain(&pch_settings, |
474 Label(SourceDir("//toolchain/"), "withpch")); | 474 Label(SourceDir("//toolchain/"), "withpch")); |
475 pch_settings.set_toolchain_label(pch_toolchain.label()); | 475 pch_settings.set_toolchain_label(pch_toolchain.label()); |
476 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); | 476 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); |
477 | 477 |
478 // Declare a C++ compiler that supports PCH. | 478 // Declare a C++ compiler that supports PCH. |
479 scoped_ptr<Tool> cxx_tool(new Tool); | 479 std::unique_ptr<Tool> cxx_tool(new Tool); |
480 TestWithScope::SetCommandForTool( | 480 TestWithScope::SetCommandForTool( |
481 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " | 481 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " |
482 "-o {{output}}", | 482 "-o {{output}}", |
483 cxx_tool.get()); | 483 cxx_tool.get()); |
484 cxx_tool->set_outputs(SubstitutionList::MakeForTest( | 484 cxx_tool->set_outputs(SubstitutionList::MakeForTest( |
485 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); | 485 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); |
486 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC); | 486 cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC); |
487 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); | 487 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); |
488 | 488 |
489 // Add a C compiler as well. | 489 // Add a C compiler as well. |
490 scoped_ptr<Tool> cc_tool(new Tool); | 490 std::unique_ptr<Tool> cc_tool(new Tool); |
491 TestWithScope::SetCommandForTool( | 491 TestWithScope::SetCommandForTool( |
492 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " | 492 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " |
493 "-o {{output}}", | 493 "-o {{output}}", |
494 cc_tool.get()); | 494 cc_tool.get()); |
495 cc_tool->set_outputs(SubstitutionList::MakeForTest( | 495 cc_tool->set_outputs(SubstitutionList::MakeForTest( |
496 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); | 496 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); |
497 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC); | 497 cc_tool->set_precompiled_header_type(Tool::PCH_MSVC); |
498 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); | 498 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); |
499 pch_toolchain.ToolchainSetupComplete(); | 499 pch_toolchain.ToolchainSetupComplete(); |
500 | 500 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 TestWithScope setup; | 597 TestWithScope setup; |
598 | 598 |
599 // A precompiled header toolchain. | 599 // A precompiled header toolchain. |
600 Settings pch_settings(setup.build_settings(), "withpch/"); | 600 Settings pch_settings(setup.build_settings(), "withpch/"); |
601 Toolchain pch_toolchain(&pch_settings, | 601 Toolchain pch_toolchain(&pch_settings, |
602 Label(SourceDir("//toolchain/"), "withpch")); | 602 Label(SourceDir("//toolchain/"), "withpch")); |
603 pch_settings.set_toolchain_label(pch_toolchain.label()); | 603 pch_settings.set_toolchain_label(pch_toolchain.label()); |
604 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); | 604 pch_settings.set_default_toolchain_label(setup.toolchain()->label()); |
605 | 605 |
606 // Declare a C++ compiler that supports PCH. | 606 // Declare a C++ compiler that supports PCH. |
607 scoped_ptr<Tool> cxx_tool(new Tool); | 607 std::unique_ptr<Tool> cxx_tool(new Tool); |
608 TestWithScope::SetCommandForTool( | 608 TestWithScope::SetCommandForTool( |
609 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " | 609 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " |
610 "-o {{output}}", | 610 "-o {{output}}", |
611 cxx_tool.get()); | 611 cxx_tool.get()); |
612 cxx_tool->set_outputs(SubstitutionList::MakeForTest( | 612 cxx_tool->set_outputs(SubstitutionList::MakeForTest( |
613 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); | 613 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); |
614 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC); | 614 cxx_tool->set_precompiled_header_type(Tool::PCH_GCC); |
615 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); | 615 pch_toolchain.SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); |
616 pch_toolchain.ToolchainSetupComplete(); | 616 pch_toolchain.ToolchainSetupComplete(); |
617 | 617 |
618 // Add a C compiler as well. | 618 // Add a C compiler as well. |
619 scoped_ptr<Tool> cc_tool(new Tool); | 619 std::unique_ptr<Tool> cc_tool(new Tool); |
620 TestWithScope::SetCommandForTool( | 620 TestWithScope::SetCommandForTool( |
621 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " | 621 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " |
622 "-o {{output}}", | 622 "-o {{output}}", |
623 cc_tool.get()); | 623 cc_tool.get()); |
624 cc_tool->set_outputs(SubstitutionList::MakeForTest( | 624 cc_tool->set_outputs(SubstitutionList::MakeForTest( |
625 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); | 625 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); |
626 cc_tool->set_precompiled_header_type(Tool::PCH_GCC); | 626 cc_tool->set_precompiled_header_type(Tool::PCH_GCC); |
627 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); | 627 pch_toolchain.SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); |
628 pch_toolchain.ToolchainSetupComplete(); | 628 pch_toolchain.ToolchainSetupComplete(); |
629 | 629 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 | 727 |
728 EXPECT_FALSE(scheduler.is_failed()); | 728 EXPECT_FALSE(scheduler.is_failed()); |
729 | 729 |
730 std::ostringstream out; | 730 std::ostringstream out; |
731 NinjaBinaryTargetWriter writer(&target, out); | 731 NinjaBinaryTargetWriter writer(&target, out); |
732 writer.Run(); | 732 writer.Run(); |
733 | 733 |
734 // Should have issued an error. | 734 // Should have issued an error. |
735 EXPECT_TRUE(scheduler.is_failed()); | 735 EXPECT_TRUE(scheduler.is_failed()); |
736 } | 736 } |
OLD | NEW |