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 <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 Loading... |
118 "\n" | 118 "\n" |
119 // There are no sources so there are no params to alink. (In practice | 119 // There are no sources so there are no params to alink. (In practice |
120 // this will probably fail in the archive tool.) | 120 // this will probably fail in the archive tool.) |
121 "build obj/foo/libstlib.a: alink\n" | 121 "build obj/foo/libstlib.a: alink\n" |
122 " ldflags =\n" | 122 " ldflags =\n" |
123 " libs =\n" | 123 " libs =\n" |
124 " output_extension = \n"; | 124 " output_extension = \n"; |
125 std::string out_str = out.str(); | 125 std::string out_str = out.str(); |
126 EXPECT_EQ(expected, out_str); | 126 EXPECT_EQ(expected, out_str); |
127 } | 127 } |
| 128 |
| 129 // Make the static library 'complete', which means it should be linked. |
| 130 stlib_target.set_complete_static_lib(true); |
| 131 { |
| 132 std::ostringstream out; |
| 133 NinjaBinaryTargetWriter writer(&stlib_target, out); |
| 134 writer.Run(); |
| 135 |
| 136 const char expected[] = |
| 137 "defines =\n" |
| 138 "include_dirs =\n" |
| 139 "cflags =\n" |
| 140 "cflags_c =\n" |
| 141 "cflags_cc =\n" |
| 142 "cflags_objc =\n" |
| 143 "cflags_objcc =\n" |
| 144 "root_out_dir = .\n" |
| 145 "target_out_dir = obj/foo\n" |
| 146 "target_output_name = libstlib\n" |
| 147 "\n" |
| 148 "\n" |
| 149 // Ordering of the obj files here should come out in the order |
| 150 // specified, with the target's first, followed by the source set's, in |
| 151 // order. |
| 152 "build obj/foo/libstlib.a: alink obj/foo/bar.input1.o " |
| 153 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n" |
| 154 " ldflags =\n" |
| 155 " libs =\n" |
| 156 " output_extension = \n"; |
| 157 std::string out_str = out.str(); |
| 158 EXPECT_EQ(expected, out_str); |
| 159 } |
128 } | 160 } |
129 | 161 |
130 // This tests that output extension overrides apply, and input dependencies | 162 // This tests that output extension overrides apply, and input dependencies |
131 // are applied. | 163 // are applied. |
132 TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) { | 164 TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) { |
133 TestWithScope setup; | 165 TestWithScope setup; |
134 Err err; | 166 Err err; |
135 | 167 |
136 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); | 168 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
137 setup.settings()->set_target_os(Settings::LINUX); | 169 setup.settings()->set_target_os(Settings::LINUX); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 "\n" | 258 "\n" |
227 "build ./libshlib.so: solink obj/foo/libshlib.input1.o " | 259 "build ./libshlib.so: solink obj/foo/libshlib.input1.o " |
228 "obj/foo/libshlib.input2.o\n" | 260 "obj/foo/libshlib.input2.o\n" |
229 " ldflags =\n" | 261 " ldflags =\n" |
230 " libs =\n" | 262 " libs =\n" |
231 " output_extension = .so\n"; | 263 " output_extension = .so\n"; |
232 | 264 |
233 std::string out_str = out.str(); | 265 std::string out_str = out.str(); |
234 EXPECT_EQ(expected, out_str); | 266 EXPECT_EQ(expected, out_str); |
235 } | 267 } |
OLD | NEW |