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/path_output.h" | 5 #include "tools/gn/path_output.h" |
6 | 6 |
| 7 #include "base/strings/string_util.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
9 #include "tools/gn/output_file.h" | 10 #include "tools/gn/output_file.h" |
10 #include "tools/gn/string_utils.h" | 11 #include "tools/gn/string_utils.h" |
11 | 12 |
12 PathOutput::PathOutput(const SourceDir& current_dir, EscapingMode escaping) | 13 PathOutput::PathOutput(const SourceDir& current_dir, |
| 14 const base::StringPiece& source_root, |
| 15 EscapingMode escaping) |
13 : current_dir_(current_dir) { | 16 : current_dir_(current_dir) { |
14 CHECK(current_dir.is_source_absolute()) | 17 inverse_current_dir_ = RebasePath("//", current_dir, source_root); |
15 << "Currently this only supports writing to output directories inside " | 18 if (!EndsWithSlash(inverse_current_dir_)) |
16 "the source root. There needs to be some tweaks to PathOutput to make " | 19 inverse_current_dir_.push_back('/'); |
17 "doing this work correctly."; | |
18 inverse_current_dir_ = InvertDir(current_dir_); | |
19 | |
20 options_.mode = escaping; | 20 options_.mode = escaping; |
21 } | 21 } |
22 | 22 |
23 PathOutput::~PathOutput() { | 23 PathOutput::~PathOutput() { |
24 } | 24 } |
25 | 25 |
26 void PathOutput::WriteFile(std::ostream& out, const SourceFile& file) const { | 26 void PathOutput::WriteFile(std::ostream& out, const SourceFile& file) const { |
27 WritePathStr(out, file.value()); | 27 WritePathStr(out, file.value()); |
28 } | 28 } |
29 | 29 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // it's system-absolute. | 155 // it's system-absolute. |
156 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
157 // On Windows, trim the leading slash, since the input for absolute | 157 // On Windows, trim the leading slash, since the input for absolute |
158 // paths will look like "/C:/foo/bar.txt". | 158 // paths will look like "/C:/foo/bar.txt". |
159 EscapeStringToStream(out, str.substr(1), options_); | 159 EscapeStringToStream(out, str.substr(1), options_); |
160 #else | 160 #else |
161 EscapeStringToStream(out, str, options_); | 161 EscapeStringToStream(out, str, options_); |
162 #endif | 162 #endif |
163 } | 163 } |
164 } | 164 } |
OLD | NEW |