| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 def ProcessToolsetsInDict(data): | 295 def ProcessToolsetsInDict(data): |
| 296 if 'targets' in data: | 296 if 'targets' in data: |
| 297 target_list = data['targets'] | 297 target_list = data['targets'] |
| 298 new_target_list = [] | 298 new_target_list = [] |
| 299 for target in target_list: | 299 for target in target_list: |
| 300 # If this target already has an explicit 'toolset', and no 'toolsets' | 300 # If this target already has an explicit 'toolset', and no 'toolsets' |
| 301 # list, don't modify it further. | 301 # list, don't modify it further. |
| 302 if 'toolset' in target and 'toolsets' not in target: | 302 if 'toolset' in target and 'toolsets' not in target: |
| 303 new_target_list.append(target) | 303 new_target_list.append(target) |
| 304 continue | 304 continue |
| 305 global multiple_toolsets | |
| 306 if multiple_toolsets: | 305 if multiple_toolsets: |
| 307 toolsets = target.get('toolsets', ['target']) | 306 toolsets = target.get('toolsets', ['target']) |
| 308 else: | 307 else: |
| 309 toolsets = ['target'] | 308 toolsets = ['target'] |
| 310 # Make sure this 'toolsets' definition is only processed once. | 309 # Make sure this 'toolsets' definition is only processed once. |
| 311 if 'toolsets' in target: | 310 if 'toolsets' in target: |
| 312 del target['toolsets'] | 311 del target['toolsets'] |
| 313 if len(toolsets) > 0: | 312 if len(toolsets) > 0: |
| 314 # Optimization: only do copies if more than one toolset is specified. | 313 # Optimization: only do copies if more than one toolset is specified. |
| 315 for build in toolsets[1:]: | 314 for build in toolsets[1:]: |
| 316 new_target = copy.deepcopy(target) | 315 new_target = copy.deepcopy(target) |
| 317 new_target['toolset'] = build | 316 new_target['toolset'] = build |
| 318 new_target_list.append(new_target) | 317 new_target_list.append(new_target) |
| 319 target['toolset'] = toolsets[0] | 318 target['toolset'] = toolsets[0] |
| 320 new_target_list.append(target) | 319 new_target_list.append(target) |
| 321 data['targets'] = new_target_list | 320 data['targets'] = new_target_list |
| 322 if 'conditions' in data: | 321 if 'conditions' in data: |
| 323 for condition in data['conditions']: | 322 for condition in data['conditions']: |
| 324 if isinstance(condition, list): | 323 if isinstance(condition, list): |
| 325 for condition_dict in condition[1:]: | 324 for condition_dict in condition[1:]: |
| 326 ProcessToolsetsInDict(condition_dict) | 325 ProcessToolsetsInDict(condition_dict) |
| 327 | 326 |
| 328 | 327 |
| 329 # TODO(mark): I don't love this name. It just means that it's going to load | 328 # TODO(mark): I don't love this name. It just means that it's going to load |
| 330 # a build file that contains targets and is expected to provide a targets dict | 329 # a build file that contains targets and is expected to provide a targets dict |
| 331 # that contains the targets... | 330 # that contains the targets... |
| 332 def LoadTargetBuildFile(build_file_path, data, aux_data, variables, includes, | 331 def LoadTargetBuildFile(build_file_path, data, aux_data, variables, includes, |
| 333 depth, check): | 332 depth, check): |
| 334 global absolute_build_file_paths | |
| 335 | |
| 336 # If depth is set, predefine the DEPTH variable to be a relative path from | 333 # If depth is set, predefine the DEPTH variable to be a relative path from |
| 337 # this build file's directory to the directory identified by depth. | 334 # this build file's directory to the directory identified by depth. |
| 338 if depth: | 335 if depth: |
| 339 # TODO(dglazkov) The backslash/forward-slash replacement at the end is a | 336 # TODO(dglazkov) The backslash/forward-slash replacement at the end is a |
| 340 # temporary measure. This should really be addressed by keeping all paths | 337 # temporary measure. This should really be addressed by keeping all paths |
| 341 # in POSIX until actual project generation. | 338 # in POSIX until actual project generation. |
| 342 d = gyp.common.RelativePath(depth, os.path.dirname(build_file_path)) | 339 d = gyp.common.RelativePath(depth, os.path.dirname(build_file_path)) |
| 343 if d == '': | 340 if d == '': |
| 344 variables['DEPTH'] = '.' | 341 variables['DEPTH'] = '.' |
| 345 else: | 342 else: |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 for op in ('', '!', '/')] | 1132 for op in ('', '!', '/')] |
| 1136 | 1133 |
| 1137 for target, target_dict in targets.iteritems(): | 1134 for target, target_dict in targets.iteritems(): |
| 1138 target_build_file = gyp.common.BuildFile(target) | 1135 target_build_file = gyp.common.BuildFile(target) |
| 1139 toolset = target_dict['toolset'] | 1136 toolset = target_dict['toolset'] |
| 1140 for dependency_key in all_dependency_sections: | 1137 for dependency_key in all_dependency_sections: |
| 1141 dependencies = target_dict.get(dependency_key, []) | 1138 dependencies = target_dict.get(dependency_key, []) |
| 1142 for index in xrange(0, len(dependencies)): | 1139 for index in xrange(0, len(dependencies)): |
| 1143 dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget( | 1140 dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget( |
| 1144 target_build_file, dependencies[index], toolset) | 1141 target_build_file, dependencies[index], toolset) |
| 1145 global multiple_toolsets | |
| 1146 if not multiple_toolsets: | 1142 if not multiple_toolsets: |
| 1147 # Ignore toolset specification in the dependency if it is specified. | 1143 # Ignore toolset specification in the dependency if it is specified. |
| 1148 dep_toolset = toolset | 1144 dep_toolset = toolset |
| 1149 dependency = gyp.common.QualifiedTarget(dep_file, | 1145 dependency = gyp.common.QualifiedTarget(dep_file, |
| 1150 dep_target, | 1146 dep_target, |
| 1151 dep_toolset) | 1147 dep_toolset) |
| 1152 dependencies[index] = dependency | 1148 dependencies[index] = dependency |
| 1153 | 1149 |
| 1154 # Make sure anything appearing in a list other than "dependencies" also | 1150 # Make sure anything appearing in a list other than "dependencies" also |
| 1155 # appears in the "dependencies" list. | 1151 # appears in the "dependencies" list. |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 # Merge it into the new config. | 1867 # Merge it into the new config. |
| 1872 MergeDicts(new_configuration_dict, configuration_dict, | 1868 MergeDicts(new_configuration_dict, configuration_dict, |
| 1873 build_file, build_file) | 1869 build_file, build_file) |
| 1874 | 1870 |
| 1875 # Drop abstract. | 1871 # Drop abstract. |
| 1876 if 'abstract' in new_configuration_dict: | 1872 if 'abstract' in new_configuration_dict: |
| 1877 del new_configuration_dict['abstract'] | 1873 del new_configuration_dict['abstract'] |
| 1878 | 1874 |
| 1879 | 1875 |
| 1880 def SetUpConfigurations(target, target_dict): | 1876 def SetUpConfigurations(target, target_dict): |
| 1881 global non_configuration_keys | |
| 1882 # key_suffixes is a list of key suffixes that might appear on key names. | 1877 # key_suffixes is a list of key suffixes that might appear on key names. |
| 1883 # These suffixes are handled in conditional evaluations (for =, +, and ?) | 1878 # These suffixes are handled in conditional evaluations (for =, +, and ?) |
| 1884 # and rules/exclude processing (for ! and /). Keys with these suffixes | 1879 # and rules/exclude processing (for ! and /). Keys with these suffixes |
| 1885 # should be treated the same as keys without. | 1880 # should be treated the same as keys without. |
| 1886 key_suffixes = ['=', '+', '?', '!', '/'] | 1881 key_suffixes = ['=', '+', '?', '!', '/'] |
| 1887 | 1882 |
| 1888 build_file = gyp.common.BuildFile(target) | 1883 build_file = gyp.common.BuildFile(target) |
| 1889 | 1884 |
| 1890 # Provide a single configuration by default if none exists. | 1885 # Provide a single configuration by default if none exists. |
| 1891 # TODO(mark): Signal an error if default_configurations exists but | 1886 # TODO(mark): Signal an error if default_configurations exists but |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 | 2054 |
| 2060 if action == 'exclude': | 2055 if action == 'exclude': |
| 2061 # This item matches an exclude regex, so set its value to 0 (exclude). | 2056 # This item matches an exclude regex, so set its value to 0 (exclude). |
| 2062 action_value = 0 | 2057 action_value = 0 |
| 2063 elif action == 'include': | 2058 elif action == 'include': |
| 2064 # This item matches an include regex, so set its value to 1 (include). | 2059 # This item matches an include regex, so set its value to 1 (include). |
| 2065 action_value = 1 | 2060 action_value = 1 |
| 2066 else: | 2061 else: |
| 2067 # This is an action that doesn't make any sense. | 2062 # This is an action that doesn't make any sense. |
| 2068 raise ValueError, 'Unrecognized action ' + action + ' in ' + name + \ | 2063 raise ValueError, 'Unrecognized action ' + action + ' in ' + name + \ |
| 2069 ' key ' + key | 2064 ' key ' + regex_key |
| 2070 | 2065 |
| 2071 for index in xrange(0, len(the_list)): | 2066 for index in xrange(0, len(the_list)): |
| 2072 list_item = the_list[index] | 2067 list_item = the_list[index] |
| 2073 if list_actions[index] == action_value: | 2068 if list_actions[index] == action_value: |
| 2074 # Even if the regex matches, nothing will change so continue (regex | 2069 # Even if the regex matches, nothing will change so continue (regex |
| 2075 # searches are expensive). | 2070 # searches are expensive). |
| 2076 continue | 2071 continue |
| 2077 if pattern_re.search(list_item): | 2072 if pattern_re.search(list_item): |
| 2078 # Regular expression match. | 2073 # Regular expression match. |
| 2079 list_actions[index] = action_value | 2074 list_actions[index] = action_value |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2481 ValidateRunAsInTarget(target, target_dict, build_file) | 2476 ValidateRunAsInTarget(target, target_dict, build_file) |
| 2482 ValidateActionsInTarget(target, target_dict, build_file) | 2477 ValidateActionsInTarget(target, target_dict, build_file) |
| 2483 | 2478 |
| 2484 # Generators might not expect ints. Turn them into strs. | 2479 # Generators might not expect ints. Turn them into strs. |
| 2485 TurnIntIntoStrInDict(data) | 2480 TurnIntIntoStrInDict(data) |
| 2486 | 2481 |
| 2487 # TODO(mark): Return |data| for now because the generator needs a list of | 2482 # TODO(mark): Return |data| for now because the generator needs a list of |
| 2488 # build files that came in. In the future, maybe it should just accept | 2483 # build files that came in. In the future, maybe it should just accept |
| 2489 # a list, and not the whole data dict. | 2484 # a list, and not the whole data dict. |
| 2490 return [flat_list, targets, data] | 2485 return [flat_list, targets, data] |
| OLD | NEW |