Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: pylib/gyp/input.py

Issue 6904020: This change supports '!' and '/' operators for 'dependencies' section. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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:
1360 # Apply the list filters ('!' and '/') to dependencies list.
1361 deps_dict = {}
1362 for op in ('', '!', '/'):
1363 key = 'dependencies' + op
1364 if key in spec and len(spec[key]) > 0:
1365 deps_dict[key] = spec[key]
1366 del spec[key] # Remove the key applied.
1367 ProcessListFiltersInDict(target, deps_dict)
1368 # Write the result back to |spec|.
1369 spec['dependencies'] = deps_dict['dependencies']
Mark Mentovai 2011/05/03 18:32:35 1. I don’t want to set spec['dependencies'] at all
Yuki Shiino 2011/05/04 10:52:11 I've changed the way, but I explain what I thought
1370
1356 dependencies = spec['dependencies'] 1371 dependencies = spec['dependencies']
1357 for index in xrange(0, len(dependencies)): 1372 for index in xrange(0, len(dependencies)):
1358 try: 1373 try:
1359 dependency = dependencies[index] 1374 dependency = dependencies[index]
1360 dependency_node = dependency_nodes[dependency] 1375 dependency_node = dependency_nodes[dependency]
1361 target_node.dependencies.append(dependency_node) 1376 target_node.dependencies.append(dependency_node)
1362 dependency_node.dependents.append(target_node) 1377 dependency_node.dependents.append(target_node)
1363 except KeyError, e: 1378 except KeyError, e:
1364 gyp.common.ExceptionAppend(e, 1379 gyp.common.ExceptionAppend(e,
1365 'while trying to load target %s' % target) 1380 'while trying to load target %s' % target)
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 """Process regular expression and exclusion-based filters on lists. 1826 """Process regular expression and exclusion-based filters on lists.
1812 1827
1813 An exclusion list is in a dict key named with a trailing "!", like 1828 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 1829 "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 1830 main list, which in this example, would be "sources". Removed items are
1816 placed into a "sources_excluded" list in the dict. 1831 placed into a "sources_excluded" list in the dict.
1817 1832
1818 Regular expression (regex) filters are contained in dict keys named with a 1833 Regular expression (regex) filters are contained in dict keys named with a
1819 trailing "/", such as "sources/" to operate on the "sources" list. Regex 1834 trailing "/", such as "sources/" to operate on the "sources" list. Regex
1820 filters in a dict take the form: 1835 filters in a dict take the form:
1821 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'] ], 1836 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'],
1822 ['include', '_mac\\.cc$'] ], 1837 ['include', '_mac\\.cc$'] ],
1823 The first filter says to exclude all files ending in _linux.cc, _mac.cc, and 1838 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 1839 _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" 1840 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 1841 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" 1842 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 1843 filter are brought back into the main list if previously excluded by an
1829 exclusion list or exclusion regex filter. Subsequent matching "exclude" 1844 exclusion list or exclusion regex filter. Subsequent matching "exclude"
1830 patterns can still cause items to be excluded after matching an "include". 1845 patterns can still cause items to be excluded after matching an "include".
1831 """ 1846 """
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 ValidateRunAsInTarget(target, target_dict, build_file) 2256 ValidateRunAsInTarget(target, target_dict, build_file)
2242 ValidateActionsInTarget(target, target_dict, build_file) 2257 ValidateActionsInTarget(target, target_dict, build_file)
2243 2258
2244 # Generators might not expect ints. Turn them into strs. 2259 # Generators might not expect ints. Turn them into strs.
2245 TurnIntIntoStrInDict(data) 2260 TurnIntIntoStrInDict(data)
2246 2261
2247 # TODO(mark): Return |data| for now because the generator needs a list of 2262 # 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 2263 # build files that came in. In the future, maybe it should just accept
2249 # a list, and not the whole data dict. 2264 # a list, and not the whole data dict.
2250 return [flat_list, targets, data] 2265 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698