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/err.h" | 5 #include "tools/gn/err.h" |
6 #include "tools/gn/functions.h" | 6 #include "tools/gn/functions.h" |
7 #include "tools/gn/parse_tree.h" | 7 #include "tools/gn/parse_tree.h" |
8 #include "tools/gn/scheduler.h" | 8 #include "tools/gn/scheduler.h" |
9 #include "tools/gn/scope.h" | 9 #include "tools/gn/scope.h" |
10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 Scope block_scope(scope); | 112 Scope block_scope(scope); |
113 block_scope.SetProperty(&kToolchainPropertyKey, toolchain.get()); | 113 block_scope.SetProperty(&kToolchainPropertyKey, toolchain.get()); |
114 block->ExecuteBlockInScope(&block_scope, err); | 114 block->ExecuteBlockInScope(&block_scope, err); |
115 block_scope.SetProperty(&kToolchainPropertyKey, NULL); | 115 block_scope.SetProperty(&kToolchainPropertyKey, NULL); |
116 if (err->has_error()) | 116 if (err->has_error()) |
117 return Value(); | 117 return Value(); |
118 | 118 |
119 if (!block_scope.CheckForUnusedVars(err)) | 119 if (!block_scope.CheckForUnusedVars(err)) |
120 return Value(); | 120 return Value(); |
121 | 121 |
122 scope->settings()->build_settings()->ItemDefined(toolchain.PassAs<Item>()); | 122 // Save this target for the file. |
| 123 Scope::ItemVector* collector = scope->GetItemCollector(); |
| 124 if (!collector) { |
| 125 *err = Err(function, "Can't define a toolchain in this context."); |
| 126 return Value(); |
| 127 } |
| 128 collector->push_back(new scoped_ptr<Item>(toolchain.PassAs<Item>())); |
123 return Value(); | 129 return Value(); |
124 } | 130 } |
125 | 131 |
126 // tool ------------------------------------------------------------------------ | 132 // tool ------------------------------------------------------------------------ |
127 | 133 |
128 const char kTool[] = "tool"; | 134 const char kTool[] = "tool"; |
129 const char kTool_HelpShort[] = | 135 const char kTool_HelpShort[] = |
130 "tool: Specify arguments to a toolchain tool."; | 136 "tool: Specify arguments to a toolchain tool."; |
131 const char kTool_Help[] = | 137 const char kTool_Help[] = |
132 "tool: Specify arguments to a toolchain tool.\n" | 138 "tool: Specify arguments to a toolchain tool.\n" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 return Value(); | 307 return Value(); |
302 | 308 |
303 Scope::KeyValueMap values; | 309 Scope::KeyValueMap values; |
304 block_scope.GetCurrentScopeValues(&values); | 310 block_scope.GetCurrentScopeValues(&values); |
305 toolchain->args() = values; | 311 toolchain->args() = values; |
306 | 312 |
307 return Value(); | 313 return Value(); |
308 } | 314 } |
309 | 315 |
310 } // namespace functions | 316 } // namespace functions |
OLD | NEW |