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/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 " soname = shlib.dll\n" | 87 " soname = shlib.dll\n" |
88 " lib = shlib.dll\n" | 88 " lib = shlib.dll\n" |
89 " dll = shlib.dll\n" | 89 " dll = shlib.dll\n" |
90 " implibflag = /IMPLIB:shlib.dll.lib\n\n"; | 90 " implibflag = /IMPLIB:shlib.dll.lib\n\n"; |
91 std::string out_str = out.str(); | 91 std::string out_str = out.str(); |
92 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
93 std::replace(out_str.begin(), out_str.end(), '\\', '/'); | 93 std::replace(out_str.begin(), out_str.end(), '\\', '/'); |
94 #endif | 94 #endif |
95 EXPECT_EQ(expected_win, out_str); | 95 EXPECT_EQ(expected_win, out_str); |
96 } | 96 } |
| 97 |
| 98 // A static library that depends on the source set (should not link it). |
| 99 Target stlib_target(setup.settings(), Label(SourceDir("//foo/"), "stlib")); |
| 100 stlib_target.set_output_type(Target::STATIC_LIBRARY); |
| 101 stlib_target.deps().push_back(LabelTargetPair(&target)); |
| 102 stlib_target.OnResolved(); |
| 103 |
| 104 { |
| 105 std::ostringstream out; |
| 106 NinjaBinaryTargetWriter writer(&stlib_target, setup.toolchain(), out); |
| 107 writer.Run(); |
| 108 |
| 109 // TODO(brettw) I think we'll need to worry about backslashes here |
| 110 // depending if we're on actual Windows or Linux pretending to be Windows. |
| 111 const char expected_win[] = |
| 112 "defines =\n" |
| 113 "includes =\n" |
| 114 "cflags =\n" |
| 115 "cflags_c =\n" |
| 116 "cflags_cc =\n" |
| 117 "cflags_objc =\n" |
| 118 "cflags_objcc =\n" |
| 119 "\n" |
| 120 "\n" |
| 121 "manifests = obj/foo/stlib.intermediate.manifest\n" |
| 122 "ldflags = /MANIFEST /ManifestFile:obj/foo/stlib.intermediate.manifest\n
" |
| 123 "libs =\n" |
| 124 // There are no sources so there are no params to alink. |
| 125 "build obj/foo/stlib.lib: alink\n\n"; |
| 126 std::string out_str = out.str(); |
| 127 #if defined(OS_WIN) |
| 128 std::replace(out_str.begin(), out_str.end(), '\\', '/'); |
| 129 #endif |
| 130 EXPECT_EQ(expected_win, out_str); |
| 131 } |
| 132 |
97 } | 133 } |
98 | 134 |
99 TEST(NinjaBinaryTargetWriter, ProductExtension) { | 135 TEST(NinjaBinaryTargetWriter, ProductExtension) { |
100 TestWithScope setup; | 136 TestWithScope setup; |
101 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); | 137 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
102 setup.settings()->set_target_os(Settings::LINUX); | 138 setup.settings()->set_target_os(Settings::LINUX); |
103 | 139 |
104 // A shared library w/ the product_extension set to a custom value. | 140 // A shared library w/ the product_extension set to a custom value. |
105 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib")); | 141 Target target(setup.settings(), Label(SourceDir("//foo/"), "shlib")); |
106 target.set_output_type(Target::SHARED_LIBRARY); | 142 target.set_output_type(Target::SHARED_LIBRARY); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 " soname = libshlib.so\n" | 216 " soname = libshlib.so\n" |
181 " lib = lib/libshlib.so\n" | 217 " lib = lib/libshlib.so\n" |
182 "\n"; | 218 "\n"; |
183 | 219 |
184 std::string out_str = out.str(); | 220 std::string out_str = out.str(); |
185 #if defined(OS_WIN) | 221 #if defined(OS_WIN) |
186 std::replace(out_str.begin(), out_str.end(), '\\', '/'); | 222 std::replace(out_str.begin(), out_str.end(), '\\', '/'); |
187 #endif | 223 #endif |
188 EXPECT_EQ(expected, out_str); | 224 EXPECT_EQ(expected, out_str); |
189 } | 225 } |
OLD | NEW |