| 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/source_file.h" | 5 #include "tools/gn/source_file.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
| 10 #include "tools/gn/source_dir.h" | 10 #include "tools/gn/source_dir.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 void AssertValueSourceFileString(const std::string& s) { | 14 void AssertValueSourceFileString(const std::string& s) { |
| 15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 16 DCHECK(s[0] == '/' || | 16 DCHECK(s[0] == '/' || |
| 17 (s.size() > 2 && s[0] != '/' && s[1] == ':' && IsSlash(s[2]))); | 17 (s.size() > 2 && s[0] != '/' && s[1] == ':' && IsSlash(s[2]))); |
| 18 #else | 18 #else |
| 19 DCHECK(s[0] == '/'); | 19 DCHECK(s[0] == '/'); |
| 20 #endif | 20 #endif |
| 21 DCHECK(!EndsWithSlash(s)); | 21 DCHECK(!EndsWithSlash(s)) << s; |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 SourceFile::SourceFile() { | 26 SourceFile::SourceFile() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 SourceFile::SourceFile(const base::StringPiece& p) | 29 SourceFile::SourceFile(const base::StringPiece& p) |
| 30 : value_(p.data(), p.size()) { | 30 : value_(p.data(), p.size()) { |
| 31 DCHECK(!value_.empty()); | 31 DCHECK(!value_.empty()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 return base::FilePath(UTF8ToFilePath(converted)); | 75 return base::FilePath(UTF8ToFilePath(converted)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 converted.assign(&value_[2], value_.size() - 2); | 78 converted.assign(&value_[2], value_.size() - 2); |
| 79 if (source_root.empty()) | 79 if (source_root.empty()) |
| 80 return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); | 80 return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); |
| 81 return source_root.Append(UTF8ToFilePath(converted)) | 81 return source_root.Append(UTF8ToFilePath(converted)) |
| 82 .NormalizePathSeparatorsTo('/'); | 82 .NormalizePathSeparatorsTo('/'); |
| 83 } | 83 } |
| OLD | NEW |