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 <algorithm> | 5 #include <algorithm> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/gn/file_template.h" | 9 #include "tools/gn/file_template.h" |
10 #include "tools/gn/ninja_action_target_writer.h" | 10 #include "tools/gn/ninja_action_target_writer.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 setup.settings()->set_target_os(Settings::WIN); | 141 setup.settings()->set_target_os(Settings::WIN); |
142 | 142 |
143 std::ostringstream out; | 143 std::ostringstream out; |
144 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); | 144 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); |
145 writer.Run(); | 145 writer.Run(); |
146 | 146 |
147 // TODO(brettw) I think we'll need to worry about backslashes here | 147 // TODO(brettw) I think we'll need to worry about backslashes here |
148 // depending if we're on actual Windows or Linux pretending to be Windows. | 148 // depending if we're on actual Windows or Linux pretending to be Windows. |
149 const char expected_win[] = | 149 const char expected_win[] = |
150 "rule __foo_bar___rule\n" | 150 "rule __foo_bar___rule\n" |
151 " command = C:/python/python.exe gyp-win-tool action-wrapper environmen
t.x86 __foo_bar___rule.$unique_name.rsp\n" | 151 " command = C$:/python/python.exe gyp-win-tool action-wrapper environme
nt.x86 __foo_bar___rule.$unique_name.rsp\n" |
152 " description = ACTION //foo:bar()\n" | 152 " description = ACTION //foo:bar()\n" |
153 " restat = 1\n" | 153 " restat = 1\n" |
154 " rspfile = __foo_bar___rule.$unique_name.rsp\n" | 154 " rspfile = __foo_bar___rule.$unique_name.rsp\n" |
155 " rspfile_content = C:/python/python.exe ../../foo/script.py\n" | 155 " rspfile_content = C$:/python/python.exe ../../foo/script.py\n" |
156 "\n" | 156 "\n" |
157 "build foo.out: __foo_bar___rule | ../../foo/included.txt ../../foo/sour
ce.txt\n" | 157 "build foo.out: __foo_bar___rule | ../../foo/included.txt ../../foo/sour
ce.txt\n" |
158 "\n" | 158 "\n" |
159 "build obj/foo/bar.stamp: stamp foo.out\n"; | 159 "build obj/foo/bar.stamp: stamp foo.out\n"; |
160 std::string out_str = out.str(); | 160 std::string out_str = out.str(); |
161 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
162 std::replace(out_str.begin(), out_str.end(), '\\', '/'); | 162 std::replace(out_str.begin(), out_str.end(), '\\', '/'); |
163 #endif | 163 #endif |
164 EXPECT_EQ(expected_win, out_str); | 164 EXPECT_EQ(expected_win, out_str); |
165 } | 165 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 setup.settings()->set_target_os(Settings::WIN); | 230 setup.settings()->set_target_os(Settings::WIN); |
231 | 231 |
232 std::ostringstream out; | 232 std::ostringstream out; |
233 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); | 233 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); |
234 writer.Run(); | 234 writer.Run(); |
235 | 235 |
236 // TODO(brettw) I think we'll need to worry about backslashes here | 236 // TODO(brettw) I think we'll need to worry about backslashes here |
237 // depending if we're on actual Windows or Linux pretending to be Windows. | 237 // depending if we're on actual Windows or Linux pretending to be Windows. |
238 const char expected_win[] = | 238 const char expected_win[] = |
239 "rule __foo_bar___rule\n" | 239 "rule __foo_bar___rule\n" |
240 " command = C:/python/python.exe gyp-win-tool action-wrapper " | 240 " command = C$:/python/python.exe gyp-win-tool action-wrapper " |
241 "environment.x86 __foo_bar___rule.$unique_name.rsp\n" | 241 "environment.x86 __foo_bar___rule.$unique_name.rsp\n" |
242 " description = ACTION //foo:bar()\n" | 242 " description = ACTION //foo:bar()\n" |
243 " restat = 1\n" | 243 " restat = 1\n" |
244 " rspfile = __foo_bar___rule.$unique_name.rsp\n" | 244 " rspfile = __foo_bar___rule.$unique_name.rsp\n" |
245 " rspfile_content = C:/python/python.exe ../../foo/script.py -i " | 245 " rspfile_content = C$:/python/python.exe ../../foo/script.py -i " |
246 "${source} \"--out=foo$ bar${source_name_part}.o\"\n" | 246 "${source} \"--out=foo$ bar${source_name_part}.o\"\n" |
247 "\n" | 247 "\n" |
248 "build input1.out: __foo_bar___rule ../../foo/input1.txt | " | 248 "build input1.out: __foo_bar___rule ../../foo/input1.txt | " |
249 "../../foo/included.txt\n" | 249 "../../foo/included.txt\n" |
250 " unique_name = 0\n" | 250 " unique_name = 0\n" |
251 " source = ../../foo/input1.txt\n" | 251 " source = ../../foo/input1.txt\n" |
252 " source_name_part = input1\n" | 252 " source_name_part = input1\n" |
253 "build input2.out: __foo_bar___rule ../../foo/input2.txt | " | 253 "build input2.out: __foo_bar___rule ../../foo/input2.txt | " |
254 "../../foo/included.txt\n" | 254 "../../foo/included.txt\n" |
255 " unique_name = 1\n" | 255 " unique_name = 1\n" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 setup.settings()->set_target_os(Settings::WIN); | 334 setup.settings()->set_target_os(Settings::WIN); |
335 | 335 |
336 std::ostringstream out; | 336 std::ostringstream out; |
337 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); | 337 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); |
338 writer.Run(); | 338 writer.Run(); |
339 | 339 |
340 // TODO(brettw) I think we'll need to worry about backslashes here | 340 // TODO(brettw) I think we'll need to worry about backslashes here |
341 // depending if we're on actual Windows or Linux pretending to be Windows. | 341 // depending if we're on actual Windows or Linux pretending to be Windows. |
342 const char expected_win[] = | 342 const char expected_win[] = |
343 "rule __foo_bar___rule\n" | 343 "rule __foo_bar___rule\n" |
344 " command = C:/python/python.exe gyp-win-tool action-wrapper " | 344 " command = C$:/python/python.exe gyp-win-tool action-wrapper " |
345 "environment.x86 __foo_bar___rule.$unique_name.rsp\n" | 345 "environment.x86 __foo_bar___rule.$unique_name.rsp\n" |
346 " description = ACTION //foo:bar()\n" | 346 " description = ACTION //foo:bar()\n" |
347 " restat = 1\n" | 347 " restat = 1\n" |
348 " rspfile = __foo_bar___rule.$unique_name.rsp\n" | 348 " rspfile = __foo_bar___rule.$unique_name.rsp\n" |
349 " rspfile_content = C:/python/python.exe ../../foo/script.py -i " | 349 " rspfile_content = C$:/python/python.exe ../../foo/script.py -i " |
350 "${source} \"--out=foo$ bar${source_name_part}.o\"\n" | 350 "${source} \"--out=foo$ bar${source_name_part}.o\"\n" |
351 "\n" | 351 "\n" |
352 "build gen/input1.d input1.out: __foo_bar___rule ../../foo/input1.txt" | 352 "build gen/input1.d input1.out: __foo_bar___rule ../../foo/input1.txt" |
353 " | ../../foo/included.txt\n" | 353 " | ../../foo/included.txt\n" |
354 " unique_name = 0\n" | 354 " unique_name = 0\n" |
355 " source = ../../foo/input1.txt\n" | 355 " source = ../../foo/input1.txt\n" |
356 " source_name_part = input1\n" | 356 " source_name_part = input1\n" |
357 " depfile = gen/input1.d\n" | 357 " depfile = gen/input1.d\n" |
358 "build gen/input2.d input2.out: __foo_bar___rule ../../foo/input2.txt" | 358 "build gen/input2.d input2.out: __foo_bar___rule ../../foo/input2.txt" |
359 " | ../../foo/included.txt\n" | 359 " | ../../foo/included.txt\n" |
360 " unique_name = 1\n" | 360 " unique_name = 1\n" |
361 " source = ../../foo/input2.txt\n" | 361 " source = ../../foo/input2.txt\n" |
362 " source_name_part = input2\n" | 362 " source_name_part = input2\n" |
363 " depfile = gen/input2.d\n" | 363 " depfile = gen/input2.d\n" |
364 "\n" | 364 "\n" |
365 "build obj/foo/bar.stamp: stamp input1.out input2.out\n"; | 365 "build obj/foo/bar.stamp: stamp input1.out input2.out\n"; |
366 std::string out_str = out.str(); | 366 std::string out_str = out.str(); |
367 #if defined(OS_WIN) | 367 #if defined(OS_WIN) |
368 std::replace(out_str.begin(), out_str.end(), '\\', '/'); | 368 std::replace(out_str.begin(), out_str.end(), '\\', '/'); |
369 #endif | 369 #endif |
370 EXPECT_EQ(expected_win, out_str); | 370 EXPECT_EQ(expected_win, out_str); |
371 } | 371 } |
372 } | 372 } |
OLD | NEW |