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

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

Issue 247663006: Add more phony rules to GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/filesystem_utils.h ('k') | tools/gn/filesystem_utils_unittest.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/filesystem_utils.h" 5 #include "tools/gn/filesystem_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return !s.empty() && IsSlash(s[s.size() - 1]); 306 return !s.empty() && IsSlash(s[s.size() - 1]);
307 } 307 }
308 308
309 base::StringPiece FindDir(const std::string* path) { 309 base::StringPiece FindDir(const std::string* path) {
310 size_t filename_offset = FindFilenameOffset(*path); 310 size_t filename_offset = FindFilenameOffset(*path);
311 if (filename_offset == 0u) 311 if (filename_offset == 0u)
312 return base::StringPiece(); 312 return base::StringPiece();
313 return base::StringPiece(path->data(), filename_offset); 313 return base::StringPiece(path->data(), filename_offset);
314 } 314 }
315 315
316 base::StringPiece FindLastDirComponent(const SourceDir& dir) {
317 const std::string& dir_string = dir.value();
318
319 if (dir_string.empty())
320 return base::StringPiece();
321 int cur = static_cast<int>(dir_string.size()) - 1;
322 DCHECK(dir_string[cur] == '/');
323 int end = cur;
324 cur--; // Skip before the last slash.
325
326 for (; cur >= 0; cur--) {
327 if (dir_string[cur] == '/')
328 return base::StringPiece(&dir_string[cur + 1], end - cur - 1);
329 }
330 return base::StringPiece(&dir_string[0], end);
331 }
332
316 bool EnsureStringIsInOutputDir(const SourceDir& dir, 333 bool EnsureStringIsInOutputDir(const SourceDir& dir,
317 const std::string& str, 334 const std::string& str,
318 const Value& originating, 335 const Value& originating,
319 Err* err) { 336 Err* err) {
320 // The last char of the dir will be a slash. We don't care if the input ends 337 // The last char of the dir will be a slash. We don't care if the input ends
321 // in a slash or not, so just compare up until there. 338 // in a slash or not, so just compare up until there.
322 // 339 //
323 // This check will be wrong for all proper prefixes "e.g. "/output" will 340 // This check will be wrong for all proper prefixes "e.g. "/output" will
324 // match "/out" but we don't really care since this is just a sanity check. 341 // match "/out" but we don't really care since this is just a sanity check.
325 const std::string& dir_str = dir.value(); 342 const std::string& dir_str = dir.value();
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return GetGenDirForSourceDir(target->settings(), target->label().dir()); 725 return GetGenDirForSourceDir(target->settings(), target->label().dir());
709 } 726 }
710 727
711 SourceDir GetCurrentOutputDir(const Scope* scope) { 728 SourceDir GetCurrentOutputDir(const Scope* scope) {
712 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir()); 729 return GetOutputDirForSourceDir(scope->settings(), scope->GetSourceDir());
713 } 730 }
714 731
715 SourceDir GetCurrentGenDir(const Scope* scope) { 732 SourceDir GetCurrentGenDir(const Scope* scope) {
716 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir()); 733 return GetGenDirForSourceDir(scope->settings(), scope->GetSourceDir());
717 } 734 }
OLDNEW
« no previous file with comments | « tools/gn/filesystem_utils.h ('k') | tools/gn/filesystem_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698