| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 "Each build arg should have one default value so we report it " | 128 "Each build arg should have one default value so we report it " |
| 129 "nicely in the\n\"gn args\" command. Please make this value " | 129 "nicely in the\n\"gn args\" command. Please make this value " |
| 130 "constant."); | 130 "constant."); |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 } else { | 133 } else { |
| 134 declared_arguments_.insert(*i); | 134 declared_arguments_.insert(*i); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Only set on the current scope to the new value if it hasn't been already | 137 // Only set on the current scope to the new value if it hasn't been already |
| 138 // set. | 138 // set. Mark the variable used so the build script can override it in |
| 139 if (!scope_to_set->GetValue(i->first)) | 139 // certain cases without getting unused value errors. |
| 140 if (!scope_to_set->GetValue(i->first)) { |
| 140 scope_to_set->SetValue(i->first, i->second, i->second.origin()); | 141 scope_to_set->SetValue(i->first, i->second, i->second.origin()); |
| 142 scope_to_set->MarkUsed(i->first); |
| 143 } |
| 141 } | 144 } |
| 142 | 145 |
| 143 return true; | 146 return true; |
| 144 } | 147 } |
| 145 | 148 |
| 146 bool Args::VerifyAllOverridesUsed(Err* err) const { | 149 bool Args::VerifyAllOverridesUsed(Err* err) const { |
| 147 base::AutoLock lock(lock_); | 150 base::AutoLock lock(lock_); |
| 148 | 151 |
| 149 for (Scope::KeyValueMap::const_iterator i = all_overrides_.begin(); | 152 for (Scope::KeyValueMap::const_iterator i = all_overrides_.begin(); |
| 150 i != all_overrides_.end(); ++i) { | 153 i != all_overrides_.end(); ++i) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 i != values.end(); ++i) | 240 i != values.end(); ++i) |
| 238 scope->SetValue(i->first, i->second, i->second.origin()); | 241 scope->SetValue(i->first, i->second, i->second.origin()); |
| 239 } | 242 } |
| 240 | 243 |
| 241 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { | 244 void Args::SaveOverrideRecord(const Scope::KeyValueMap& values) const { |
| 242 base::AutoLock lock(lock_); | 245 base::AutoLock lock(lock_); |
| 243 for (Scope::KeyValueMap::const_iterator i = values.begin(); | 246 for (Scope::KeyValueMap::const_iterator i = values.begin(); |
| 244 i != values.end(); ++i) | 247 i != values.end(); ++i) |
| 245 all_overrides_[i->first] = i->second; | 248 all_overrides_[i->first] = i->second; |
| 246 } | 249 } |
| OLD | NEW |