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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1811 """Process regular expression and exclusion-based filters on lists. | 1815 """Process regular expression and exclusion-based filters on lists. |
1812 | 1816 |
1813 An exclusion list is in a dict key named with a trailing "!", like | 1817 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 | 1818 "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 | 1819 main list, which in this example, would be "sources". Removed items are |
1816 placed into a "sources_excluded" list in the dict. | 1820 placed into a "sources_excluded" list in the dict. |
1817 | 1821 |
1818 Regular expression (regex) filters are contained in dict keys named with a | 1822 Regular expression (regex) filters are contained in dict keys named with a |
1819 trailing "/", such as "sources/" to operate on the "sources" list. Regex | 1823 trailing "/", such as "sources/" to operate on the "sources" list. Regex |
1820 filters in a dict take the form: | 1824 filters in a dict take the form: |
1821 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'] ], | 1825 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'], |
1822 ['include', '_mac\\.cc$'] ], | 1826 ['include', '_mac\\.cc$'] ], |
1823 The first filter says to exclude all files ending in _linux.cc, _mac.cc, and | 1827 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 | 1828 _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" | 1829 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 | 1830 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" | 1831 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 | 1832 filter are brought back into the main list if previously excluded by an |
1829 exclusion list or exclusion regex filter. Subsequent matching "exclude" | 1833 exclusion list or exclusion regex filter. Subsequent matching "exclude" |
1830 patterns can still cause items to be excluded after matching an "include". | 1834 patterns can still cause items to be excluded after matching an "include". |
1831 """ | 1835 """ |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2178 | 2182 |
2179 # Build a dict to access each target's subdict by qualified name. | 2183 # Build a dict to access each target's subdict by qualified name. |
2180 targets = BuildTargetsDict(data) | 2184 targets = BuildTargetsDict(data) |
2181 | 2185 |
2182 # Fully qualify all dependency links. | 2186 # Fully qualify all dependency links. |
2183 QualifyDependencies(targets) | 2187 QualifyDependencies(targets) |
2184 | 2188 |
2185 # Expand dependencies specified as build_file:*. | 2189 # Expand dependencies specified as build_file:*. |
2186 ExpandWildcardDependencies(targets, data) | 2190 ExpandWildcardDependencies(targets, data) |
2187 | 2191 |
2192 # Apply exclude (!) and regex (/) list filters only for dependency_sections. | |
2193 for target_name, target_dict in targets.iteritems(): | |
2194 tmp_dict = {} | |
2195 for key_base in dependency_sections: | |
2196 for op in ('', '!', '/'): | |
2197 key = key_base + op | |
2198 if key in target_dict and len(target_dict[key]) > 0: | |
Mark Mentovai
2011/05/04 15:04:35
Get rid of the len check, I think this will be fin
Yuki Shiino
2011/05/04 15:47:48
Done.
| |
2199 tmp_dict[key] = target_dict[key] | |
2200 del target_dict[key] # Remove the key applied. | |
Mark Mentovai
2011/05/04 15:04:35
This comment doesn’t make any sense to me. I’m not
Yuki Shiino
2011/05/04 15:47:48
Done.
| |
2201 ProcessListFiltersInDict(target_name, tmp_dict) | |
2202 # Write the results back to |spec|. | |
2203 for key in tmp_dict: | |
2204 target_dict[key] = tmp_dict[key] | |
2205 | |
2188 if circular_check: | 2206 if circular_check: |
2189 # Make sure that any targets in a.gyp don't contain dependencies in other | 2207 # Make sure that any targets in a.gyp don't contain dependencies in other |
2190 # .gyp files that further depend on a.gyp. | 2208 # .gyp files that further depend on a.gyp. |
2191 VerifyNoGYPFileCircularDependencies(targets) | 2209 VerifyNoGYPFileCircularDependencies(targets) |
2192 | 2210 |
2193 [dependency_nodes, flat_list] = BuildDependencyList(targets) | 2211 [dependency_nodes, flat_list] = BuildDependencyList(targets) |
2194 | 2212 |
2195 # Check that no two targets in the same directory have the same name. | 2213 # Check that no two targets in the same directory have the same name. |
2196 VerifyNoCollidingTargets(flat_list) | 2214 VerifyNoCollidingTargets(flat_list) |
2197 | |
2198 | 2215 |
2199 # Handle dependent settings of various types. | 2216 # Handle dependent settings of various types. |
2200 for settings_type in ['all_dependent_settings', | 2217 for settings_type in ['all_dependent_settings', |
2201 'direct_dependent_settings', | 2218 'direct_dependent_settings', |
2202 'link_settings']: | 2219 'link_settings']: |
2203 DoDependentSettings(settings_type, flat_list, targets, dependency_nodes) | 2220 DoDependentSettings(settings_type, flat_list, targets, dependency_nodes) |
2204 | 2221 |
2205 # Take out the dependent settings now that they've been published to all | 2222 # Take out the dependent settings now that they've been published to all |
2206 # of the targets that require them. | 2223 # of the targets that require them. |
2207 for target in flat_list: | 2224 for target in flat_list: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2241 ValidateRunAsInTarget(target, target_dict, build_file) | 2258 ValidateRunAsInTarget(target, target_dict, build_file) |
2242 ValidateActionsInTarget(target, target_dict, build_file) | 2259 ValidateActionsInTarget(target, target_dict, build_file) |
2243 | 2260 |
2244 # Generators might not expect ints. Turn them into strs. | 2261 # Generators might not expect ints. Turn them into strs. |
2245 TurnIntIntoStrInDict(data) | 2262 TurnIntIntoStrInDict(data) |
2246 | 2263 |
2247 # TODO(mark): Return |data| for now because the generator needs a list of | 2264 # 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 | 2265 # build files that came in. In the future, maybe it should just accept |
2249 # a list, and not the whole data dict. | 2266 # a list, and not the whole data dict. |
2250 return [flat_list, targets, data] | 2267 return [flat_list, targets, data] |
OLD | NEW |