OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/substitution_pattern.h" | 5 #include "tools/gn/substitution_pattern.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "tools/gn/build_settings.h" | 8 #include "tools/gn/build_settings.h" |
9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
10 #include "tools/gn/filesystem_utils.h" | 10 #include "tools/gn/filesystem_utils.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 origin_ = origin; | 85 origin_ = origin; |
86 | 86 |
87 // Fill required types vector. | 87 // Fill required types vector. |
88 SubstitutionBits bits; | 88 SubstitutionBits bits; |
89 FillRequiredTypes(&bits); | 89 FillRequiredTypes(&bits); |
90 bits.FillVector(&required_types_); | 90 bits.FillVector(&required_types_); |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
| 94 // static |
| 95 SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) { |
| 96 Err err; |
| 97 SubstitutionPattern pattern; |
| 98 CHECK(pattern.Parse(str, NULL, &err)) << err.message(); |
| 99 return pattern; |
| 100 } |
| 101 |
94 std::string SubstitutionPattern::AsString() const { | 102 std::string SubstitutionPattern::AsString() const { |
95 std::string result; | 103 std::string result; |
96 for (size_t i = 0; i < ranges_.size(); i++) { | 104 for (size_t i = 0; i < ranges_.size(); i++) { |
97 if (ranges_[i].type == SUBSTITUTION_LITERAL) | 105 if (ranges_[i].type == SUBSTITUTION_LITERAL) |
98 result.append(ranges_[i].literal); | 106 result.append(ranges_[i].literal); |
99 else | 107 else |
100 result.append(kSubstitutionNames[ranges_[i].type]); | 108 result.append(kSubstitutionNames[ranges_[i].type]); |
101 } | 109 } |
102 return result; | 110 return result; |
103 } | 111 } |
(...skipping 26 matching lines...) Expand all Loading... |
130 "File is not inside output directory.", | 138 "File is not inside output directory.", |
131 "The given file should be in the output directory. Normally you\n" | 139 "The given file should be in the output directory. Normally you\n" |
132 "would specify\n\"$target_out_dir/foo\" or " | 140 "would specify\n\"$target_out_dir/foo\" or " |
133 "\"{{source_gen_dir}}/foo\"."); | 141 "\"{{source_gen_dir}}/foo\"."); |
134 return false; | 142 return false; |
135 } | 143 } |
136 } | 144 } |
137 | 145 |
138 return true; | 146 return true; |
139 } | 147 } |
OLD | NEW |