Chromium Code Reviews| 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_ = |
| 15 << "Currently this only supports writing to output directories inside " | 18 RebaseSourceAbsolutePath("//", current_dir, source_root); |
| 16 "the source root. There needs to be some tweaks to PathOutput to make " | 19 if (!EndsWithSlash(inverse_current_dir_)) |
|
brettw
2014/11/05 19:59:49
I would hope that the above operation is always th
zeuthen
2014/11/07 19:24:12
I tried adding a DHCECK() and it fails is in the P
| |
| 17 "doing this work correctly."; | 20 inverse_current_dir_.push_back('/'); |
| 18 inverse_current_dir_ = InvertDir(current_dir_); | |
| 19 | |
| 20 options_.mode = escaping; | 21 options_.mode = escaping; |
| 21 } | 22 } |
| 22 | 23 |
| 23 PathOutput::~PathOutput() { | 24 PathOutput::~PathOutput() { |
| 24 } | 25 } |
| 25 | 26 |
| 26 void PathOutput::WriteFile(std::ostream& out, const SourceFile& file) const { | 27 void PathOutput::WriteFile(std::ostream& out, const SourceFile& file) const { |
| 27 WritePathStr(out, file.value()); | 28 WritePathStr(out, file.value()); |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 // it's system-absolute. | 156 // it's system-absolute. |
| 156 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
| 157 // On Windows, trim the leading slash, since the input for absolute | 158 // On Windows, trim the leading slash, since the input for absolute |
| 158 // paths will look like "/C:/foo/bar.txt". | 159 // paths will look like "/C:/foo/bar.txt". |
| 159 EscapeStringToStream(out, str.substr(1), options_); | 160 EscapeStringToStream(out, str.substr(1), options_); |
| 160 #else | 161 #else |
| 161 EscapeStringToStream(out, str, options_); | 162 EscapeStringToStream(out, str, options_); |
| 162 #endif | 163 #endif |
| 163 } | 164 } |
| 164 } | 165 } |
| OLD | NEW |