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

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

Issue 505353002: Reduce input dependencies in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_target_writer.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 <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/target.h" 9 #include "tools/gn/target.h"
10 #include "tools/gn/test_with_scope.h" 10 #include "tools/gn/test_with_scope.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // this will probably fail in the archive tool.) 118 // this will probably fail in the archive tool.)
119 "build obj/foo/libstlib.a: alink\n" 119 "build obj/foo/libstlib.a: alink\n"
120 " ldflags =\n" 120 " ldflags =\n"
121 " libs =\n" 121 " libs =\n"
122 " output_extension = \n"; 122 " output_extension = \n";
123 std::string out_str = out.str(); 123 std::string out_str = out.str();
124 EXPECT_EQ(expected, out_str); 124 EXPECT_EQ(expected, out_str);
125 } 125 }
126 } 126 }
127 127
128 TEST(NinjaBinaryTargetWriter, ProductExtension) { 128 // This tests that output extension overrides apply, and input dependencies
129 // are applied.
130 TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) {
129 TestWithScope setup; 131 TestWithScope setup;
130 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 132 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
131 setup.settings()->set_target_os(Settings::LINUX); 133 setup.settings()->set_target_os(Settings::LINUX);
132 134
135 // An action for our library to depend on.
136 Target action(setup.settings(), Label(SourceDir("//foo/"), "action"));
137 action.set_output_type(Target::ACTION_FOREACH);
138 action.SetToolchain(setup.toolchain());
139 action.OnResolved();
140
133 // A shared library w/ the product_extension set to a custom value. 141 // A shared library w/ the product_extension set to a custom value.
134 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib")); 142 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
135 target.set_output_type(Target::SHARED_LIBRARY); 143 target.set_output_type(Target::SHARED_LIBRARY);
136 target.set_output_extension(std::string("so.6")); 144 target.set_output_extension(std::string("so.6"));
137 target.sources().push_back(SourceFile("//foo/input1.cc")); 145 target.sources().push_back(SourceFile("//foo/input1.cc"));
138 target.sources().push_back(SourceFile("//foo/input2.cc")); 146 target.sources().push_back(SourceFile("//foo/input2.cc"));
147 target.deps().push_back(LabelTargetPair(&action));
139 target.SetToolchain(setup.toolchain()); 148 target.SetToolchain(setup.toolchain());
140 target.OnResolved(); 149 target.OnResolved();
141 150
142 std::ostringstream out; 151 std::ostringstream out;
143 NinjaBinaryTargetWriter writer(&target, out); 152 NinjaBinaryTargetWriter writer(&target, out);
144 writer.Run(); 153 writer.Run();
145 154
146 const char expected[] = 155 const char expected[] =
147 "defines =\n" 156 "defines =\n"
148 "include_dirs =\n" 157 "include_dirs =\n"
149 "cflags =\n" 158 "cflags =\n"
150 "cflags_c =\n" 159 "cflags_c =\n"
151 "cflags_cc =\n" 160 "cflags_cc =\n"
152 "cflags_objc =\n" 161 "cflags_objc =\n"
153 "cflags_objcc =\n" 162 "cflags_objcc =\n"
154 "root_out_dir = .\n" 163 "root_out_dir = .\n"
155 "target_out_dir = obj/foo\n" 164 "target_out_dir = obj/foo\n"
156 "target_output_name = libshlib\n" 165 "target_output_name = libshlib\n"
157 "\n" 166 "\n"
158 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n" 167 "build obj/foo/shlib.inputdeps.stamp: stamp obj/foo/action.stamp\n"
159 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n" 168 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc"
169 " || obj/foo/shlib.inputdeps.stamp\n"
170 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc"
171 " || obj/foo/shlib.inputdeps.stamp\n"
160 "\n" 172 "\n"
161 "build ./libshlib.so.6: solink obj/foo/libshlib.input1.o " 173 "build ./libshlib.so.6: solink obj/foo/libshlib.input1.o "
162 "obj/foo/libshlib.input2.o\n" 174 // The order-only dependency here is stricly unnecessary since the
175 // sources list this as an order-only dep. See discussion in the code
176 // that writes this.
177 "obj/foo/libshlib.input2.o || obj/foo/action.stamp\n"
163 " ldflags =\n" 178 " ldflags =\n"
164 " libs =\n" 179 " libs =\n"
165 " output_extension = .so.6\n"; 180 " output_extension = .so.6\n";
166 181
167 std::string out_str = out.str(); 182 std::string out_str = out.str();
168 EXPECT_EQ(expected, out_str); 183 EXPECT_EQ(expected, out_str);
169 } 184 }
170 185
171 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) { 186 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) {
172 TestWithScope setup; 187 TestWithScope setup;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 "\n" 220 "\n"
206 "build ./libshlib.so: solink obj/foo/libshlib.input1.o " 221 "build ./libshlib.so: solink obj/foo/libshlib.input1.o "
207 "obj/foo/libshlib.input2.o\n" 222 "obj/foo/libshlib.input2.o\n"
208 " ldflags =\n" 223 " ldflags =\n"
209 " libs =\n" 224 " libs =\n"
210 " output_extension = .so\n"; 225 " output_extension = .so\n";
211 226
212 std::string out_str = out.str(); 227 std::string out_str = out.str();
213 EXPECT_EQ(expected, out_str); 228 EXPECT_EQ(expected, out_str);
214 } 229 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698