Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: tools/gn/target_unittest.cc

Issue 2178173002: Allow GN toolchains to specify runtime deps outputs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/tool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); 556 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
557 557
558 Target target(setup.settings(), Label(SourceDir("//a/"), "a")); 558 Target target(setup.settings(), Label(SourceDir("//a/"), "a"));
559 target.set_output_type(Target::SHARED_LIBRARY); 559 target.set_output_type(Target::SHARED_LIBRARY);
560 target.SetToolchain(&toolchain); 560 target.SetToolchain(&toolchain);
561 ASSERT_TRUE(target.OnResolved(&err)); 561 ASSERT_TRUE(target.OnResolved(&err));
562 562
563 EXPECT_EQ("./liba.so", target.link_output_file().value()); 563 EXPECT_EQ("./liba.so", target.link_output_file().value());
564 EXPECT_EQ("./liba.so.TOC", target.dependency_output_file().value()); 564 EXPECT_EQ("./liba.so.TOC", target.dependency_output_file().value());
565 EXPECT_EQ("./liba.so", target.runtime_link_output_file().value()); 565
566 ASSERT_EQ(1u, target.runtime_outputs().size());
567 EXPECT_EQ("./liba.so", target.runtime_outputs()[0].value());
566 } 568 }
567 569
568 // Tests that runtime_link output works without an explicit link_output for 570 // Tests that runtime_outputs works without an explicit link_output for
569 // solink tools. 571 // solink tools.
570 TEST(Target, RuntimeLinkOuput) { 572 TEST(Target, RuntimeOuputs) {
571 TestWithScope setup; 573 TestWithScope setup;
572 Err err; 574 Err err;
573 575
574 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc")); 576 Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc"));
575 577
576 std::unique_ptr<Tool> solink_tool(new Tool()); 578 std::unique_ptr<Tool> solink_tool(new Tool());
577 solink_tool->set_output_prefix(""); 579 solink_tool->set_output_prefix("");
578 solink_tool->set_default_output_extension(".dll"); 580 solink_tool->set_default_output_extension(".dll");
579 581
582 // Say the linker makes a DLL< an import library, and a symbol file we want
583 // to treat as a runtime output.
580 const char kLibPattern[] = 584 const char kLibPattern[] =
581 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib"; 585 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}.lib";
582 SubstitutionPattern lib_output =
583 SubstitutionPattern::MakeForTest(kLibPattern);
584
585 const char kDllPattern[] = 586 const char kDllPattern[] =
586 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"; 587 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}";
587 SubstitutionPattern dll_output = 588 const char kPdbPattern[] =
588 SubstitutionPattern::MakeForTest(kDllPattern); 589 "{{root_out_dir}}/{{target_output_name}}.pdb";
590 SubstitutionPattern pdb_pattern =
591 SubstitutionPattern::MakeForTest(kPdbPattern);
589 592
590 solink_tool->set_outputs( 593 solink_tool->set_outputs(
591 SubstitutionList::MakeForTest(kLibPattern, kDllPattern)); 594 SubstitutionList::MakeForTest(kLibPattern, kDllPattern, kPdbPattern));
592 595
593 solink_tool->set_runtime_link_output(dll_output); 596 // Say we only want the DLL and symbol file treaded as runtime outputs.
597 solink_tool->set_runtime_outputs(SubstitutionList::MakeForTest(
598 kDllPattern, kPdbPattern));
594 599
595 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); 600 toolchain.SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
596 601
597 Target target(setup.settings(), Label(SourceDir("//a/"), "a")); 602 Target target(setup.settings(), Label(SourceDir("//a/"), "a"));
598 target.set_output_type(Target::SHARED_LIBRARY); 603 target.set_output_type(Target::SHARED_LIBRARY);
599 target.SetToolchain(&toolchain); 604 target.SetToolchain(&toolchain);
600 ASSERT_TRUE(target.OnResolved(&err)); 605 ASSERT_TRUE(target.OnResolved(&err));
601 606
602 EXPECT_EQ("./a.dll.lib", target.link_output_file().value()); 607 EXPECT_EQ("./a.dll.lib", target.link_output_file().value());
603 EXPECT_EQ("./a.dll.lib", target.dependency_output_file().value()); 608 EXPECT_EQ("./a.dll.lib", target.dependency_output_file().value());
604 EXPECT_EQ("./a.dll", target.runtime_link_output_file().value()); 609
610 ASSERT_EQ(2u, target.runtime_outputs().size());
611 EXPECT_EQ("./a.dll", target.runtime_outputs()[0].value());
612 EXPECT_EQ("./a.pdb", target.runtime_outputs()[1].value());
605 } 613 }
606 614
607 // Shared libraries should be inherited across public shared liobrary 615 // Shared libraries should be inherited across public shared liobrary
608 // boundaries. 616 // boundaries.
609 TEST(Target, SharedInheritance) { 617 TEST(Target, SharedInheritance) {
610 TestWithScope setup; 618 TestWithScope setup;
611 Err err; 619 Err err;
612 620
613 // Create two leaf shared libraries. 621 // Create two leaf shared libraries.
614 TestTarget pub(setup, "//foo:pub", Target::SHARED_LIBRARY); 622 TestTarget pub(setup, "//foo:pub", Target::SHARED_LIBRARY);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); 987 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u);
980 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); 988 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u);
981 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u); 989 ASSERT_EQ(c.bundle_data().bundle_deps().size(), 1u);
982 990
983 // E does not have any bundle_data information but gets a list of 991 // E does not have any bundle_data information but gets a list of
984 // bundle_deps to propagate them during target resolution. 992 // bundle_deps to propagate them during target resolution.
985 ASSERT_TRUE(e.bundle_data().file_rules().empty()); 993 ASSERT_TRUE(e.bundle_data().file_rules().empty());
986 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty()); 994 ASSERT_TRUE(e.bundle_data().assets_catalog_sources().empty());
987 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u); 995 ASSERT_EQ(e.bundle_data().bundle_deps().size(), 2u);
988 } 996 }
OLDNEW
« no previous file with comments | « tools/gn/target.cc ('k') | tools/gn/tool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698