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

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

Issue 1530183005: Special-case paths that appear in libs by not prefixing them with -l. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in previous patch Created 4 years, 12 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/target.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/scheduler.h" 9 #include "tools/gn/scheduler.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // that writes this. 194 // that writes this.
195 "obj/foo/libshlib.input2.o || obj/foo/action.stamp\n" 195 "obj/foo/libshlib.input2.o || obj/foo/action.stamp\n"
196 " ldflags =\n" 196 " ldflags =\n"
197 " libs =\n" 197 " libs =\n"
198 " output_extension = .so.6\n"; 198 " output_extension = .so.6\n";
199 199
200 std::string out_str = out.str(); 200 std::string out_str = out.str();
201 EXPECT_EQ(expected, out_str); 201 EXPECT_EQ(expected, out_str);
202 } 202 }
203 203
204 // Tests libs are applied.
205 TEST(NinjaBinaryTargetWriter, LibsAndLibDirs) {
206 TestWithScope setup;
207 Err err;
208
209 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
210
211 // A shared library w/ libs and lib_dirs.
212 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
213 target.set_output_type(Target::SHARED_LIBRARY);
214 target.config_values().libs().push_back(LibFile(SourceFile("//foo/lib1.a")));
215 target.config_values().libs().push_back(LibFile("foo"));
216 target.config_values().lib_dirs().push_back(SourceDir("//foo/bar/"));
217 target.SetToolchain(setup.toolchain());
218 ASSERT_TRUE(target.OnResolved(&err));
219
220 std::ostringstream out;
221 NinjaBinaryTargetWriter writer(&target, out);
222 writer.Run();
223
224 const char expected[] =
225 "defines =\n"
226 "include_dirs =\n"
227 "root_out_dir = .\n"
228 "target_out_dir = obj/foo\n"
229 "target_output_name = libshlib\n"
230 "\n"
231 "\n"
232 "build ./libshlib.so: solink | ../../foo/lib1.a\n"
233 " ldflags = -L../../foo/bar\n"
234 " libs = ../../foo/lib1.a -lfoo\n"
235 " output_extension = .so\n";
236
237 std::string out_str = out.str();
238 EXPECT_EQ(expected, out_str);
239 }
240
204 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) { 241 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) {
205 TestWithScope setup; 242 TestWithScope setup;
206 Err err; 243 Err err;
207 244
208 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 245 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
209 246
210 // This test is the same as ProductExtension, except that 247 // This test is the same as ProductExtension, except that
211 // we call set_output_extension("") and ensure that we still get the default. 248 // we call set_output_extension("") and ensure that we still get the default.
212 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib")); 249 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
213 target.set_output_type(Target::SHARED_LIBRARY); 250 target.set_output_type(Target::SHARED_LIBRARY);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 728
692 EXPECT_FALSE(scheduler.is_failed()); 729 EXPECT_FALSE(scheduler.is_failed());
693 730
694 std::ostringstream out; 731 std::ostringstream out;
695 NinjaBinaryTargetWriter writer(&target, out); 732 NinjaBinaryTargetWriter writer(&target, out);
696 writer.Run(); 733 writer.Run();
697 734
698 // Should have issued an error. 735 // Should have issued an error.
699 EXPECT_TRUE(scheduler.is_failed()); 736 EXPECT_TRUE(scheduler.is_failed());
700 } 737 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698