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

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

Issue 857163002: Absolute path fixes for gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/filesystem_utils.h"
9 #include "tools/gn/parse_tree.h" 10 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/value.h" 11 #include "tools/gn/value.h"
11 12
12 namespace { 13 namespace {
13 14
14 // We print user visible label names with no trailing slash after the 15 // We print user visible label names with no trailing slash after the
15 // directory name. 16 // directory name.
16 std::string DirWithNoTrailingSlash(const SourceDir& dir) { 17 std::string DirWithNoTrailingSlash(const SourceDir& dir) {
17 // Be careful not to trim if the input is just "/" or "//". 18 // Be careful not to trim if the input is just "/" or "//".
18 if (dir.value().size() > 2) 19 if (dir.value().size() > 2)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const Label& current_toolchain, 87 const Label& current_toolchain,
87 const Value& original_value, 88 const Value& original_value,
88 const base::StringPiece& input, 89 const base::StringPiece& input,
89 SourceDir* out_dir, 90 SourceDir* out_dir,
90 std::string* out_name, 91 std::string* out_name,
91 SourceDir* out_toolchain_dir, 92 SourceDir* out_toolchain_dir,
92 std::string* out_toolchain_name, 93 std::string* out_toolchain_name,
93 Err* err) { 94 Err* err) {
94 // To workaround the problem that StringPiece operator[] doesn't return a ref. 95 // To workaround the problem that StringPiece operator[] doesn't return a ref.
95 const char* input_str = input.data(); 96 const char* input_str = input.data();
96 97 size_t offset = 0;
97 size_t path_separator = input.find_first_of(":("); 98 #if defined(OS_WIN)
brettw 2015/01/20 21:05:00 On Windows, this accepts either "/C:/foo" or "C:/f
99 if (IsPathAbsolute(input)) {
100 // Skip over the drive letter colon.
101 offset = 3;
102 }
103 #endif
104 size_t path_separator = input.find_first_of(":(", offset);
98 base::StringPiece location_piece; 105 base::StringPiece location_piece;
99 base::StringPiece name_piece; 106 base::StringPiece name_piece;
100 base::StringPiece toolchain_piece; 107 base::StringPiece toolchain_piece;
101 if (path_separator == std::string::npos) { 108 if (path_separator == std::string::npos) {
102 location_piece = input; 109 location_piece = input;
103 // Leave name & toolchain piece null. 110 // Leave name & toolchain piece null.
104 } else { 111 } else {
105 location_piece = base::StringPiece(&input_str[0], path_separator); 112 location_piece = base::StringPiece(&input_str[0], path_separator);
106 113
107 size_t toolchain_separator = input.find('(', path_separator); 114 size_t toolchain_separator = input.find('(', path_separator);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 260 }
254 return ret; 261 return ret;
255 } 262 }
256 263
257 std::string Label::GetUserVisibleName(const Label& default_toolchain) const { 264 std::string Label::GetUserVisibleName(const Label& default_toolchain) const {
258 bool include_toolchain = 265 bool include_toolchain =
259 default_toolchain.dir() != toolchain_dir_ || 266 default_toolchain.dir() != toolchain_dir_ ||
260 default_toolchain.name() != toolchain_name_; 267 default_toolchain.name() != toolchain_name_;
261 return GetUserVisibleName(include_toolchain); 268 return GetUserVisibleName(include_toolchain);
262 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698