OLD | NEW |
---|---|
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/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/value.h" | 10 #include "tools/gn/value.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 const SourceDir& current_dir, | 28 const SourceDir& current_dir, |
29 const base::StringPiece& input, | 29 const base::StringPiece& input, |
30 SourceDir* result, | 30 SourceDir* result, |
31 Err* err) { | 31 Err* err) { |
32 // No rule, use the current locaton. | 32 // No rule, use the current locaton. |
33 if (input.empty()) { | 33 if (input.empty()) { |
34 *result = current_dir; | 34 *result = current_dir; |
35 return true; | 35 return true; |
36 } | 36 } |
37 | 37 |
38 // Don't allow directories to start with a single slash. All labels must be | |
39 // in the source root. | |
40 if (input[0] == '/' && (input.size() == 1 || input[1] != '/')) { | |
tfarina
2014/12/30 02:38:00
OK. let's try.
| |
41 *err = Err(input_value, "Label can't start with a single slash", | |
42 "Labels must be either relative (no slash at the beginning) or be " | |
43 "absolute\ninside the source root (two slashes at the beginning)."); | |
44 return false; | |
45 } | |
46 | |
47 *result = current_dir.ResolveRelativeDir(input); | 38 *result = current_dir.ResolveRelativeDir(input); |
48 return true; | 39 return true; |
49 } | 40 } |
50 | 41 |
51 // Given the separated-out target name (after the colon) computes the final | 42 // Given the separated-out target name (after the colon) computes the final |
52 // name, using the implicit name from the previously-generated | 43 // name, using the implicit name from the previously-generated |
53 // computed_location if necessary. The input_value is used only for generating | 44 // computed_location if necessary. The input_value is used only for generating |
54 // error messages. | 45 // error messages. |
55 bool ComputeTargetNameFromDep(const Value& input_value, | 46 bool ComputeTargetNameFromDep(const Value& input_value, |
56 const SourceDir& computed_location, | 47 const SourceDir& computed_location, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 } | 253 } |
263 return ret; | 254 return ret; |
264 } | 255 } |
265 | 256 |
266 std::string Label::GetUserVisibleName(const Label& default_toolchain) const { | 257 std::string Label::GetUserVisibleName(const Label& default_toolchain) const { |
267 bool include_toolchain = | 258 bool include_toolchain = |
268 default_toolchain.dir() != toolchain_dir_ || | 259 default_toolchain.dir() != toolchain_dir_ || |
269 default_toolchain.name() != toolchain_name_; | 260 default_toolchain.name() != toolchain_name_; |
270 return GetUserVisibleName(include_toolchain); | 261 return GetUserVisibleName(include_toolchain); |
271 } | 262 } |
OLD | NEW |