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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 years, 8 months 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
« no previous file with comments | « tools/gn/test_with_scope.h ('k') | tools/gn/toolchain.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 "tools/gn/test_with_scope.h" 5 #include "tools/gn/test_with_scope.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
(...skipping 24 matching lines...) Expand all
35 Value(nullptr, str), &err); 35 Value(nullptr, str), &err);
36 CHECK(!err.has_error()); 36 CHECK(!err.has_error());
37 return result; 37 return result;
38 } 38 }
39 39
40 // static 40 // static
41 void TestWithScope::SetupToolchain(Toolchain* toolchain) { 41 void TestWithScope::SetupToolchain(Toolchain* toolchain) {
42 Err err; 42 Err err;
43 43
44 // CC 44 // CC
45 scoped_ptr<Tool> cc_tool(new Tool); 45 std::unique_ptr<Tool> cc_tool(new Tool);
46 SetCommandForTool( 46 SetCommandForTool(
47 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 47 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
48 "-o {{output}}", 48 "-o {{output}}",
49 cc_tool.get()); 49 cc_tool.get());
50 cc_tool->set_outputs(SubstitutionList::MakeForTest( 50 cc_tool->set_outputs(SubstitutionList::MakeForTest(
51 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 51 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
52 toolchain->SetTool(Toolchain::TYPE_CC, std::move(cc_tool)); 52 toolchain->SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
53 53
54 // CXX 54 // CXX
55 scoped_ptr<Tool> cxx_tool(new Tool); 55 std::unique_ptr<Tool> cxx_tool(new Tool);
56 SetCommandForTool( 56 SetCommandForTool(
57 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 57 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
58 "-o {{output}}", 58 "-o {{output}}",
59 cxx_tool.get()); 59 cxx_tool.get());
60 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 60 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
61 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 61 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
62 toolchain->SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool)); 62 toolchain->SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
63 63
64 // OBJC 64 // OBJC
65 scoped_ptr<Tool> objc_tool(new Tool); 65 std::unique_ptr<Tool> objc_tool(new Tool);
66 SetCommandForTool( 66 SetCommandForTool(
67 "objcc {{source}} {{cflags}} {{cflags_objc}} {{defines}} " 67 "objcc {{source}} {{cflags}} {{cflags_objc}} {{defines}} "
68 "{{include_dirs}} -o {{output}}", 68 "{{include_dirs}} -o {{output}}",
69 objc_tool.get()); 69 objc_tool.get());
70 objc_tool->set_outputs(SubstitutionList::MakeForTest( 70 objc_tool->set_outputs(SubstitutionList::MakeForTest(
71 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 71 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
72 toolchain->SetTool(Toolchain::TYPE_OBJC, std::move(objc_tool)); 72 toolchain->SetTool(Toolchain::TYPE_OBJC, std::move(objc_tool));
73 73
74 // OBJC 74 // OBJC
75 scoped_ptr<Tool> objcxx_tool(new Tool); 75 std::unique_ptr<Tool> objcxx_tool(new Tool);
76 SetCommandForTool( 76 SetCommandForTool(
77 "objcxx {{source}} {{cflags}} {{cflags_objcc}} {{defines}} " 77 "objcxx {{source}} {{cflags}} {{cflags_objcc}} {{defines}} "
78 "{{include_dirs}} -o {{output}}", 78 "{{include_dirs}} -o {{output}}",
79 objcxx_tool.get()); 79 objcxx_tool.get());
80 objcxx_tool->set_outputs(SubstitutionList::MakeForTest( 80 objcxx_tool->set_outputs(SubstitutionList::MakeForTest(
81 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 81 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
82 toolchain->SetTool(Toolchain::TYPE_OBJCXX, std::move(objcxx_tool)); 82 toolchain->SetTool(Toolchain::TYPE_OBJCXX, std::move(objcxx_tool));
83 83
84 // Don't use RC and ASM tools in unit tests yet. Add here if needed. 84 // Don't use RC and ASM tools in unit tests yet. Add here if needed.
85 85
86 // ALINK 86 // ALINK
87 scoped_ptr<Tool> alink_tool(new Tool); 87 std::unique_ptr<Tool> alink_tool(new Tool);
88 SetCommandForTool("ar {{output}} {{source}}", alink_tool.get()); 88 SetCommandForTool("ar {{output}} {{source}}", alink_tool.get());
89 alink_tool->set_lib_switch("-l"); 89 alink_tool->set_lib_switch("-l");
90 alink_tool->set_lib_dir_switch("-L"); 90 alink_tool->set_lib_dir_switch("-L");
91 alink_tool->set_output_prefix("lib"); 91 alink_tool->set_output_prefix("lib");
92 alink_tool->set_outputs(SubstitutionList::MakeForTest( 92 alink_tool->set_outputs(SubstitutionList::MakeForTest(
93 "{{target_out_dir}}/{{target_output_name}}.a")); 93 "{{target_out_dir}}/{{target_output_name}}.a"));
94 toolchain->SetTool(Toolchain::TYPE_ALINK, std::move(alink_tool)); 94 toolchain->SetTool(Toolchain::TYPE_ALINK, std::move(alink_tool));
95 95
96 // SOLINK 96 // SOLINK
97 scoped_ptr<Tool> solink_tool(new Tool); 97 std::unique_ptr<Tool> solink_tool(new Tool);
98 SetCommandForTool("ld -shared -o {{target_output_name}}.so {{inputs}} " 98 SetCommandForTool("ld -shared -o {{target_output_name}}.so {{inputs}} "
99 "{{ldflags}} {{libs}}", solink_tool.get()); 99 "{{ldflags}} {{libs}}", solink_tool.get());
100 solink_tool->set_lib_switch("-l"); 100 solink_tool->set_lib_switch("-l");
101 solink_tool->set_lib_dir_switch("-L"); 101 solink_tool->set_lib_dir_switch("-L");
102 solink_tool->set_output_prefix("lib"); 102 solink_tool->set_output_prefix("lib");
103 solink_tool->set_default_output_extension(".so"); 103 solink_tool->set_default_output_extension(".so");
104 solink_tool->set_outputs(SubstitutionList::MakeForTest( 104 solink_tool->set_outputs(SubstitutionList::MakeForTest(
105 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}")); 105 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
106 toolchain->SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool)); 106 toolchain->SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
107 107
108 // SOLINK_MODULE 108 // SOLINK_MODULE
109 scoped_ptr<Tool> solink_module_tool(new Tool); 109 std::unique_ptr<Tool> solink_module_tool(new Tool);
110 SetCommandForTool("ld -bundle -o {{target_output_name}}.so {{inputs}} " 110 SetCommandForTool("ld -bundle -o {{target_output_name}}.so {{inputs}} "
111 "{{ldflags}} {{libs}}", solink_module_tool.get()); 111 "{{ldflags}} {{libs}}", solink_module_tool.get());
112 solink_module_tool->set_lib_switch("-l"); 112 solink_module_tool->set_lib_switch("-l");
113 solink_module_tool->set_lib_dir_switch("-L"); 113 solink_module_tool->set_lib_dir_switch("-L");
114 solink_module_tool->set_output_prefix("lib"); 114 solink_module_tool->set_output_prefix("lib");
115 solink_module_tool->set_default_output_extension(".so"); 115 solink_module_tool->set_default_output_extension(".so");
116 solink_module_tool->set_outputs(SubstitutionList::MakeForTest( 116 solink_module_tool->set_outputs(SubstitutionList::MakeForTest(
117 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}")); 117 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
118 toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE, 118 toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE,
119 std::move(solink_module_tool)); 119 std::move(solink_module_tool));
120 120
121 // LINK 121 // LINK
122 scoped_ptr<Tool> link_tool(new Tool); 122 std::unique_ptr<Tool> link_tool(new Tool);
123 SetCommandForTool("ld -o {{target_output_name}} {{source}} " 123 SetCommandForTool("ld -o {{target_output_name}} {{source}} "
124 "{{ldflags}} {{libs}}", link_tool.get()); 124 "{{ldflags}} {{libs}}", link_tool.get());
125 link_tool->set_lib_switch("-l"); 125 link_tool->set_lib_switch("-l");
126 link_tool->set_lib_dir_switch("-L"); 126 link_tool->set_lib_dir_switch("-L");
127 link_tool->set_outputs(SubstitutionList::MakeForTest( 127 link_tool->set_outputs(SubstitutionList::MakeForTest(
128 "{{root_out_dir}}/{{target_output_name}}")); 128 "{{root_out_dir}}/{{target_output_name}}"));
129 toolchain->SetTool(Toolchain::TYPE_LINK, std::move(link_tool)); 129 toolchain->SetTool(Toolchain::TYPE_LINK, std::move(link_tool));
130 130
131 // STAMP 131 // STAMP
132 scoped_ptr<Tool> stamp_tool(new Tool); 132 std::unique_ptr<Tool> stamp_tool(new Tool);
133 SetCommandForTool("touch {{output}}", stamp_tool.get()); 133 SetCommandForTool("touch {{output}}", stamp_tool.get());
134 toolchain->SetTool(Toolchain::TYPE_STAMP, std::move(stamp_tool)); 134 toolchain->SetTool(Toolchain::TYPE_STAMP, std::move(stamp_tool));
135 135
136 // COPY 136 // COPY
137 scoped_ptr<Tool> copy_tool(new Tool); 137 std::unique_ptr<Tool> copy_tool(new Tool);
138 SetCommandForTool("cp {{source}} {{output}}", copy_tool.get()); 138 SetCommandForTool("cp {{source}} {{output}}", copy_tool.get());
139 toolchain->SetTool(Toolchain::TYPE_COPY, std::move(copy_tool)); 139 toolchain->SetTool(Toolchain::TYPE_COPY, std::move(copy_tool));
140 140
141 // COPY_BUNDLE_DATA 141 // COPY_BUNDLE_DATA
142 scoped_ptr<Tool> copy_bundle_data_tool(new Tool); 142 std::unique_ptr<Tool> copy_bundle_data_tool(new Tool);
143 SetCommandForTool("cp {{source}} {{output}}", copy_bundle_data_tool.get()); 143 SetCommandForTool("cp {{source}} {{output}}", copy_bundle_data_tool.get());
144 toolchain->SetTool(Toolchain::TYPE_COPY_BUNDLE_DATA, 144 toolchain->SetTool(Toolchain::TYPE_COPY_BUNDLE_DATA,
145 std::move(copy_bundle_data_tool)); 145 std::move(copy_bundle_data_tool));
146 146
147 // COMPILE_XCASSETS 147 // COMPILE_XCASSETS
148 scoped_ptr<Tool> compile_xcassets_tool(new Tool); 148 std::unique_ptr<Tool> compile_xcassets_tool(new Tool);
149 SetCommandForTool("touch {{output}}", compile_xcassets_tool.get()); 149 SetCommandForTool("touch {{output}}", compile_xcassets_tool.get());
150 toolchain->SetTool(Toolchain::TYPE_COMPILE_XCASSETS, 150 toolchain->SetTool(Toolchain::TYPE_COMPILE_XCASSETS,
151 std::move(compile_xcassets_tool)); 151 std::move(compile_xcassets_tool));
152 152
153 toolchain->ToolchainSetupComplete(); 153 toolchain->ToolchainSetupComplete();
154 } 154 }
155 155
156 // static 156 // static
157 void TestWithScope::SetCommandForTool(const std::string& cmd, Tool* tool) { 157 void TestWithScope::SetCommandForTool(const std::string& cmd, Tool* tool) {
158 Err err; 158 Err err;
(...skipping 24 matching lines...) Expand all
183 const std::string& label_string, 183 const std::string& label_string,
184 Target::OutputType type) 184 Target::OutputType type)
185 : Target(setup.settings(), setup.ParseLabel(label_string)) { 185 : Target(setup.settings(), setup.ParseLabel(label_string)) {
186 visibility().SetPublic(); 186 visibility().SetPublic();
187 set_output_type(type); 187 set_output_type(type);
188 SetToolchain(setup.toolchain()); 188 SetToolchain(setup.toolchain());
189 } 189 }
190 190
191 TestTarget::~TestTarget() { 191 TestTarget::~TestTarget() {
192 } 192 }
OLDNEW
« no previous file with comments | « tools/gn/test_with_scope.h ('k') | tools/gn/toolchain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698