| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/visual_studio_writer.h" | 5 #include "tools/gn/visual_studio_writer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "tools/gn/variables.h" | 30 #include "tools/gn/variables.h" |
| 31 #include "tools/gn/visual_studio_utils.h" | 31 #include "tools/gn/visual_studio_utils.h" |
| 32 #include "tools/gn/xml_element_writer.h" | 32 #include "tools/gn/xml_element_writer.h" |
| 33 | 33 |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 #include "base/win/registry.h" | 35 #include "base/win/registry.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 std::string EscapeString(const std::string& value) { |
| 41 std::string result; |
| 42 for (char c : value) { |
| 43 switch (c) { |
| 44 case '\n': |
| 45 result += " "; |
| 46 break; |
| 47 case '\r': |
| 48 result += " "; |
| 49 break; |
| 50 case '\t': |
| 51 result += "	"; |
| 52 break; |
| 53 case '"': |
| 54 result += """; |
| 55 break; |
| 56 case '<': |
| 57 result += "<"; |
| 58 break; |
| 59 case '>': |
| 60 result += ">"; |
| 61 break; |
| 62 case '&': |
| 63 result += "&"; |
| 64 break; |
| 65 default: |
| 66 result += c; |
| 67 } |
| 68 } |
| 69 return result; |
| 70 } |
| 71 |
| 40 struct SemicolonSeparatedWriter { | 72 struct SemicolonSeparatedWriter { |
| 41 void operator()(const std::string& value, std::ostream& out) const { | 73 void operator()(const std::string& value, std::ostream& out) const { |
| 42 out << value + ';'; | 74 out << EscapeString(value) + ';'; |
| 43 } | 75 } |
| 44 }; | 76 }; |
| 45 | 77 |
| 46 struct IncludeDirWriter { | 78 struct IncludeDirWriter { |
| 47 explicit IncludeDirWriter(PathOutput& path_output) | 79 explicit IncludeDirWriter(PathOutput& path_output) |
| 48 : path_output_(path_output) {} | 80 : path_output_(path_output) {} |
| 49 ~IncludeDirWriter() = default; | 81 ~IncludeDirWriter() = default; |
| 50 | 82 |
| 51 void operator()(const SourceDir& dir, std::ostream& out) const { | 83 void operator()(const SourceDir& dir, std::ostream& out) const { |
| 52 path_output_.WriteDir(out, dir, PathOutput::DIR_NO_LAST_SLASH); | 84 path_output_.WriteDir(out, dir, PathOutput::DIR_NO_LAST_SLASH); |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 } | 899 } |
| 868 } | 900 } |
| 869 | 901 |
| 870 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { | 902 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { |
| 871 std::ostringstream ninja_target_out; | 903 std::ostringstream ninja_target_out; |
| 872 DCHECK(!target->dependency_output_file().value().empty()); | 904 DCHECK(!target->dependency_output_file().value().empty()); |
| 873 ninja_path_output_.WriteFile(ninja_target_out, | 905 ninja_path_output_.WriteFile(ninja_target_out, |
| 874 target->dependency_output_file()); | 906 target->dependency_output_file()); |
| 875 return ninja_target_out.str(); | 907 return ninja_target_out.str(); |
| 876 } | 908 } |
| OLD | NEW |