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 26 matching lines...) Expand all Loading... |
37 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); | 37 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
38 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); | 38 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); |
39 | 39 |
40 std::ostringstream out; | 40 std::ostringstream out; |
41 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); | 41 NinjaActionTargetWriter writer(&target, setup.toolchain(), out); |
42 | 42 |
43 std::vector<std::string> args; | 43 std::vector<std::string> args; |
44 args.push_back("-i"); | 44 args.push_back("-i"); |
45 args.push_back("{{source}}"); | 45 args.push_back("{{source}}"); |
46 args.push_back("--out=foo bar{{source_name_part}}.o"); | 46 args.push_back("--out=foo bar{{source_name_part}}.o"); |
47 FileTemplate args_template(args); | 47 FileTemplate args_template(setup.settings(), args); |
48 | 48 |
49 writer.WriteArgsSubstitutions(SourceFile("//foo/b ar.in"), args_template); | 49 writer.WriteArgsSubstitutions(SourceFile("//foo/b ar.in"), args_template); |
50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
51 EXPECT_EQ(" source = \"../../foo/b$ ar.in\"\n" | 51 EXPECT_EQ(" source = \"../../foo/b$ ar.in\"\n" |
52 " source_name_part = \"b$ ar\"\n", | 52 " source_name_part = \"b$ ar\"\n", |
53 out.str()); | 53 out.str()); |
54 #else | 54 #else |
55 EXPECT_EQ(" source = ../../foo/b\\$ ar.in\n" | 55 EXPECT_EQ(" source = ../../foo/b\\$ ar.in\n" |
56 " source_name_part = b\\$ ar\n", | 56 " source_name_part = b\\$ ar\n", |
57 out.str()); | 57 out.str()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 " | obj/foo/bar.inputdeps.stamp\n" | 343 " | obj/foo/bar.inputdeps.stamp\n" |
344 " unique_name = 1\n" | 344 " unique_name = 1\n" |
345 " source = ../../foo/input2.txt\n" | 345 " source = ../../foo/input2.txt\n" |
346 " source_name_part = input2\n" | 346 " source_name_part = input2\n" |
347 " depfile = gen/input2.d\n" | 347 " depfile = gen/input2.d\n" |
348 "\n" | 348 "\n" |
349 "build obj/foo/bar.stamp: stamp input1.out input2.out\n"; | 349 "build obj/foo/bar.stamp: stamp input1.out input2.out\n"; |
350 EXPECT_EQ(expected_win, out.str()); | 350 EXPECT_EQ(expected_win, out.str()); |
351 } | 351 } |
352 } | 352 } |
OLD | NEW |