Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: tools/gn/ninja_binary_target_writer_unittest.cc

Issue 51693002: GN: toolchain threading cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_copy_target_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 TEST(NinjaBinaryTargetWriter, SourceSet) { 11 TEST(NinjaBinaryTargetWriter, SourceSet) {
12 TestWithScope setup; 12 TestWithScope setup;
13 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); 13 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
14 setup.settings()->set_target_os(Settings::WIN); 14 setup.settings()->set_target_os(Settings::WIN);
15 15
16 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar")); 16 Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
17 target.set_output_type(Target::SOURCE_SET); 17 target.set_output_type(Target::SOURCE_SET);
18 target.sources().push_back(SourceFile("//foo/input1.cc")); 18 target.sources().push_back(SourceFile("//foo/input1.cc"));
19 target.sources().push_back(SourceFile("//foo/input2.cc")); 19 target.sources().push_back(SourceFile("//foo/input2.cc"));
20 target.OnResolved(); 20 target.OnResolved();
21 21
22 // Source set itself. 22 // Source set itself.
23 { 23 {
24 std::ostringstream out; 24 std::ostringstream out;
25 NinjaBinaryTargetWriter writer(&target, out); 25 NinjaBinaryTargetWriter writer(&target, setup.toolchain(), out);
26 writer.Run(); 26 writer.Run();
27 27
28 // TODO(brettw) I think we'll need to worry about backslashes here 28 // TODO(brettw) I think we'll need to worry about backslashes here
29 // depending if we're on actual Windows or Linux pretending to be Windows. 29 // depending if we're on actual Windows or Linux pretending to be Windows.
30 const char expected_win[] = 30 const char expected_win[] =
31 "defines =\n" 31 "defines =\n"
32 "includes =\n" 32 "includes =\n"
33 "cflags =\n" 33 "cflags =\n"
34 "cflags_c =\n" 34 "cflags_c =\n"
35 "cflags_cc =\n" 35 "cflags_cc =\n"
36 "cflags_objc =\n" 36 "cflags_objc =\n"
37 "cflags_objcc =\n" 37 "cflags_objcc =\n"
38 "\n" 38 "\n"
39 "build obj/foo/bar.input1.obj: tc_cxx ../../foo/input1.cc\n" 39 "build obj/foo/bar.input1.obj: cxx ../../foo/input1.cc\n"
40 "build obj/foo/bar.input2.obj: tc_cxx ../../foo/input2.cc\n" 40 "build obj/foo/bar.input2.obj: cxx ../../foo/input2.cc\n"
41 "\n" 41 "\n"
42 "build obj/foo/bar.stamp: tc_stamp obj/foo/bar.input1.obj obj/foo/bar.in put2.obj\n"; 42 "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.obj obj/foo/bar.input 2.obj\n";
43 std::string out_str = out.str(); 43 std::string out_str = out.str();
44 #if defined(OS_WIN) 44 #if defined(OS_WIN)
45 std::replace(out_str.begin(), out_str.end(), '\\', '/'); 45 std::replace(out_str.begin(), out_str.end(), '\\', '/');
46 #endif 46 #endif
47 EXPECT_EQ(expected_win, out_str); 47 EXPECT_EQ(expected_win, out_str);
48 } 48 }
49 49
50 // A shared library that depends on the source set. 50 // A shared library that depends on the source set.
51 Target shlib_target(setup.settings(), Label(SourceDir("//foo/"), "shlib")); 51 Target shlib_target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
52 shlib_target.set_output_type(Target::SHARED_LIBRARY); 52 shlib_target.set_output_type(Target::SHARED_LIBRARY);
53 shlib_target.deps().push_back(LabelTargetPair(&target)); 53 shlib_target.deps().push_back(LabelTargetPair(&target));
54 shlib_target.OnResolved(); 54 shlib_target.OnResolved();
55 55
56 { 56 {
57 std::ostringstream out; 57 std::ostringstream out;
58 NinjaBinaryTargetWriter writer(&shlib_target, out); 58 NinjaBinaryTargetWriter writer(&shlib_target, setup.toolchain(), out);
59 writer.Run(); 59 writer.Run();
60 60
61 // TODO(brettw) I think we'll need to worry about backslashes here 61 // TODO(brettw) I think we'll need to worry about backslashes here
62 // depending if we're on actual Windows or Linux pretending to be Windows. 62 // depending if we're on actual Windows or Linux pretending to be Windows.
63 const char expected_win[] = 63 const char expected_win[] =
64 "defines =\n" 64 "defines =\n"
65 "includes =\n" 65 "includes =\n"
66 "cflags =\n" 66 "cflags =\n"
67 "cflags_c =\n" 67 "cflags_c =\n"
68 "cflags_cc =\n" 68 "cflags_cc =\n"
69 "cflags_objc =\n" 69 "cflags_objc =\n"
70 "cflags_objcc =\n" 70 "cflags_objcc =\n"
71 "\n" 71 "\n"
72 "\n" 72 "\n"
73 "manifests = obj/foo/shlib.intermediate.manifest\n" 73 "manifests = obj/foo/shlib.intermediate.manifest\n"
74 "ldflags = /MANIFEST /ManifestFile:obj/foo/shlib.intermediate.manifest\n " 74 "ldflags = /MANIFEST /ManifestFile:obj/foo/shlib.intermediate.manifest\n "
75 "libs =\n" 75 "libs =\n"
76 "build shlib.dll shlib.dll.lib: tc_solink obj/foo/bar.input1.obj obj/foo /bar.input2.obj\n" 76 "build shlib.dll shlib.dll.lib: solink obj/foo/bar.input1.obj obj/foo/ba r.input2.obj\n"
77 " soname = shlib.dll\n" 77 " soname = shlib.dll\n"
78 " lib = shlib.dll\n" 78 " lib = shlib.dll\n"
79 " dll = shlib.dll\n" 79 " dll = shlib.dll\n"
80 " implibflag = /IMPLIB:shlib.dll.lib\n\n"; 80 " implibflag = /IMPLIB:shlib.dll.lib\n\n";
81 std::string out_str = out.str(); 81 std::string out_str = out.str();
82 #if defined(OS_WIN) 82 #if defined(OS_WIN)
83 std::replace(out_str.begin(), out_str.end(), '\\', '/'); 83 std::replace(out_str.begin(), out_str.end(), '\\', '/');
84 #endif 84 #endif
85 EXPECT_EQ(expected_win, out_str); 85 EXPECT_EQ(expected_win, out_str);
86 } 86 }
87 } 87 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_binary_target_writer.cc ('k') | tools/gn/ninja_copy_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698