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

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

Issue 2265833002: Implement `gn analyze`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not pretty print the written json; this gets around crlf issues Created 4 years, 3 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/docs/reference.md ('k') | 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const ParseNode* origin, 93 const ParseNode* origin,
94 Err* err); 94 Err* err);
95 95
96 // ---------------------------------------------------------------------------- 96 // ----------------------------------------------------------------------------
97 97
98 // Returns true if the input string is absolute. Double-slashes at the 98 // Returns true if the input string is absolute. Double-slashes at the
99 // beginning are treated as source-relative paths. On Windows, this handles 99 // beginning are treated as source-relative paths. On Windows, this handles
100 // paths of both the native format: "C:/foo" and ours "/C:/foo" 100 // paths of both the native format: "C:/foo" and ours "/C:/foo"
101 bool IsPathAbsolute(const base::StringPiece& path); 101 bool IsPathAbsolute(const base::StringPiece& path);
102 102
103 // Returns true if the input string is source-absolute. Source-absolute
104 // paths begin with two forward slashes and resolve as if they are
105 // relative to the source root.
106 bool IsPathSourceAbsolute(const base::StringPiece& path);
107
103 // Given an absolute path, checks to see if is it is inside the source root. 108 // Given an absolute path, checks to see if is it is inside the source root.
104 // If it is, fills a source-absolute path into the given output and returns 109 // If it is, fills a source-absolute path into the given output and returns
105 // true. If it isn't, clears the dest and returns false. 110 // true. If it isn't, clears the dest and returns false.
106 // 111 //
107 // The source_root should be a base::FilePath converted to UTF-8. On Windows, 112 // The source_root should be a base::FilePath converted to UTF-8. On Windows,
108 // it should begin with a "C:/" rather than being our SourceFile's style 113 // it should begin with a "C:/" rather than being our SourceFile's style
109 // ("/C:/"). The source root can end with a slash or not. 114 // ("/C:/"). The source root can end with a slash or not.
110 // 115 //
111 // Note that this does not attempt to normalize slashes in the output. 116 // Note that this does not attempt to normalize slashes in the output.
112 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root, 117 bool MakeAbsolutePathRelativeIfPossible(const base::StringPiece& source_root,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 bool ContentsEqual(const base::FilePath& file_path, const std::string& data); 173 bool ContentsEqual(const base::FilePath& file_path, const std::string& data);
169 174
170 // Writes given stream contents to the given file if it differs from existing 175 // Writes given stream contents to the given file if it differs from existing
171 // file contents. Returns true if new contents was successfully written or 176 // file contents. Returns true if new contents was successfully written or
172 // existing file contents doesn't need updating, false on write error. |err| is 177 // existing file contents doesn't need updating, false on write error. |err| is
173 // set on write error if not nullptr. 178 // set on write error if not nullptr.
174 bool WriteFileIfChanged(const base::FilePath& file_path, 179 bool WriteFileIfChanged(const base::FilePath& file_path,
175 const std::string& data, 180 const std::string& data,
176 Err* err); 181 Err* err);
177 182
183 // Writes given stream contents to the given file. Returns true if data was
184 // successfully written, false otherwise. |err| is set on error if not nullptr.
185 bool WriteFile(const base::FilePath& file_path, const std::string& data,
186 Err* err);
187
178 // ----------------------------------------------------------------------------- 188 // -----------------------------------------------------------------------------
179 189
180 enum class BuildDirType { 190 enum class BuildDirType {
181 // Returns the root toolchain dir rather than the generated or output 191 // Returns the root toolchain dir rather than the generated or output
182 // subdirectories. This is valid only for the toolchain directory getters. 192 // subdirectories. This is valid only for the toolchain directory getters.
183 // Asking for this for a target or source dir makes no sense. 193 // Asking for this for a target or source dir makes no sense.
184 TOOLCHAIN_ROOT, 194 TOOLCHAIN_ROOT,
185 195
186 // Generated file directory. 196 // Generated file directory.
187 GEN, 197 GEN,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 OutputFile GetBuildDirForTargetAsOutputFile(const Target* target, 262 OutputFile GetBuildDirForTargetAsOutputFile(const Target* target,
253 BuildDirType type); 263 BuildDirType type);
254 264
255 // Returns the scope's current directory. 265 // Returns the scope's current directory.
256 SourceDir GetScopeCurrentBuildDirAsSourceDir(const Scope* scope, 266 SourceDir GetScopeCurrentBuildDirAsSourceDir(const Scope* scope,
257 BuildDirType type); 267 BuildDirType type);
258 // Lack of OutputDir version is due only to it not currently being needed, 268 // Lack of OutputDir version is due only to it not currently being needed,
259 // please add one if you need it. 269 // please add one if you need it.
260 270
261 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_ 271 #endif // TOOLS_GN_FILESYSTEM_UTILS_H_
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/filesystem_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698