OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_build_writer.h" | 8 #include "tools/gn/ninja_build_writer.h" |
9 #include "tools/gn/pool.h" | 9 #include "tools/gn/pool.h" |
10 #include "tools/gn/scheduler.h" | 10 #include "tools/gn/scheduler.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 other_pool.set_depth(42); | 41 other_pool.set_depth(42); |
42 Toolchain other_toolchain(setup.settings(), other_toolchain_label); | 42 Toolchain other_toolchain(setup.settings(), other_toolchain_label); |
43 TestWithScope::SetupToolchain(&other_toolchain); | 43 TestWithScope::SetupToolchain(&other_toolchain); |
44 other_toolchain.GetTool(Toolchain::TYPE_LINK)->set_pool( | 44 other_toolchain.GetTool(Toolchain::TYPE_LINK)->set_pool( |
45 LabelPtrPair<Pool>(&other_pool)); | 45 LabelPtrPair<Pool>(&other_pool)); |
46 | 46 |
47 // Settings to go with the other toolchain. | 47 // Settings to go with the other toolchain. |
48 Settings other_settings(setup.build_settings(), "toolchain/"); | 48 Settings other_settings(setup.build_settings(), "toolchain/"); |
49 other_settings.set_toolchain_label(other_toolchain_label); | 49 other_settings.set_toolchain_label(other_toolchain_label); |
50 | 50 |
51 std::map<const Settings*, const Toolchain*> used_toolchains; | 51 std::unordered_map<const Settings*, const Toolchain*> used_toolchains; |
52 used_toolchains[setup.settings()] = setup.toolchain(); | 52 used_toolchains[setup.settings()] = setup.toolchain(); |
53 used_toolchains[&other_settings] = &other_toolchain; | 53 used_toolchains[&other_settings] = &other_toolchain; |
54 | 54 |
55 std::vector<const Target*> targets = { &target_foo, &target_bar }; | 55 std::vector<const Target*> targets = { &target_foo, &target_bar }; |
56 | 56 |
57 std::ostringstream ninja_out; | 57 std::ostringstream ninja_out; |
58 std::ostringstream depfile_out; | 58 std::ostringstream depfile_out; |
59 | 59 |
60 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, | 60 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, |
61 setup.toolchain(), targets, ninja_out, depfile_out); | 61 setup.toolchain(), targets, ninja_out, depfile_out); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 ASSERT_TRUE(target_foo.OnResolved(&err)); | 110 ASSERT_TRUE(target_foo.OnResolved(&err)); |
111 | 111 |
112 Target target_bar(setup.settings(), Label(SourceDir("//bar/"), "bar")); | 112 Target target_bar(setup.settings(), Label(SourceDir("//bar/"), "bar")); |
113 target_bar.set_output_type(Target::ACTION); | 113 target_bar.set_output_type(Target::ACTION); |
114 target_bar.action_values().set_script(SourceFile("//bar/script.py")); | 114 target_bar.action_values().set_script(SourceFile("//bar/script.py")); |
115 target_bar.action_values().outputs() = SubstitutionList::MakeForTest( | 115 target_bar.action_values().outputs() = SubstitutionList::MakeForTest( |
116 "//out/Debug/out3.out", "//out/Debug/out2.out"); | 116 "//out/Debug/out3.out", "//out/Debug/out2.out"); |
117 target_bar.SetToolchain(setup.toolchain()); | 117 target_bar.SetToolchain(setup.toolchain()); |
118 ASSERT_TRUE(target_bar.OnResolved(&err)); | 118 ASSERT_TRUE(target_bar.OnResolved(&err)); |
119 | 119 |
120 std::map<const Settings*, const Toolchain*> used_toolchains; | 120 std::unordered_map<const Settings*, const Toolchain*> used_toolchains; |
121 used_toolchains[setup.settings()] = setup.toolchain(); | 121 used_toolchains[setup.settings()] = setup.toolchain(); |
122 std::vector<const Target*> targets = { &target_foo, &target_bar }; | 122 std::vector<const Target*> targets = { &target_foo, &target_bar }; |
123 std::ostringstream ninja_out; | 123 std::ostringstream ninja_out; |
124 std::ostringstream depfile_out; | 124 std::ostringstream depfile_out; |
125 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, | 125 NinjaBuildWriter writer(setup.build_settings(), used_toolchains, |
126 setup.toolchain(), targets, ninja_out, depfile_out); | 126 setup.toolchain(), targets, ninja_out, depfile_out); |
127 ASSERT_FALSE(writer.Run(&err)); | 127 ASSERT_FALSE(writer.Run(&err)); |
128 | 128 |
129 const char expected_help_test[] = | 129 const char expected_help_test[] = |
130 "Two or more targets generate the same output:\n" | 130 "Two or more targets generate the same output:\n" |
131 " out2.out\n" | 131 " out2.out\n" |
132 "\n" | 132 "\n" |
133 "This is can often be fixed by changing one of the target names, or by \n" | 133 "This is can often be fixed by changing one of the target names, or by \n" |
134 "setting an output_name on one of them.\n" | 134 "setting an output_name on one of them.\n" |
135 "\n" | 135 "\n" |
136 "Collisions:\n" | 136 "Collisions:\n" |
137 " //foo:bar\n" | 137 " //foo:bar\n" |
138 " //bar:bar\n"; | 138 " //bar:bar\n"; |
139 | 139 |
140 EXPECT_EQ(expected_help_test, err.help_text()); | 140 EXPECT_EQ(expected_help_test, err.help_text()); |
141 } | 141 } |
OLD | NEW |