| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "tools/gn/ninja_binary_target_writer.h" | 8 #include "tools/gn/ninja_binary_target_writer.h" |
| 9 #include "tools/gn/scheduler.h" | 9 #include "tools/gn/scheduler.h" |
| 10 #include "tools/gn/target.h" | 10 #include "tools/gn/target.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 pch_toolchain.ToolchainSetupComplete(); | 402 pch_toolchain.ToolchainSetupComplete(); |
| 403 | 403 |
| 404 // This target doesn't specify precompiled headers. | 404 // This target doesn't specify precompiled headers. |
| 405 { | 405 { |
| 406 Target no_pch_target(&pch_settings, | 406 Target no_pch_target(&pch_settings, |
| 407 Label(SourceDir("//foo/"), "no_pch_target")); | 407 Label(SourceDir("//foo/"), "no_pch_target")); |
| 408 no_pch_target.set_output_type(Target::SOURCE_SET); | 408 no_pch_target.set_output_type(Target::SOURCE_SET); |
| 409 no_pch_target.visibility().SetPublic(); | 409 no_pch_target.visibility().SetPublic(); |
| 410 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); | 410 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); |
| 411 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); | 411 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); |
| 412 no_pch_target.config_values().cflags_c().push_back("-std=c99"); |
| 412 no_pch_target.SetToolchain(&pch_toolchain); | 413 no_pch_target.SetToolchain(&pch_toolchain); |
| 413 ASSERT_TRUE(no_pch_target.OnResolved(&err)); | 414 ASSERT_TRUE(no_pch_target.OnResolved(&err)); |
| 414 | 415 |
| 415 std::ostringstream out; | 416 std::ostringstream out; |
| 416 NinjaBinaryTargetWriter writer(&no_pch_target, out); | 417 NinjaBinaryTargetWriter writer(&no_pch_target, out); |
| 417 writer.Run(); | 418 writer.Run(); |
| 418 | 419 |
| 419 const char no_pch_expected[] = | 420 const char no_pch_expected[] = |
| 420 "defines =\n" | 421 "defines =\n" |
| 421 "include_dirs =\n" | 422 "include_dirs =\n" |
| 422 "cflags =\n" | 423 "cflags =\n" |
| 423 "cflags_c =\n" | 424 "cflags_c = -std=c99\n" |
| 424 "cflags_cc =\n" | 425 "cflags_cc =\n" |
| 425 "target_output_name = no_pch_target\n" | 426 "target_output_name = no_pch_target\n" |
| 426 "\n" | 427 "\n" |
| 427 "build withpch/obj/foo/no_pch_target.input1.o: " | 428 "build withpch/obj/foo/no_pch_target.input1.o: " |
| 428 "withpch_cxx ../../foo/input1.cc\n" | 429 "withpch_cxx ../../foo/input1.cc\n" |
| 429 "build withpch/obj/foo/no_pch_target.input2.o: " | 430 "build withpch/obj/foo/no_pch_target.input2.o: " |
| 430 "withpch_cc ../../foo/input2.c\n" | 431 "withpch_cc ../../foo/input2.c\n" |
| 431 "\n" | 432 "\n" |
| 432 "build withpch/obj/foo/no_pch_target.stamp: " | 433 "build withpch/obj/foo/no_pch_target.stamp: " |
| 433 "withpch_stamp withpch/obj/foo/no_pch_target.input1.o " | 434 "withpch_stamp withpch/obj/foo/no_pch_target.input1.o " |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 pch_toolchain.ToolchainSetupComplete(); | 531 pch_toolchain.ToolchainSetupComplete(); |
| 531 | 532 |
| 532 // This target doesn't specify precompiled headers. | 533 // This target doesn't specify precompiled headers. |
| 533 { | 534 { |
| 534 Target no_pch_target(&pch_settings, | 535 Target no_pch_target(&pch_settings, |
| 535 Label(SourceDir("//foo/"), "no_pch_target")); | 536 Label(SourceDir("//foo/"), "no_pch_target")); |
| 536 no_pch_target.set_output_type(Target::SOURCE_SET); | 537 no_pch_target.set_output_type(Target::SOURCE_SET); |
| 537 no_pch_target.visibility().SetPublic(); | 538 no_pch_target.visibility().SetPublic(); |
| 538 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); | 539 no_pch_target.sources().push_back(SourceFile("//foo/input1.cc")); |
| 539 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); | 540 no_pch_target.sources().push_back(SourceFile("//foo/input2.c")); |
| 541 no_pch_target.config_values().cflags_c().push_back("-std=c99"); |
| 540 no_pch_target.SetToolchain(&pch_toolchain); | 542 no_pch_target.SetToolchain(&pch_toolchain); |
| 541 ASSERT_TRUE(no_pch_target.OnResolved(&err)); | 543 ASSERT_TRUE(no_pch_target.OnResolved(&err)); |
| 542 | 544 |
| 543 std::ostringstream out; | 545 std::ostringstream out; |
| 544 NinjaBinaryTargetWriter writer(&no_pch_target, out); | 546 NinjaBinaryTargetWriter writer(&no_pch_target, out); |
| 545 writer.Run(); | 547 writer.Run(); |
| 546 | 548 |
| 547 const char no_pch_expected[] = | 549 const char no_pch_expected[] = |
| 548 "defines =\n" | 550 "defines =\n" |
| 549 "include_dirs =\n" | 551 "include_dirs =\n" |
| 550 "cflags =\n" | 552 "cflags =\n" |
| 551 "cflags_c =\n" | 553 "cflags_c = -std=c99\n" |
| 552 "cflags_cc =\n" | 554 "cflags_cc =\n" |
| 553 "target_output_name = no_pch_target\n" | 555 "target_output_name = no_pch_target\n" |
| 554 "\n" | 556 "\n" |
| 555 "build withpch/obj/foo/no_pch_target.input1.o: " | 557 "build withpch/obj/foo/no_pch_target.input1.o: " |
| 556 "withpch_cxx ../../foo/input1.cc\n" | 558 "withpch_cxx ../../foo/input1.cc\n" |
| 557 "build withpch/obj/foo/no_pch_target.input2.o: " | 559 "build withpch/obj/foo/no_pch_target.input2.o: " |
| 558 "withpch_cc ../../foo/input2.c\n" | 560 "withpch_cc ../../foo/input2.c\n" |
| 559 "\n" | 561 "\n" |
| 560 "build withpch/obj/foo/no_pch_target.stamp: " | 562 "build withpch/obj/foo/no_pch_target.stamp: " |
| 561 "withpch_stamp withpch/obj/foo/no_pch_target.input1.o " | 563 "withpch_stamp withpch/obj/foo/no_pch_target.input1.o " |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 630 |
| 629 EXPECT_FALSE(scheduler.is_failed()); | 631 EXPECT_FALSE(scheduler.is_failed()); |
| 630 | 632 |
| 631 std::ostringstream out; | 633 std::ostringstream out; |
| 632 NinjaBinaryTargetWriter writer(&target, out); | 634 NinjaBinaryTargetWriter writer(&target, out); |
| 633 writer.Run(); | 635 writer.Run(); |
| 634 | 636 |
| 635 // Should have issued an error. | 637 // Should have issued an error. |
| 636 EXPECT_TRUE(scheduler.is_failed()); | 638 EXPECT_TRUE(scheduler.is_failed()); |
| 637 } | 639 } |
| OLD | NEW |