| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "tools/gn/variables.h" | 8 #include "tools/gn/variables.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 void Args::AddArgOverrides(const Scope::KeyValueMap& overrides) { | 74 void Args::AddArgOverrides(const Scope::KeyValueMap& overrides) { |
| 75 for (Scope::KeyValueMap::const_iterator i = overrides.begin(); | 75 for (Scope::KeyValueMap::const_iterator i = overrides.begin(); |
| 76 i != overrides.end(); ++i) { | 76 i != overrides.end(); ++i) { |
| 77 overrides_[i->first] = i->second; | 77 overrides_[i->first] = i->second; |
| 78 all_overrides_[i->first] = i->second; | 78 all_overrides_[i->first] = i->second; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 const Value* Args::GetArgOverride(const char* name) const { |
| 83 Scope::KeyValueMap::const_iterator found = |
| 84 all_overrides_.find(base::StringPiece(name)); |
| 85 if (found == all_overrides_.end()) |
| 86 return NULL; |
| 87 return &found->second; |
| 88 } |
| 89 |
| 82 void Args::SetupRootScope(Scope* dest, | 90 void Args::SetupRootScope(Scope* dest, |
| 83 const Scope::KeyValueMap& toolchain_overrides) const { | 91 const Scope::KeyValueMap& toolchain_overrides) const { |
| 84 SetSystemVars(dest); | 92 SetSystemVars(dest); |
| 85 ApplyOverrides(overrides_, dest); | 93 ApplyOverrides(overrides_, dest); |
| 86 ApplyOverrides(toolchain_overrides, dest); | 94 ApplyOverrides(toolchain_overrides, dest); |
| 87 SaveOverrideRecord(toolchain_overrides); | 95 SaveOverrideRecord(toolchain_overrides); |
| 88 } | 96 } |
| 89 | 97 |
| 90 bool Args::DeclareArgs(const Scope::KeyValueMap& args, | 98 bool Args::DeclareArgs(const Scope::KeyValueMap& args, |
| 91 Scope* scope_to_set, | 99 Scope* scope_to_set, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // Do not declare the build* variants since these shouldn't be changed. | 236 // Do not declare the build* variants since these shouldn't be changed. |
| 229 // | 237 // |
| 230 // Mark these variables used so the build config file can override them | 238 // Mark these variables used so the build config file can override them |
| 231 // without geting a warning about overwriting an unused variable. | 239 // without geting a warning about overwriting an unused variable. |
| 232 declared_arguments_[variables::kOs] = os_val; | 240 declared_arguments_[variables::kOs] = os_val; |
| 233 declared_arguments_[variables::kCpuArch] = arch_val; | 241 declared_arguments_[variables::kCpuArch] = arch_val; |
| 234 dest->MarkUsed(variables::kCpuArch); | 242 dest->MarkUsed(variables::kCpuArch); |
| 235 dest->MarkUsed(variables::kOs); | 243 dest->MarkUsed(variables::kOs); |
| 236 } | 244 } |
| 237 | 245 |
| 238 | |
| 239 void Args::ApplyOverrides(const Scope::KeyValueMap& values, | 246 void Args::ApplyOverrides(const Scope::KeyValueMap& values, |
| 240 Scope* scope) const { | 247 Scope* scope) const { |
| 241 for (Scope::KeyValueMap::const_iterator i = values.begin(); | 248 for (Scope::KeyValueMap::const_iterator i = values.begin(); |
| 242 i != values.end(); ++i) | 249 i != values.end(); ++i) |
| 243 scope->SetValue(i->first, i->second, i->second.origin()); | 250 scope->SetValue(i->first, i->second, i->second.origin()); |
| 244 } | 251 } |
| 245 | 252 |
| 246 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { | 253 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { |
| 247 base::AutoLock lock(lock_); | 254 base::AutoLock lock(lock_); |
| 248 for (Scope::KeyValueMap::const_iterator i = values.begin(); | 255 for (Scope::KeyValueMap::const_iterator i = values.begin(); |
| 249 i != values.end(); ++i) | 256 i != values.end(); ++i) |
| 250 all_overrides_[i->first] = i->second; | 257 all_overrides_[i->first] = i->second; |
| 251 } | 258 } |
| OLD | NEW |