| 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 21 matching lines...) Expand all Loading... |
| 32 writer.Run(); | 32 writer.Run(); |
| 33 | 33 |
| 34 const char expected[] = | 34 const char expected[] = |
| 35 "defines =\n" | 35 "defines =\n" |
| 36 "include_dirs =\n" | 36 "include_dirs =\n" |
| 37 "cflags =\n" | 37 "cflags =\n" |
| 38 "cflags_c =\n" | 38 "cflags_c =\n" |
| 39 "cflags_cc =\n" | 39 "cflags_cc =\n" |
| 40 "cflags_objc =\n" | 40 "cflags_objc =\n" |
| 41 "cflags_objcc =\n" | 41 "cflags_objcc =\n" |
| 42 "root_out_dir = \n" | 42 "root_out_dir = .\n" |
| 43 "target_out_dir = obj/foo\n" | 43 "target_out_dir = obj/foo\n" |
| 44 "target_output_name = bar\n" | 44 "target_output_name = bar\n" |
| 45 "\n" | 45 "\n" |
| 46 "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc\n" | 46 "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc\n" |
| 47 "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc\n" | 47 "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc\n" |
| 48 "\n" | 48 "\n" |
| 49 "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o " | 49 "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o " |
| 50 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n"; | 50 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n"; |
| 51 std::string out_str = out.str(); | 51 std::string out_str = out.str(); |
| 52 EXPECT_EQ(expected, out_str); | 52 EXPECT_EQ(expected, out_str); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 65 writer.Run(); | 65 writer.Run(); |
| 66 | 66 |
| 67 const char expected[] = | 67 const char expected[] = |
| 68 "defines =\n" | 68 "defines =\n" |
| 69 "include_dirs =\n" | 69 "include_dirs =\n" |
| 70 "cflags =\n" | 70 "cflags =\n" |
| 71 "cflags_c =\n" | 71 "cflags_c =\n" |
| 72 "cflags_cc =\n" | 72 "cflags_cc =\n" |
| 73 "cflags_objc =\n" | 73 "cflags_objc =\n" |
| 74 "cflags_objcc =\n" | 74 "cflags_objcc =\n" |
| 75 "root_out_dir = \n" | 75 "root_out_dir = .\n" |
| 76 "target_out_dir = obj/foo\n" | 76 "target_out_dir = obj/foo\n" |
| 77 "target_output_name = libshlib\n" | 77 "target_output_name = libshlib\n" |
| 78 "\n" | 78 "\n" |
| 79 "\n" | 79 "\n" |
| 80 // Ordering of the obj files here should come out in the order | 80 // Ordering of the obj files here should come out in the order |
| 81 // specified, with the target's first, followed by the source set's, in | 81 // specified, with the target's first, followed by the source set's, in |
| 82 // order. | 82 // order. |
| 83 "build libshlib.so: solink obj/foo/bar.input1.o " | 83 "build ./libshlib.so: solink obj/foo/bar.input1.o " |
| 84 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n" | 84 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n" |
| 85 " ldflags =\n" | 85 " ldflags =\n" |
| 86 " libs =\n" | 86 " libs =\n" |
| 87 " output_extension = .so\n"; | 87 " output_extension = .so\n"; |
| 88 std::string out_str = out.str(); | 88 std::string out_str = out.str(); |
| 89 EXPECT_EQ(expected, out_str); | 89 EXPECT_EQ(expected, out_str); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // A static library that depends on the source set (should not link it). | 92 // A static library that depends on the source set (should not link it). |
| 93 Target stlib_target(setup.settings(), Label(SourceDir("//foo/"), "stlib")); | 93 Target stlib_target(setup.settings(), Label(SourceDir("//foo/"), "stlib")); |
| 94 stlib_target.set_output_type(Target::STATIC_LIBRARY); | 94 stlib_target.set_output_type(Target::STATIC_LIBRARY); |
| 95 stlib_target.deps().push_back(LabelTargetPair(&target)); | 95 stlib_target.deps().push_back(LabelTargetPair(&target)); |
| 96 stlib_target.SetToolchain(setup.toolchain()); | 96 stlib_target.SetToolchain(setup.toolchain()); |
| 97 stlib_target.OnResolved(); | 97 stlib_target.OnResolved(); |
| 98 | 98 |
| 99 { | 99 { |
| 100 std::ostringstream out; | 100 std::ostringstream out; |
| 101 NinjaBinaryTargetWriter writer(&stlib_target, out); | 101 NinjaBinaryTargetWriter writer(&stlib_target, out); |
| 102 writer.Run(); | 102 writer.Run(); |
| 103 | 103 |
| 104 const char expected[] = | 104 const char expected[] = |
| 105 "defines =\n" | 105 "defines =\n" |
| 106 "include_dirs =\n" | 106 "include_dirs =\n" |
| 107 "cflags =\n" | 107 "cflags =\n" |
| 108 "cflags_c =\n" | 108 "cflags_c =\n" |
| 109 "cflags_cc =\n" | 109 "cflags_cc =\n" |
| 110 "cflags_objc =\n" | 110 "cflags_objc =\n" |
| 111 "cflags_objcc =\n" | 111 "cflags_objcc =\n" |
| 112 "root_out_dir = \n" | 112 "root_out_dir = .\n" |
| 113 "target_out_dir = obj/foo\n" | 113 "target_out_dir = obj/foo\n" |
| 114 "target_output_name = libstlib\n" | 114 "target_output_name = libstlib\n" |
| 115 "\n" | 115 "\n" |
| 116 "\n" | 116 "\n" |
| 117 // There are no sources so there are no params to alink. (In practice | 117 // There are no sources so there are no params to alink. (In practice |
| 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"; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 144 writer.Run(); | 144 writer.Run(); |
| 145 | 145 |
| 146 const char expected[] = | 146 const char expected[] = |
| 147 "defines =\n" | 147 "defines =\n" |
| 148 "include_dirs =\n" | 148 "include_dirs =\n" |
| 149 "cflags =\n" | 149 "cflags =\n" |
| 150 "cflags_c =\n" | 150 "cflags_c =\n" |
| 151 "cflags_cc =\n" | 151 "cflags_cc =\n" |
| 152 "cflags_objc =\n" | 152 "cflags_objc =\n" |
| 153 "cflags_objcc =\n" | 153 "cflags_objcc =\n" |
| 154 "root_out_dir = \n" | 154 "root_out_dir = .\n" |
| 155 "target_out_dir = obj/foo\n" | 155 "target_out_dir = obj/foo\n" |
| 156 "target_output_name = libshlib\n" | 156 "target_output_name = libshlib\n" |
| 157 "\n" | 157 "\n" |
| 158 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n" | 158 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n" |
| 159 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n" | 159 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n" |
| 160 "\n" | 160 "\n" |
| 161 "build libshlib.so.6: solink obj/foo/libshlib.input1.o " | 161 "build ./libshlib.so.6: solink obj/foo/libshlib.input1.o " |
| 162 "obj/foo/libshlib.input2.o\n" | 162 "obj/foo/libshlib.input2.o\n" |
| 163 " ldflags =\n" | 163 " ldflags =\n" |
| 164 " libs =\n" | 164 " libs =\n" |
| 165 " output_extension = .so.6\n"; | 165 " output_extension = .so.6\n"; |
| 166 | 166 |
| 167 std::string out_str = out.str(); | 167 std::string out_str = out.str(); |
| 168 EXPECT_EQ(expected, out_str); | 168 EXPECT_EQ(expected, out_str); |
| 169 } | 169 } |
| 170 | 170 |
| 171 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) { | 171 TEST(NinjaBinaryTargetWriter, EmptyProductExtension) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 189 writer.Run(); | 189 writer.Run(); |
| 190 | 190 |
| 191 const char expected[] = | 191 const char expected[] = |
| 192 "defines =\n" | 192 "defines =\n" |
| 193 "include_dirs =\n" | 193 "include_dirs =\n" |
| 194 "cflags =\n" | 194 "cflags =\n" |
| 195 "cflags_c =\n" | 195 "cflags_c =\n" |
| 196 "cflags_cc =\n" | 196 "cflags_cc =\n" |
| 197 "cflags_objc =\n" | 197 "cflags_objc =\n" |
| 198 "cflags_objcc =\n" | 198 "cflags_objcc =\n" |
| 199 "root_out_dir = \n" | 199 "root_out_dir = .\n" |
| 200 "target_out_dir = obj/foo\n" | 200 "target_out_dir = obj/foo\n" |
| 201 "target_output_name = libshlib\n" | 201 "target_output_name = libshlib\n" |
| 202 "\n" | 202 "\n" |
| 203 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n" | 203 "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n" |
| 204 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n" | 204 "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n" |
| 205 "\n" | 205 "\n" |
| 206 "build libshlib.so: solink obj/foo/libshlib.input1.o " | 206 "build ./libshlib.so: solink obj/foo/libshlib.input1.o " |
| 207 "obj/foo/libshlib.input2.o\n" | 207 "obj/foo/libshlib.input2.o\n" |
| 208 " ldflags =\n" | 208 " ldflags =\n" |
| 209 " libs =\n" | 209 " libs =\n" |
| 210 " output_extension = .so\n"; | 210 " output_extension = .so\n"; |
| 211 | 211 |
| 212 std::string out_str = out.str(); | 212 std::string out_str = out.str(); |
| 213 EXPECT_EQ(expected, out_str); | 213 EXPECT_EQ(expected, out_str); |
| 214 } | 214 } |
| OLD | NEW |