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/args.h" | 5 #include "tools/gn/args.h" |
6 | 6 |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "tools/gn/variables.h" | 9 #include "tools/gn/variables.h" |
10 | 10 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 bool Args::VerifyAllOverridesUsed(Err* err) const { | 188 bool Args::VerifyAllOverridesUsed(Err* err) const { |
189 base::AutoLock lock(lock_); | 189 base::AutoLock lock(lock_); |
190 Scope::KeyValueMap all_overrides(all_overrides_); | 190 Scope::KeyValueMap all_overrides(all_overrides_); |
191 for (const auto& map_pair : declared_arguments_per_toolchain_) | 191 for (const auto& map_pair : declared_arguments_per_toolchain_) |
192 RemoveDeclaredOverrides(map_pair.second, &all_overrides); | 192 RemoveDeclaredOverrides(map_pair.second, &all_overrides); |
193 | 193 |
194 if (all_overrides.empty()) | 194 if (all_overrides.empty()) |
195 return true; | 195 return true; |
196 | 196 |
197 // Get a list of all possible overrides for help with error finding. | |
198 // | |
199 // It might be nice to do edit distance checks to see if we can find one close | |
200 // to what you typed. | |
201 std::string all_declared_str; | |
202 for (const auto& map_pair : declared_arguments_per_toolchain_) { | |
203 for (const auto& cur_str : map_pair.second) { | |
204 if (!all_declared_str.empty()) | |
205 all_declared_str += ", "; | |
206 all_declared_str += cur_str.first.as_string(); | |
207 } | |
208 } | |
209 | |
210 *err = Err( | 197 *err = Err( |
211 all_overrides.begin()->second.origin(), "Build argument has no effect.", | 198 all_overrides.begin()->second.origin(), "Build argument has no effect.", |
212 "The variable \"" + all_overrides.begin()->first.as_string() + | 199 "The variable \"" + all_overrides.begin()->first.as_string() + |
213 "\" was set as a build argument\nbut never appeared in a " + | 200 "\" was set as a build argument\nbut never appeared in a " + |
214 "declare_args() block in any buildfile.\n\nPossible arguments: " + | 201 "declare_args() block in any buildfile.\n\n" |
215 all_declared_str); | 202 "To view possible args, run \"gn args --list <builddir>\""); |
216 return false; | 203 return false; |
217 } | 204 } |
218 | 205 |
219 void Args::MergeDeclaredArguments(Scope::KeyValueMap* dest) const { | 206 void Args::MergeDeclaredArguments(Scope::KeyValueMap* dest) const { |
220 base::AutoLock lock(lock_); | 207 base::AutoLock lock(lock_); |
221 for (const auto& map_pair : declared_arguments_per_toolchain_) { | 208 for (const auto& map_pair : declared_arguments_per_toolchain_) { |
222 for (const auto& arg : map_pair.second) | 209 for (const auto& arg : map_pair.second) |
223 (*dest)[arg.first] = arg.second; | 210 (*dest)[arg.first] = arg.second; |
224 } | 211 } |
225 } | 212 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 lock_.AssertAcquired(); | 294 lock_.AssertAcquired(); |
308 for (const auto& val : values) | 295 for (const auto& val : values) |
309 all_overrides_[val.first] = val.second; | 296 all_overrides_[val.first] = val.second; |
310 } | 297 } |
311 | 298 |
312 Scope::KeyValueMap& Args::DeclaredArgumentsForToolchainLocked( | 299 Scope::KeyValueMap& Args::DeclaredArgumentsForToolchainLocked( |
313 Scope* scope) const { | 300 Scope* scope) const { |
314 lock_.AssertAcquired(); | 301 lock_.AssertAcquired(); |
315 return declared_arguments_per_toolchain_[scope->settings()]; | 302 return declared_arguments_per_toolchain_[scope->settings()]; |
316 } | 303 } |
OLD | NEW |