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/target.h" | 5 #include "tools/gn/target.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); | 451 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); |
452 | 452 |
453 Target target(setup.settings(), Label(SourceDir("//a/"), "a")); | 453 Target target(setup.settings(), Label(SourceDir("//a/"), "a")); |
454 target.set_output_type(Target::SHARED_LIBRARY); | 454 target.set_output_type(Target::SHARED_LIBRARY); |
455 target.SetToolchain(&toolchain); | 455 target.SetToolchain(&toolchain); |
456 ASSERT_TRUE(target.OnResolved(&err)); | 456 ASSERT_TRUE(target.OnResolved(&err)); |
457 | 457 |
458 EXPECT_EQ("./liba.so", target.link_output_file().value()); | 458 EXPECT_EQ("./liba.so", target.link_output_file().value()); |
459 EXPECT_EQ("./liba.so.TOC", target.dependency_output_file().value()); | 459 EXPECT_EQ("./liba.so.TOC", target.dependency_output_file().value()); |
| 460 EXPECT_EQ("./liba.so", target.runtime_link_output_file().value()); |
| 461 } |
| 462 |
| 463 // Tests that runtime_link output works without an explicit link_output for |
| 464 // solink tools. |
| 465 TEST(Target, RuntimeLinkOuput) { |
| 466 TestWithScope setup; |
| 467 Err err; |
| 468 |
| 469 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc")); |
| 470 |
| 471 scoped_ptr<Tool> solink_tool(new Tool()); |
| 472 solink_tool->set_output_prefix(""); |
| 473 solink_tool->set_default_output_extension(".dll"); |
| 474 |
| 475 const char kLibPattern[] = |
| 476 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib"; |
| 477 SubstitutionPattern lib_output = |
| 478 SubstitutionPattern::MakeForTest(kLibPattern); |
| 479 |
| 480 const char kDllPattern[] = |
| 481 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"; |
| 482 SubstitutionPattern dll_output = |
| 483 SubstitutionPattern::MakeForTest(kDllPattern); |
| 484 |
| 485 solink_tool->set_outputs( |
| 486 SubstitutionList::MakeForTest(kLibPattern, kDllPattern)); |
| 487 |
| 488 solink_tool->set_runtime_link_output(dll_output); |
| 489 |
| 490 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); |
| 491 |
| 492 Target target(setup.settings(), Label(SourceDir("//a/"), "a")); |
| 493 target.set_output_type(Target::SHARED_LIBRARY); |
| 494 target.SetToolchain(&toolchain); |
| 495 ASSERT_TRUE(target.OnResolved(&err)); |
| 496 |
| 497 EXPECT_EQ("./a.dll.lib", target.link_output_file().value()); |
| 498 EXPECT_EQ("./a.dll.lib", target.dependency_output_file().value()); |
| 499 EXPECT_EQ("./a.dll", target.runtime_link_output_file().value()); |
460 } | 500 } |
461 | 501 |
462 // Shared libraries should be inherited across public shared liobrary | 502 // Shared libraries should be inherited across public shared liobrary |
463 // boundaries. | 503 // boundaries. |
464 TEST(Target, SharedInheritance) { | 504 TEST(Target, SharedInheritance) { |
465 TestWithScope setup; | 505 TestWithScope setup; |
466 Err err; | 506 Err err; |
467 | 507 |
468 // Create two leaf shared libraries. | 508 // Create two leaf shared libraries. |
469 TestTarget pub(setup, "//foo:pub", Target::SHARED_LIBRARY); | 509 TestTarget pub(setup, "//foo:pub", Target::SHARED_LIBRARY); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 d.private_deps().push_back(LabelTargetPair(&exe)); | 756 d.private_deps().push_back(LabelTargetPair(&exe)); |
717 d.assert_no_deps().push_back(disallow_a); | 757 d.assert_no_deps().push_back(disallow_a); |
718 ASSERT_TRUE(d.OnResolved(&err)); | 758 ASSERT_TRUE(d.OnResolved(&err)); |
719 | 759 |
720 // A2 disallows depending on anything in its own directory, but the | 760 // A2 disallows depending on anything in its own directory, but the |
721 // assertions should not match the target itself so this should be OK. | 761 // assertions should not match the target itself so this should be OK. |
722 TestTarget a2(setup, "//a:a2", Target::EXECUTABLE); | 762 TestTarget a2(setup, "//a:a2", Target::EXECUTABLE); |
723 a2.assert_no_deps().push_back(disallow_a); | 763 a2.assert_no_deps().push_back(disallow_a); |
724 ASSERT_TRUE(a2.OnResolved(&err)); | 764 ASSERT_TRUE(a2.OnResolved(&err)); |
725 } | 765 } |
OLD | NEW |