OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. 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 from compiler.ast import Const | 5 from compiler.ast import Const |
6 from compiler.ast import Dict | 6 from compiler.ast import Dict |
7 from compiler.ast import Discard | 7 from compiler.ast import Discard |
8 from compiler.ast import List | 8 from compiler.ast import List |
9 from compiler.ast import Module | 9 from compiler.ast import Module |
10 from compiler.ast import Node | 10 from compiler.ast import Node |
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 def ValidateActionsInTarget(target, target_dict, build_file): | 2263 def ValidateActionsInTarget(target, target_dict, build_file): |
2264 '''Validates the inputs to the actions in a target.''' | 2264 '''Validates the inputs to the actions in a target.''' |
2265 target_name = target_dict.get('target_name') | 2265 target_name = target_dict.get('target_name') |
2266 actions = target_dict.get('actions', []) | 2266 actions = target_dict.get('actions', []) |
2267 for action in actions: | 2267 for action in actions: |
2268 action_name = action.get('action_name') | 2268 action_name = action.get('action_name') |
2269 if not action_name: | 2269 if not action_name: |
2270 raise Exception("Anonymous action in target %s. " | 2270 raise Exception("Anonymous action in target %s. " |
2271 "An action must have an 'action_name' field." % | 2271 "An action must have an 'action_name' field." % |
2272 target_name) | 2272 target_name) |
2273 inputs = action.get('inputs', []) | 2273 inputs = action.get('inputs', None) |
| 2274 if inputs is None: |
| 2275 raise Exception('Action in target %s has no inputs.' % target_name) |
2274 action_command = action.get('action') | 2276 action_command = action.get('action') |
2275 if action_command and not action_command[0]: | 2277 if action_command and not action_command[0]: |
2276 raise Exception("Empty action as command in target %s." % target_name) | 2278 raise Exception("Empty action as command in target %s." % target_name) |
2277 | 2279 |
2278 | 2280 |
2279 def TurnIntIntoStrInDict(the_dict): | 2281 def TurnIntIntoStrInDict(the_dict): |
2280 """Given dict the_dict, recursively converts all integers into strings. | 2282 """Given dict the_dict, recursively converts all integers into strings. |
2281 """ | 2283 """ |
2282 # Use items instead of iteritems because there's no need to try to look at | 2284 # Use items instead of iteritems because there's no need to try to look at |
2283 # reinserted keys and their associated values. | 2285 # reinserted keys and their associated values. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 ValidateRunAsInTarget(target, target_dict, build_file) | 2481 ValidateRunAsInTarget(target, target_dict, build_file) |
2480 ValidateActionsInTarget(target, target_dict, build_file) | 2482 ValidateActionsInTarget(target, target_dict, build_file) |
2481 | 2483 |
2482 # Generators might not expect ints. Turn them into strs. | 2484 # Generators might not expect ints. Turn them into strs. |
2483 TurnIntIntoStrInDict(data) | 2485 TurnIntIntoStrInDict(data) |
2484 | 2486 |
2485 # TODO(mark): Return |data| for now because the generator needs a list of | 2487 # TODO(mark): Return |data| for now because the generator needs a list of |
2486 # build files that came in. In the future, maybe it should just accept | 2488 # build files that came in. In the future, maybe it should just accept |
2487 # a list, and not the whole data dict. | 2489 # a list, and not the whole data dict. |
2488 return [flat_list, targets, data] | 2490 return [flat_list, targets, data] |
OLD | NEW |