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

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

Issue 1544333002: Convert Pass()→std::move() in //tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/template.cc ('k') | tools/gn/toolchain.cc » ('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>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
9 #include "tools/gn/tokenizer.h" 11 #include "tools/gn/tokenizer.h"
10 12
11 TestWithScope::TestWithScope() 13 TestWithScope::TestWithScope()
12 : build_settings_(), 14 : build_settings_(),
13 settings_(&build_settings_, std::string()), 15 settings_(&build_settings_, std::string()),
14 toolchain_(&settings_, Label(SourceDir("//toolchain/"), "default")), 16 toolchain_(&settings_, Label(SourceDir("//toolchain/"), "default")),
15 scope_(&settings_), 17 scope_(&settings_),
16 scope_progammatic_provider_(&scope_, true) { 18 scope_progammatic_provider_(&scope_, true) {
(...skipping 23 matching lines...) Expand all
40 Err err; 42 Err err;
41 43
42 // CC 44 // CC
43 scoped_ptr<Tool> cc_tool(new Tool); 45 scoped_ptr<Tool> cc_tool(new Tool);
44 SetCommandForTool( 46 SetCommandForTool(
45 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} " 47 "cc {{source}} {{cflags}} {{cflags_c}} {{defines}} {{include_dirs}} "
46 "-o {{output}}", 48 "-o {{output}}",
47 cc_tool.get()); 49 cc_tool.get());
48 cc_tool->set_outputs(SubstitutionList::MakeForTest( 50 cc_tool->set_outputs(SubstitutionList::MakeForTest(
49 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 51 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
50 toolchain->SetTool(Toolchain::TYPE_CC, cc_tool.Pass()); 52 toolchain->SetTool(Toolchain::TYPE_CC, std::move(cc_tool));
51 53
52 // CXX 54 // CXX
53 scoped_ptr<Tool> cxx_tool(new Tool); 55 scoped_ptr<Tool> cxx_tool(new Tool);
54 SetCommandForTool( 56 SetCommandForTool(
55 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " 57 "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
56 "-o {{output}}", 58 "-o {{output}}",
57 cxx_tool.get()); 59 cxx_tool.get());
58 cxx_tool->set_outputs(SubstitutionList::MakeForTest( 60 cxx_tool->set_outputs(SubstitutionList::MakeForTest(
59 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 61 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
60 toolchain->SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass()); 62 toolchain->SetTool(Toolchain::TYPE_CXX, std::move(cxx_tool));
61 63
62 // OBJC 64 // OBJC
63 scoped_ptr<Tool> objc_tool(new Tool); 65 scoped_ptr<Tool> objc_tool(new Tool);
64 SetCommandForTool( 66 SetCommandForTool(
65 "objcc {{source}} {{cflags}} {{cflags_objc}} {{defines}} " 67 "objcc {{source}} {{cflags}} {{cflags_objc}} {{defines}} "
66 "{{include_dirs}} -o {{output}}", 68 "{{include_dirs}} -o {{output}}",
67 objc_tool.get()); 69 objc_tool.get());
68 objc_tool->set_outputs(SubstitutionList::MakeForTest( 70 objc_tool->set_outputs(SubstitutionList::MakeForTest(
69 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 71 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
70 toolchain->SetTool(Toolchain::TYPE_OBJC, objc_tool.Pass()); 72 toolchain->SetTool(Toolchain::TYPE_OBJC, std::move(objc_tool));
71 73
72 // OBJC 74 // OBJC
73 scoped_ptr<Tool> objcxx_tool(new Tool); 75 scoped_ptr<Tool> objcxx_tool(new Tool);
74 SetCommandForTool( 76 SetCommandForTool(
75 "objcxx {{source}} {{cflags}} {{cflags_objcc}} {{defines}} " 77 "objcxx {{source}} {{cflags}} {{cflags_objcc}} {{defines}} "
76 "{{include_dirs}} -o {{output}}", 78 "{{include_dirs}} -o {{output}}",
77 objcxx_tool.get()); 79 objcxx_tool.get());
78 objcxx_tool->set_outputs(SubstitutionList::MakeForTest( 80 objcxx_tool->set_outputs(SubstitutionList::MakeForTest(
79 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o")); 81 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
80 toolchain->SetTool(Toolchain::TYPE_OBJCXX, objcxx_tool.Pass()); 82 toolchain->SetTool(Toolchain::TYPE_OBJCXX, std::move(objcxx_tool));
81 83
82 // 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.
83 85
84 // ALINK 86 // ALINK
85 scoped_ptr<Tool> alink_tool(new Tool); 87 scoped_ptr<Tool> alink_tool(new Tool);
86 SetCommandForTool("ar {{output}} {{source}}", alink_tool.get()); 88 SetCommandForTool("ar {{output}} {{source}}", alink_tool.get());
87 alink_tool->set_lib_switch("-l"); 89 alink_tool->set_lib_switch("-l");
88 alink_tool->set_lib_dir_switch("-L"); 90 alink_tool->set_lib_dir_switch("-L");
89 alink_tool->set_output_prefix("lib"); 91 alink_tool->set_output_prefix("lib");
90 alink_tool->set_outputs(SubstitutionList::MakeForTest( 92 alink_tool->set_outputs(SubstitutionList::MakeForTest(
91 "{{target_out_dir}}/{{target_output_name}}.a")); 93 "{{target_out_dir}}/{{target_output_name}}.a"));
92 toolchain->SetTool(Toolchain::TYPE_ALINK, alink_tool.Pass()); 94 toolchain->SetTool(Toolchain::TYPE_ALINK, std::move(alink_tool));
93 95
94 // SOLINK 96 // SOLINK
95 scoped_ptr<Tool> solink_tool(new Tool); 97 scoped_ptr<Tool> solink_tool(new Tool);
96 SetCommandForTool("ld -shared -o {{target_output_name}}.so {{inputs}} " 98 SetCommandForTool("ld -shared -o {{target_output_name}}.so {{inputs}} "
97 "{{ldflags}} {{libs}}", solink_tool.get()); 99 "{{ldflags}} {{libs}}", solink_tool.get());
98 solink_tool->set_lib_switch("-l"); 100 solink_tool->set_lib_switch("-l");
99 solink_tool->set_lib_dir_switch("-L"); 101 solink_tool->set_lib_dir_switch("-L");
100 solink_tool->set_output_prefix("lib"); 102 solink_tool->set_output_prefix("lib");
101 solink_tool->set_default_output_extension(".so"); 103 solink_tool->set_default_output_extension(".so");
102 solink_tool->set_outputs(SubstitutionList::MakeForTest( 104 solink_tool->set_outputs(SubstitutionList::MakeForTest(
103 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}")); 105 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
104 toolchain->SetTool(Toolchain::TYPE_SOLINK, solink_tool.Pass()); 106 toolchain->SetTool(Toolchain::TYPE_SOLINK, std::move(solink_tool));
105 107
106 // SOLINK_MODULE 108 // SOLINK_MODULE
107 scoped_ptr<Tool> solink_module_tool(new Tool); 109 scoped_ptr<Tool> solink_module_tool(new Tool);
108 SetCommandForTool("ld -bundle -o {{target_output_name}}.so {{inputs}} " 110 SetCommandForTool("ld -bundle -o {{target_output_name}}.so {{inputs}} "
109 "{{ldflags}} {{libs}}", solink_module_tool.get()); 111 "{{ldflags}} {{libs}}", solink_module_tool.get());
110 solink_module_tool->set_lib_switch("-l"); 112 solink_module_tool->set_lib_switch("-l");
111 solink_module_tool->set_lib_dir_switch("-L"); 113 solink_module_tool->set_lib_dir_switch("-L");
112 solink_module_tool->set_output_prefix("lib"); 114 solink_module_tool->set_output_prefix("lib");
113 solink_module_tool->set_default_output_extension(".so"); 115 solink_module_tool->set_default_output_extension(".so");
114 solink_module_tool->set_outputs(SubstitutionList::MakeForTest( 116 solink_module_tool->set_outputs(SubstitutionList::MakeForTest(
115 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}")); 117 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"));
116 toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE, solink_module_tool.Pass()); 118 toolchain->SetTool(Toolchain::TYPE_SOLINK_MODULE,
119 std::move(solink_module_tool));
117 120
118 // LINK 121 // LINK
119 scoped_ptr<Tool> link_tool(new Tool); 122 scoped_ptr<Tool> link_tool(new Tool);
120 SetCommandForTool("ld -o {{target_output_name}} {{source}} " 123 SetCommandForTool("ld -o {{target_output_name}} {{source}} "
121 "{{ldflags}} {{libs}}", link_tool.get()); 124 "{{ldflags}} {{libs}}", link_tool.get());
122 link_tool->set_lib_switch("-l"); 125 link_tool->set_lib_switch("-l");
123 link_tool->set_lib_dir_switch("-L"); 126 link_tool->set_lib_dir_switch("-L");
124 link_tool->set_outputs(SubstitutionList::MakeForTest( 127 link_tool->set_outputs(SubstitutionList::MakeForTest(
125 "{{root_out_dir}}/{{target_output_name}}")); 128 "{{root_out_dir}}/{{target_output_name}}"));
126 toolchain->SetTool(Toolchain::TYPE_LINK, link_tool.Pass()); 129 toolchain->SetTool(Toolchain::TYPE_LINK, std::move(link_tool));
127 130
128 // STAMP 131 // STAMP
129 scoped_ptr<Tool> stamp_tool(new Tool); 132 scoped_ptr<Tool> stamp_tool(new Tool);
130 SetCommandForTool("touch {{output}}", stamp_tool.get()); 133 SetCommandForTool("touch {{output}}", stamp_tool.get());
131 toolchain->SetTool(Toolchain::TYPE_STAMP, stamp_tool.Pass()); 134 toolchain->SetTool(Toolchain::TYPE_STAMP, std::move(stamp_tool));
132 135
133 // COPY 136 // COPY
134 scoped_ptr<Tool> copy_tool(new Tool); 137 scoped_ptr<Tool> copy_tool(new Tool);
135 SetCommandForTool("cp {{source}} {{output}}", copy_tool.get()); 138 SetCommandForTool("cp {{source}} {{output}}", copy_tool.get());
136 toolchain->SetTool(Toolchain::TYPE_COPY, copy_tool.Pass()); 139 toolchain->SetTool(Toolchain::TYPE_COPY, std::move(copy_tool));
137 140
138 toolchain->ToolchainSetupComplete(); 141 toolchain->ToolchainSetupComplete();
139 } 142 }
140 143
141 // static 144 // static
142 void TestWithScope::SetCommandForTool(const std::string& cmd, Tool* tool) { 145 void TestWithScope::SetCommandForTool(const std::string& cmd, Tool* tool) {
143 Err err; 146 Err err;
144 SubstitutionPattern command; 147 SubstitutionPattern command;
145 command.Parse(cmd, nullptr, &err); 148 command.Parse(cmd, nullptr, &err);
146 CHECK(!err.has_error()) 149 CHECK(!err.has_error())
(...skipping 21 matching lines...) Expand all
168 const std::string& label_string, 171 const std::string& label_string,
169 Target::OutputType type) 172 Target::OutputType type)
170 : Target(setup.settings(), setup.ParseLabel(label_string)) { 173 : Target(setup.settings(), setup.ParseLabel(label_string)) {
171 visibility().SetPublic(); 174 visibility().SetPublic();
172 set_output_type(type); 175 set_output_type(type);
173 SetToolchain(setup.toolchain()); 176 SetToolchain(setup.toolchain());
174 } 177 }
175 178
176 TestTarget::~TestTarget() { 179 TestTarget::~TestTarget() {
177 } 180 }
OLDNEW
« no previous file with comments | « tools/gn/template.cc ('k') | tools/gn/toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698