| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 SubstitutionBits bits; | 93 SubstitutionBits bits; |
| 94 FillRequiredTypes(&bits); | 94 FillRequiredTypes(&bits); |
| 95 bits.FillVector(&required_types_); | 95 bits.FillVector(&required_types_); |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // static | 99 // static |
| 100 SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) { | 100 SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) { |
| 101 Err err; | 101 Err err; |
| 102 SubstitutionPattern pattern; | 102 SubstitutionPattern pattern; |
| 103 CHECK(pattern.Parse(str, nullptr, &err)) << err.message(); | 103 if (!pattern.Parse(str, nullptr, &err)) |
| 104 LOG(FATAL) << err.message(); |
| 104 return pattern; | 105 return pattern; |
| 105 } | 106 } |
| 106 | 107 |
| 107 std::string SubstitutionPattern::AsString() const { | 108 std::string SubstitutionPattern::AsString() const { |
| 108 std::string result; | 109 std::string result; |
| 109 for (const auto& elem : ranges_) { | 110 for (const auto& elem : ranges_) { |
| 110 if (elem.type == SUBSTITUTION_LITERAL) | 111 if (elem.type == SUBSTITUTION_LITERAL) |
| 111 result.append(elem.literal); | 112 result.append(elem.literal); |
| 112 else | 113 else |
| 113 result.append(kSubstitutionNames[elem.type]); | 114 result.append(kSubstitutionNames[elem.type]); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 143 "File is not inside output directory.", | 144 "File is not inside output directory.", |
| 144 "The given file should be in the output directory. Normally you\n" | 145 "The given file should be in the output directory. Normally you\n" |
| 145 "would specify\n\"$target_out_dir/foo\" or " | 146 "would specify\n\"$target_out_dir/foo\" or " |
| 146 "\"{{source_gen_dir}}/foo\"."); | 147 "\"{{source_gen_dir}}/foo\"."); |
| 147 return false; | 148 return false; |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 | 151 |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| OLD | NEW |