| 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 "tools/gn/ninja_binary_target_writer.h" | 5 #include "tools/gn/ninja_binary_target_writer.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 "defines =\n" | 103 "defines =\n" |
| 104 "include_dirs =\n" | 104 "include_dirs =\n" |
| 105 "root_out_dir = .\n" | 105 "root_out_dir = .\n" |
| 106 "target_out_dir = obj/foo\n" | 106 "target_out_dir = obj/foo\n" |
| 107 "target_output_name = libstlib\n" | 107 "target_output_name = libstlib\n" |
| 108 "\n" | 108 "\n" |
| 109 "\n" | 109 "\n" |
| 110 // There are no sources so there are no params to alink. (In practice | 110 // There are no sources so there are no params to alink. (In practice |
| 111 // this will probably fail in the archive tool.) | 111 // this will probably fail in the archive tool.) |
| 112 "build obj/foo/libstlib.a: alink || obj/foo/bar.stamp\n" | 112 "build obj/foo/libstlib.a: alink || obj/foo/bar.stamp\n" |
| 113 " ldflags =\n" | |
| 114 " libs =\n" | |
| 115 " output_extension = \n"; | 113 " output_extension = \n"; |
| 116 std::string out_str = out.str(); | 114 std::string out_str = out.str(); |
| 117 EXPECT_EQ(expected, out_str); | 115 EXPECT_EQ(expected, out_str); |
| 118 } | 116 } |
| 119 | 117 |
| 120 // Make the static library 'complete', which means it should be linked. | 118 // Make the static library 'complete', which means it should be linked. |
| 121 stlib_target.set_complete_static_lib(true); | 119 stlib_target.set_complete_static_lib(true); |
| 122 { | 120 { |
| 123 std::ostringstream out; | 121 std::ostringstream out; |
| 124 NinjaBinaryTargetWriter writer(&stlib_target, out); | 122 NinjaBinaryTargetWriter writer(&stlib_target, out); |
| 125 writer.Run(); | 123 writer.Run(); |
| 126 | 124 |
| 127 const char expected[] = | 125 const char expected[] = |
| 128 "defines =\n" | 126 "defines =\n" |
| 129 "include_dirs =\n" | 127 "include_dirs =\n" |
| 130 "root_out_dir = .\n" | 128 "root_out_dir = .\n" |
| 131 "target_out_dir = obj/foo\n" | 129 "target_out_dir = obj/foo\n" |
| 132 "target_output_name = libstlib\n" | 130 "target_output_name = libstlib\n" |
| 133 "\n" | 131 "\n" |
| 134 "\n" | 132 "\n" |
| 135 // Ordering of the obj files here should come out in the order | 133 // Ordering of the obj files here should come out in the order |
| 136 // specified, with the target's first, followed by the source set's, in | 134 // specified, with the target's first, followed by the source set's, in |
| 137 // order. | 135 // order. |
| 138 "build obj/foo/libstlib.a: alink obj/foo/bar.input1.o " | 136 "build obj/foo/libstlib.a: alink obj/foo/bar.input1.o " |
| 139 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj " | 137 "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj " |
| 140 "|| obj/foo/bar.stamp\n" | 138 "|| obj/foo/bar.stamp\n" |
| 141 " ldflags =\n" | |
| 142 " libs =\n" | |
| 143 " output_extension = \n"; | 139 " output_extension = \n"; |
| 144 std::string out_str = out.str(); | 140 std::string out_str = out.str(); |
| 145 EXPECT_EQ(expected, out_str); | 141 EXPECT_EQ(expected, out_str); |
| 146 } | 142 } |
| 147 } | 143 } |
| 148 | 144 |
| 149 // This tests that output extension overrides apply, and input dependencies | 145 // This tests that output extension overrides apply, and input dependencies |
| 150 // are applied. | 146 // are applied. |
| 151 TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) { | 147 TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) { |
| 152 TestWithScope setup; | 148 TestWithScope setup; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 726 |
| 731 EXPECT_FALSE(scheduler.is_failed()); | 727 EXPECT_FALSE(scheduler.is_failed()); |
| 732 | 728 |
| 733 std::ostringstream out; | 729 std::ostringstream out; |
| 734 NinjaBinaryTargetWriter writer(&target, out); | 730 NinjaBinaryTargetWriter writer(&target, out); |
| 735 writer.Run(); | 731 writer.Run(); |
| 736 | 732 |
| 737 // Should have issued an error. | 733 // Should have issued an error. |
| 738 EXPECT_TRUE(scheduler.is_failed()); | 734 EXPECT_TRUE(scheduler.is_failed()); |
| 739 } | 735 } |
| OLD | NEW |