Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 from compiler.ast import Const | 7 from compiler.ast import Const |
| 8 from compiler.ast import Dict | 8 from compiler.ast import Dict |
| 9 from compiler.ast import Discard | 9 from compiler.ast import Discard |
| 10 from compiler.ast import List | 10 from compiler.ast import List |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 """Make dependency links fully-qualified relative to the current directory. | 1035 """Make dependency links fully-qualified relative to the current directory. |
| 1036 | 1036 |
| 1037 |targets| is a dict mapping fully-qualified target names to their target | 1037 |targets| is a dict mapping fully-qualified target names to their target |
| 1038 dicts. For each target in this dict, keys known to contain dependency | 1038 dicts. For each target in this dict, keys known to contain dependency |
| 1039 links are examined, and any dependencies referenced will be rewritten | 1039 links are examined, and any dependencies referenced will be rewritten |
| 1040 so that they are fully-qualified and relative to the current directory. | 1040 so that they are fully-qualified and relative to the current directory. |
| 1041 All rewritten dependencies are suitable for use as keys to |targets| or a | 1041 All rewritten dependencies are suitable for use as keys to |targets| or a |
| 1042 similar dict. | 1042 similar dict. |
| 1043 """ | 1043 """ |
| 1044 | 1044 |
| 1045 all_dependency_sections = [dep + op | |
| 1046 for dep in dependency_sections | |
| 1047 for op in ('', '!', '/')] | |
| 1048 | |
| 1045 for target, target_dict in targets.iteritems(): | 1049 for target, target_dict in targets.iteritems(): |
| 1046 target_build_file = gyp.common.BuildFile(target) | 1050 target_build_file = gyp.common.BuildFile(target) |
| 1047 toolset = target_dict['toolset'] | 1051 toolset = target_dict['toolset'] |
| 1048 for dependency_key in dependency_sections: | 1052 for dependency_key in all_dependency_sections: |
| 1049 dependencies = target_dict.get(dependency_key, []) | 1053 dependencies = target_dict.get(dependency_key, []) |
| 1050 for index in xrange(0, len(dependencies)): | 1054 for index in xrange(0, len(dependencies)): |
| 1051 dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget( | 1055 dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget( |
| 1052 target_build_file, dependencies[index], toolset) | 1056 target_build_file, dependencies[index], toolset) |
| 1053 global multiple_toolsets | 1057 global multiple_toolsets |
| 1054 if not multiple_toolsets: | 1058 if not multiple_toolsets: |
| 1055 # Ignore toolset specification in the dependency if it is specified. | 1059 # Ignore toolset specification in the dependency if it is specified. |
| 1056 dep_toolset = toolset | 1060 dep_toolset = toolset |
| 1057 dependency = gyp.common.QualifiedTarget(dep_file, | 1061 dependency = gyp.common.QualifiedTarget(dep_file, |
| 1058 dep_target, | 1062 dep_target, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 # Set up the dependency links. Targets that have no dependencies are treated | 1350 # Set up the dependency links. Targets that have no dependencies are treated |
| 1347 # as dependent on root_node. | 1351 # as dependent on root_node. |
| 1348 root_node = DependencyGraphNode(None) | 1352 root_node = DependencyGraphNode(None) |
| 1349 for target, spec in targets.iteritems(): | 1353 for target, spec in targets.iteritems(): |
| 1350 target_node = dependency_nodes[target] | 1354 target_node = dependency_nodes[target] |
| 1351 target_build_file = gyp.common.BuildFile(target) | 1355 target_build_file = gyp.common.BuildFile(target) |
| 1352 if not 'dependencies' in spec or len(spec['dependencies']) == 0: | 1356 if not 'dependencies' in spec or len(spec['dependencies']) == 0: |
| 1353 target_node.dependencies = [root_node] | 1357 target_node.dependencies = [root_node] |
| 1354 root_node.dependents.append(target_node) | 1358 root_node.dependents.append(target_node) |
| 1355 else: | 1359 else: |
| 1356 dependencies = spec['dependencies'] | 1360 deps_dict = {} |
| 1361 for op in ('', '!', '/'): | |
| 1362 key = 'dependencies' + op | |
| 1363 if key in spec and len(spec[key]) > 0: | |
| 1364 deps_dict[key] = spec[key] | |
| 1365 ProcessListFiltersInDict(target, deps_dict) | |
| 1366 | |
| 1367 dependencies = deps_dict['dependencies'] | |
| 1357 for index in xrange(0, len(dependencies)): | 1368 for index in xrange(0, len(dependencies)): |
| 1358 try: | 1369 try: |
| 1359 dependency = dependencies[index] | 1370 dependency = dependencies[index] |
| 1360 dependency_node = dependency_nodes[dependency] | 1371 dependency_node = dependency_nodes[dependency] |
| 1361 target_node.dependencies.append(dependency_node) | 1372 target_node.dependencies.append(dependency_node) |
| 1362 dependency_node.dependents.append(target_node) | 1373 dependency_node.dependents.append(target_node) |
| 1363 except KeyError, e: | 1374 except KeyError, e: |
| 1364 gyp.common.ExceptionAppend(e, | 1375 gyp.common.ExceptionAppend(e, |
| 1365 'while trying to load target %s' % target) | 1376 'while trying to load target %s' % target) |
| 1366 raise | 1377 raise |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1811 """Process regular expression and exclusion-based filters on lists. | 1822 """Process regular expression and exclusion-based filters on lists. |
| 1812 | 1823 |
| 1813 An exclusion list is in a dict key named with a trailing "!", like | 1824 An exclusion list is in a dict key named with a trailing "!", like |
| 1814 "sources!". Every item in such a list is removed from the associated | 1825 "sources!". Every item in such a list is removed from the associated |
| 1815 main list, which in this example, would be "sources". Removed items are | 1826 main list, which in this example, would be "sources". Removed items are |
| 1816 placed into a "sources_excluded" list in the dict. | 1827 placed into a "sources_excluded" list in the dict. |
| 1817 | 1828 |
| 1818 Regular expression (regex) filters are contained in dict keys named with a | 1829 Regular expression (regex) filters are contained in dict keys named with a |
| 1819 trailing "/", such as "sources/" to operate on the "sources" list. Regex | 1830 trailing "/", such as "sources/" to operate on the "sources" list. Regex |
| 1820 filters in a dict take the form: | 1831 filters in a dict take the form: |
| 1821 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'] ], | 1832 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'], |
| 1822 ['include', '_mac\\.cc$'] ], | 1833 ['include', '_mac\\.cc$'] ], |
| 1823 The first filter says to exclude all files ending in _linux.cc, _mac.cc, and | 1834 The first filter says to exclude all files ending in _linux.cc, _mac.cc, and |
| 1824 _win.cc. The second filter then includes all files ending in _mac.cc that | 1835 _win.cc. The second filter then includes all files ending in _mac.cc that |
| 1825 are now or were once in the "sources" list. Items matching an "exclude" | 1836 are now or were once in the "sources" list. Items matching an "exclude" |
| 1826 filter are subject to the same processing as would occur if they were listed | 1837 filter are subject to the same processing as would occur if they were listed |
| 1827 by name in an exclusion list (ending in "!"). Items matching an "include" | 1838 by name in an exclusion list (ending in "!"). Items matching an "include" |
| 1828 filter are brought back into the main list if previously excluded by an | 1839 filter are brought back into the main list if previously excluded by an |
| 1829 exclusion list or exclusion regex filter. Subsequent matching "exclude" | 1840 exclusion list or exclusion regex filter. Subsequent matching "exclude" |
| 1830 patterns can still cause items to be excluded after matching an "include". | 1841 patterns can still cause items to be excluded after matching an "include". |
| 1831 """ | 1842 """ |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2221 build_file) | 2232 build_file) |
| 2222 | 2233 |
| 2223 # Move everything that can go into a "configurations" section into one. | 2234 # Move everything that can go into a "configurations" section into one. |
| 2224 for target in flat_list: | 2235 for target in flat_list: |
| 2225 target_dict = targets[target] | 2236 target_dict = targets[target] |
| 2226 SetUpConfigurations(target, target_dict) | 2237 SetUpConfigurations(target, target_dict) |
| 2227 | 2238 |
| 2228 # Apply exclude (!) and regex (/) list filters. | 2239 # Apply exclude (!) and regex (/) list filters. |
| 2229 for target in flat_list: | 2240 for target in flat_list: |
| 2230 target_dict = targets[target] | 2241 target_dict = targets[target] |
| 2231 ProcessListFiltersInDict(target, target_dict) | 2242 ProcessListFiltersInDict(target, target_dict) |
|
Mark Mentovai
2011/04/26 19:12:24
This will process the filters on dependencies agai
Yuki Shiino
2011/04/27 08:45:37
Done.
I changed the code to remove '!' and '/' key
| |
| 2232 | 2243 |
| 2233 # Make sure that the rules make sense, and build up rule_sources lists as | 2244 # Make sure that the rules make sense, and build up rule_sources lists as |
| 2234 # needed. Not all generators will need to use the rule_sources lists, but | 2245 # needed. Not all generators will need to use the rule_sources lists, but |
| 2235 # some may, and it seems best to build the list in a common spot. | 2246 # some may, and it seems best to build the list in a common spot. |
| 2236 # Also validate actions and run_as elements in targets. | 2247 # Also validate actions and run_as elements in targets. |
| 2237 for target in flat_list: | 2248 for target in flat_list: |
| 2238 target_dict = targets[target] | 2249 target_dict = targets[target] |
| 2239 build_file = gyp.common.BuildFile(target) | 2250 build_file = gyp.common.BuildFile(target) |
| 2240 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) | 2251 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) |
| 2241 ValidateRunAsInTarget(target, target_dict, build_file) | 2252 ValidateRunAsInTarget(target, target_dict, build_file) |
| 2242 ValidateActionsInTarget(target, target_dict, build_file) | 2253 ValidateActionsInTarget(target, target_dict, build_file) |
| 2243 | 2254 |
| 2244 # Generators might not expect ints. Turn them into strs. | 2255 # Generators might not expect ints. Turn them into strs. |
| 2245 TurnIntIntoStrInDict(data) | 2256 TurnIntIntoStrInDict(data) |
| 2246 | 2257 |
| 2247 # TODO(mark): Return |data| for now because the generator needs a list of | 2258 # TODO(mark): Return |data| for now because the generator needs a list of |
| 2248 # build files that came in. In the future, maybe it should just accept | 2259 # build files that came in. In the future, maybe it should just accept |
| 2249 # a list, and not the whole data dict. | 2260 # a list, and not the whole data dict. |
| 2250 return [flat_list, targets, data] | 2261 return [flat_list, targets, data] |
| OLD | NEW |