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

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

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/substitution_writer.h" 5 #include "tools/gn/substitution_writer.h"
6 6
7 #include "tools/gn/build_settings.h" 7 #include "tools/gn/build_settings.h"
8 #include "tools/gn/escape.h" 8 #include "tools/gn/escape.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/output_file.h" 10 #include "tools/gn/output_file.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 out << "\"" << result << "\""; 162 out << "\"" << result << "\"";
163 else 163 else
164 out << result; 164 out << result;
165 } 165 }
166 166
167 // static 167 // static
168 void SubstitutionWriter::GetListAsSourceFiles( 168 void SubstitutionWriter::GetListAsSourceFiles(
169 const SubstitutionList& list, 169 const SubstitutionList& list,
170 std::vector<SourceFile>* output) { 170 std::vector<SourceFile>* output) {
171 for (const auto& pattern : list.list()) { 171 for (const auto& pattern : list.list()) {
172 CHECK(pattern.ranges().size() == 1 && 172 LOG_IF(FATAL, pattern.ranges().size() != 1 ||
173 pattern.ranges()[0].type == SUBSTITUTION_LITERAL) 173 pattern.ranges()[0].type != SUBSTITUTION_LITERAL)
174 << "The substitution pattern \"" 174 << "The substitution pattern \"" << pattern.AsString()
175 << pattern.AsString()
176 << "\" was expected to be a literal with no {{substitutions}}."; 175 << "\" was expected to be a literal with no {{substitutions}}.";
177 const std::string& literal = pattern.ranges()[0].literal; 176 const std::string& literal = pattern.ranges()[0].literal;
178 CHECK(literal.size() >= 1 && literal[0] == '/') 177 LOG_IF(FATAL, literal.empty() || literal[0] != '/')
179 << "The result of the pattern \"" 178 << "The result of the pattern \"" << pattern.AsString()
180 << pattern.AsString()
181 << "\" was not an absolute path."; 179 << "\" was not an absolute path.";
182 output->push_back(SourceFile(literal)); 180 output->push_back(SourceFile(literal));
183 } 181 }
184 } 182 }
185 183
186 // static 184 // static
187 void SubstitutionWriter::GetListAsOutputFiles( 185 void SubstitutionWriter::GetListAsOutputFiles(
188 const Settings* settings, 186 const Settings* settings,
189 const SubstitutionList& list, 187 const SubstitutionList& list,
190 std::vector<OutputFile>* output) { 188 std::vector<OutputFile>* output) {
191 std::vector<SourceFile> output_as_sources; 189 std::vector<SourceFile> output_as_sources;
192 GetListAsSourceFiles(list, &output_as_sources); 190 GetListAsSourceFiles(list, &output_as_sources);
193 for (const auto& file : output_as_sources) 191 for (const auto& file : output_as_sources)
194 output->push_back(OutputFile(settings->build_settings(), file)); 192 output->push_back(OutputFile(settings->build_settings(), file));
195 } 193 }
196 194
197 // static 195 // static
198 SourceFile SubstitutionWriter::ApplyPatternToSource( 196 SourceFile SubstitutionWriter::ApplyPatternToSource(
199 const Settings* settings, 197 const Settings* settings,
200 const SubstitutionPattern& pattern, 198 const SubstitutionPattern& pattern,
201 const SourceFile& source) { 199 const SourceFile& source) {
202 std::string result_value = ApplyPatternToSourceAsString( 200 std::string result_value = ApplyPatternToSourceAsString(
203 settings, pattern, source); 201 settings, pattern, source);
204 CHECK(!result_value.empty() && result_value[0] == '/') 202 LOG_IF(FATAL, result_value.empty() || result_value[0] != '/')
205 << "The result of the pattern \"" 203 << "The result of the pattern \"" << pattern.AsString()
206 << pattern.AsString()
207 << "\" was not a path beginning in \"/\" or \"//\"."; 204 << "\" was not a path beginning in \"/\" or \"//\".";
208 return SourceFile(SourceFile::SWAP_IN, &result_value); 205 return SourceFile(SourceFile::SWAP_IN, &result_value);
209 } 206 }
210 207
211 // static 208 // static
212 std::string SubstitutionWriter::ApplyPatternToSourceAsString( 209 std::string SubstitutionWriter::ApplyPatternToSourceAsString(
213 const Settings* settings, 210 const Settings* settings,
214 const SubstitutionPattern& pattern, 211 const SubstitutionPattern& pattern,
215 const SourceFile& source) { 212 const SourceFile& source) {
216 std::string result_value; 213 std::string result_value;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return tool->default_output_extension(); 566 return tool->default_output_extension();
570 if (target->output_extension().empty()) 567 if (target->output_extension().empty())
571 return std::string(); // Explicitly set to no extension. 568 return std::string(); // Explicitly set to no extension.
572 return std::string(".") + target->output_extension(); 569 return std::string(".") + target->output_extension();
573 570
574 default: 571 default:
575 NOTREACHED(); 572 NOTREACHED();
576 return std::string(); 573 return std::string();
577 } 574 }
578 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698