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

Unified 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: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/filesystem_utils.cc
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc
index a5787a2ebef41c1a25259b8c84b6cf79072b3073..0bc266dc5873b0dab9d6979dd7483327d955efff 100644
--- a/tools/gn/filesystem_utils.cc
+++ b/tools/gn/filesystem_utils.cc
@@ -313,6 +313,23 @@ base::StringPiece FindDir(const std::string* path) {
return base::StringPiece(path->data(), filename_offset);
}
+base::StringPiece FindLastDirComponent(const SourceDir& dir) {
+ const std::string& dir_string = dir.value();
+
+ if (dir_string.empty())
+ return base::StringPiece();
+ int cur = static_cast<int>(dir_string.size()) - 1;
+ DCHECK(dir_string[cur] == '/');
+ int end = cur;
+ cur--; // Skip before the last slash.
+
+ for (; cur >= 0; cur--) {
+ if (dir_string[cur] == '/')
+ return base::StringPiece(&dir_string[cur + 1], end - cur - 1);
+ }
+ return base::StringPiece(&dir_string[0], end);
+}
+
bool EnsureStringIsInOutputDir(const SourceDir& dir,
const std::string& str,
const Value& originating,

Powered by Google App Engine
This is Rietveld 408576698