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 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 key_suffixes = ['=', '+', '?', '!', '/'] | 2200 key_suffixes = ['=', '+', '?', '!', '/'] |
2201 | 2201 |
2202 build_file = gyp.common.BuildFile(target) | 2202 build_file = gyp.common.BuildFile(target) |
2203 | 2203 |
2204 # Provide a single configuration by default if none exists. | 2204 # Provide a single configuration by default if none exists. |
2205 # TODO(mark): Signal an error if default_configurations exists but | 2205 # TODO(mark): Signal an error if default_configurations exists but |
2206 # configurations does not. | 2206 # configurations does not. |
2207 if not 'configurations' in target_dict: | 2207 if not 'configurations' in target_dict: |
2208 target_dict['configurations'] = {'Default': {}} | 2208 target_dict['configurations'] = {'Default': {}} |
2209 if not 'default_configuration' in target_dict: | 2209 if not 'default_configuration' in target_dict: |
2210 concrete = [i for i in target_dict['configurations'].iterkeys() | 2210 concrete = [i for (i, config) in target_dict['configurations'].iteritems() |
2211 if not target_dict['configurations'][i].get('abstract')] | 2211 if not config.get('abstract')] |
2212 target_dict['default_configuration'] = sorted(concrete)[0] | 2212 target_dict['default_configuration'] = sorted(concrete)[0] |
2213 | 2213 |
2214 merged_configurations = {} | 2214 merged_configurations = {} |
2215 for configuration in target_dict['configurations'].keys(): | 2215 configs = target_dict['configurations'] |
2216 old_configuration_dict = target_dict['configurations'][configuration] | 2216 for (configuration, old_configuration_dict) in configs.iteritems(): |
2217 # Skip abstract configurations (saves work only). | 2217 # Skip abstract configurations (saves work only). |
2218 if old_configuration_dict.get('abstract'): | 2218 if old_configuration_dict.get('abstract'): |
2219 continue | 2219 continue |
2220 # Configurations inherit (most) settings from the enclosing target scope. | 2220 # Configurations inherit (most) settings from the enclosing target scope. |
2221 # Get the inheritance relationship right by making a copy of the target | 2221 # Get the inheritance relationship right by making a copy of the target |
2222 # dict. | 2222 # dict. |
2223 new_configuration_dict = copy.deepcopy(target_dict) | 2223 new_configuration_dict = {} |
2224 | 2224 for (key, target_val) in target_dict.iteritems(): |
2225 # Take out the bits that don't belong in a "configurations" section. | |
2226 # Since configuration setup is done before conditional, exclude, and rules | |
2227 # processing, be careful with handling of the suffix characters used in | |
2228 # those phases. | |
2229 delete_keys = [] | |
2230 for key in new_configuration_dict: | |
2231 key_ext = key[-1:] | 2225 key_ext = key[-1:] |
2232 if key_ext in key_suffixes: | 2226 if key_ext in key_suffixes: |
2233 key_base = key[:-1] | 2227 key_base = key[:-1] |
2234 else: | 2228 else: |
2235 key_base = key | 2229 key_base = key |
2236 if key_base in non_configuration_keys: | 2230 if not key_base in non_configuration_keys: |
2237 delete_keys.append(key) | 2231 new_configuration_dict[key] = copy.deepcopy(target_val) |
2238 | |
2239 for key in delete_keys: | |
2240 del new_configuration_dict[key] | |
2241 | 2232 |
2242 # Merge in configuration (with all its parents first). | 2233 # Merge in configuration (with all its parents first). |
2243 MergeConfigWithInheritance(new_configuration_dict, build_file, | 2234 MergeConfigWithInheritance(new_configuration_dict, build_file, |
2244 target_dict, configuration, []) | 2235 target_dict, configuration, []) |
2245 | 2236 |
2246 merged_configurations[configuration] = new_configuration_dict | 2237 merged_configurations[configuration] = new_configuration_dict |
2247 | 2238 |
2248 # Put the new configurations back into the target dict as a configuration. | 2239 # Put the new configurations back into the target dict as a configuration. |
2249 for configuration in merged_configurations.keys(): | 2240 for configuration in merged_configurations.keys(): |
2250 target_dict['configurations'][configuration] = ( | 2241 target_dict['configurations'][configuration] = ( |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 ValidateRunAsInTarget(target, target_dict, build_file) | 2850 ValidateRunAsInTarget(target, target_dict, build_file) |
2860 ValidateActionsInTarget(target, target_dict, build_file) | 2851 ValidateActionsInTarget(target, target_dict, build_file) |
2861 | 2852 |
2862 # Generators might not expect ints. Turn them into strs. | 2853 # Generators might not expect ints. Turn them into strs. |
2863 TurnIntIntoStrInDict(data) | 2854 TurnIntIntoStrInDict(data) |
2864 | 2855 |
2865 # TODO(mark): Return |data| for now because the generator needs a list of | 2856 # TODO(mark): Return |data| for now because the generator needs a list of |
2866 # build files that came in. In the future, maybe it should just accept | 2857 # build files that came in. In the future, maybe it should just accept |
2867 # a list, and not the whole data dict. | 2858 # a list, and not the whole data dict. |
2868 return [flat_list, targets, data] | 2859 return [flat_list, targets, data] |
OLD | NEW |