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

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

Issue 1455203002: [GN] Add support to rebase_path to resolve paths above the source root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add tests, handle Windows sources. Created 5 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
« no previous file with comments | « no previous file | tools/gn/filesystem_utils.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 #ifndef TOOLS_GN_FILESYSTEM_UTILS_H_ 5 #ifndef TOOLS_GN_FILESYSTEM_UTILS_H_
6 #define TOOLS_GN_FILESYSTEM_UTILS_H_ 6 #define TOOLS_GN_FILESYSTEM_UTILS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // 104 //
105 // The source_root should be a base::FilePath converted to UTF-8. On Windows, 105 // The source_root should be a base::FilePath converted to UTF-8. On Windows,
106 // it should begin with a "C:/" rather than being our SourceFile's style 106 // it should begin with a "C:/" rather than being our SourceFile's style
107 // ("/C:/"). The source root can end with a slash or not. 107 // ("/C:/"). The source root can end with a slash or not.
108 // 108 //
109 // Note that this does not attempt to normalize slashes in the output. 109 // Note that this does not attempt to normalize slashes in the output.
110 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, 110 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root,
111 const base::StringPiece& path, 111 const base::StringPiece& path,
112 std::string* dest); 112 std::string* dest);
113 113
114 // Collapses "." and sequential "/"s and evaluates "..". 114 // Collapses "." and sequential "/"s and evaluates "..". |path| may be
115 void NormalizePath(std::string* path); 115 // system-absolute, source-absolute, or relative. If |path| is source-absolute
116 // and |source_root| is non-empty, |path| may be system absolute after this
117 // function returns, if |path| references the filesystem outside of
118 // |source_root| (ex. path = "//.."). In this case on Windows, |path| will have
119 // a leading slash. Otherwise, |path| will retain its relativity. |source_root|
120 // must not end with a slash.
121 void NormalizePath(std::string* path,
122 const base::StringPiece& source_root = base::StringPiece());
116 123
117 // Converts slashes to backslashes for Windows. Keeps the string unchanged 124 // Converts slashes to backslashes for Windows. Keeps the string unchanged
118 // for other systems. 125 // for other systems.
119 void ConvertPathToSystem(std::string* path); 126 void ConvertPathToSystem(std::string* path);
120 127
121 // Takes a path, |input|, and makes it relative to the given directory 128 // Takes a path, |input|, and makes it relative to the given directory
122 // |dest_dir|. Both inputs may be source-relative (e.g. begins with 129 // |dest_dir|. Both inputs may be source-relative (e.g. begins with
123 // with "//") or may be absolute. 130 // with "//") or may be absolute.
124 // 131 //
125 // If supplied, the |source_root| parameter is the absolute path to 132 // If supplied, the |source_root| parameter is the absolute path to
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 195
189 SourceDir GetTargetOutputDir(const Target* target); 196 SourceDir GetTargetOutputDir(const Target* target);
190 OutputFile GetTargetOutputDirAsOutputFile(const Target* target); 197 OutputFile GetTargetOutputDirAsOutputFile(const Target* target);
191 SourceDir GetTargetGenDir(const Target* target); 198 SourceDir GetTargetGenDir(const Target* target);
192 OutputFile GetTargetGenDirAsOutputFile(const Target* target); 199 OutputFile GetTargetGenDirAsOutputFile(const Target* target);
193 200
194 SourceDir GetCurrentOutputDir(const Scope* scope); 201 SourceDir GetCurrentOutputDir(const Scope* scope);
195 SourceDir GetCurrentGenDir(const Scope* scope); 202 SourceDir GetCurrentGenDir(const Scope* scope);
196 203
197 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ 204 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | tools/gn/filesystem_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698