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

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

Issue 1742303002: Accept absolute Windows paths without leading slash in GN commands (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format files with 'git cl format' to make presubmit script happy Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/gn/label_pattern.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/label.h" 5 #include "tools/gn/label.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 SourceDir* out_dir, 92 SourceDir* out_dir,
93 std::string* out_name, 93 std::string* out_name,
94 SourceDir* out_toolchain_dir, 94 SourceDir* out_toolchain_dir,
95 std::string* out_toolchain_name, 95 std::string* out_toolchain_name,
96 Err* err) { 96 Err* err) {
97 // To workaround the problem that StringPiece operator[] doesn't return a ref. 97 // To workaround the problem that StringPiece operator[] doesn't return a ref.
98 const char* input_str = input.data(); 98 const char* input_str = input.data();
99 size_t offset = 0; 99 size_t offset = 0;
100 #if defined(OS_WIN) 100 #if defined(OS_WIN)
101 if (IsPathAbsolute(input)) { 101 if (IsPathAbsolute(input)) {
102 if (input[0] != '/') { 102 size_t drive_letter_pos = input[0] == '/' ? 1 : 0;
103 *err = Err(original_value, "Bad absolute path.", 103 if (input.size() > drive_letter_pos + 2 &&
104 "Absolute paths must be of the form /C:\\ but this is \"" + 104 input[drive_letter_pos + 1] == ':' &&
105 input.as_string() + "\"."); 105 IsSlash(input[drive_letter_pos + 2]) &&
106 return false; 106 base::IsAsciiAlpha(input[drive_letter_pos])) {
107 }
108 if (input.size() > 3 && input[2] == ':' && IsSlash(input[3]) &&
109 base::IsAsciiAlpha(input[1])) {
110 // Skip over the drive letter colon. 107 // Skip over the drive letter colon.
111 offset = 3; 108 offset = drive_letter_pos + 2;
112 } 109 }
113 } 110 }
114 #endif 111 #endif
115 size_t path_separator = input.find_first_of(":(", offset); 112 size_t path_separator = input.find_first_of(":(", offset);
116 base::StringPiece location_piece; 113 base::StringPiece location_piece;
117 base::StringPiece name_piece; 114 base::StringPiece name_piece;
118 base::StringPiece toolchain_piece; 115 base::StringPiece toolchain_piece;
119 if (path_separator == std::string::npos) { 116 if (path_separator == std::string::npos) {
120 location_piece = input; 117 location_piece = input;
121 // Leave name & toolchain piece null. 118 // Leave name & toolchain piece null.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 270 }
274 return ret; 271 return ret;
275 } 272 }
276 273
277 std::string Label::GetUserVisibleName(const Label& default_toolchain) const { 274 std::string Label::GetUserVisibleName(const Label& default_toolchain) const {
278 bool include_toolchain = 275 bool include_toolchain =
279 default_toolchain.dir() != toolchain_dir_ || 276 default_toolchain.dir() != toolchain_dir_ ||
280 default_toolchain.name() != toolchain_name_; 277 default_toolchain.name() != toolchain_name_;
281 return GetUserVisibleName(include_toolchain); 278 return GetUserVisibleName(include_toolchain);
282 } 279 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/label_pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698