~ubuntu-branches/ubuntu/lucid/gyp/lucid-proposed

« back to all changes in this revision

Viewing changes to pylib/gyp/input.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2010-02-17 22:00:38 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217220038-hmfvpu3zapmihgeo
Tags: 0.1~svn785-0ubuntu1

New upstream snapshot, needed to support --no-circular-check

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
 
47
47
def IsPathSection(section):
 
48
  # If section ends in one of these characters, it's applied to a section
 
49
  # without the trailing characters.  '/' is notably absent from this list,
 
50
  # because there's no way for a regular expression to be treated as a path.
 
51
  while section[-1:] in ('=', '+', '?', '!'):
 
52
    section = section[0:-1]
 
53
 
48
54
  if section in path_sections or \
49
55
     section.endswith('_dir') or section.endswith('_dirs') or \
50
56
     section.endswith('_file') or section.endswith('_files') or \
71
77
  'product_dir',
72
78
  'product_extension',
73
79
  'product_name',
 
80
  'product_prefix',
74
81
  'rules',
75
82
  'run_as',
76
83
  'sources',
1297
1304
  return [dependency_nodes, flat_list]
1298
1305
 
1299
1306
 
 
1307
def VerifyNoGYPFileCircularDependencies(targets):
 
1308
  # Create a DependencyGraphNode for each gyp file containing a target.  Put
 
1309
  # it into a dict for easy access.
 
1310
  dependency_nodes = {}
 
1311
  for target in targets.iterkeys():
 
1312
    build_file = gyp.common.BuildFile(target)
 
1313
    if not build_file in dependency_nodes:
 
1314
      dependency_nodes[build_file] = DependencyGraphNode(build_file)
 
1315
 
 
1316
  # Set up the dependency links.
 
1317
  for target, spec in targets.iteritems():
 
1318
    build_file = gyp.common.BuildFile(target)
 
1319
    build_file_node = dependency_nodes[build_file]
 
1320
    target_dependencies = spec.get('dependencies', [])
 
1321
    for dependency in target_dependencies:
 
1322
      try:
 
1323
        dependency_build_file = gyp.common.BuildFile(dependency)
 
1324
        if dependency_build_file == build_file:
 
1325
          # A .gyp file is allowed to refer back to itself.
 
1326
          continue
 
1327
        dependency_node = dependency_nodes[dependency_build_file]
 
1328
        if dependency_node not in build_file_node.dependencies:
 
1329
          build_file_node.dependencies.append(dependency_node)
 
1330
          dependency_node.dependents.append(build_file_node)
 
1331
      except KeyError, e:
 
1332
        gyp.common.ExceptionAppend(
 
1333
            e, 'while computing dependencies of .gyp file %s' % build_file)
 
1334
        raise
 
1335
 
 
1336
  # Files that have no dependencies are treated as dependent on root_node.
 
1337
  root_node = DependencyGraphNode(None)
 
1338
  for build_file_node in dependency_nodes.itervalues():
 
1339
    if len(build_file_node.dependencies) == 0:
 
1340
      build_file_node.dependencies.append(root_node)
 
1341
      root_node.dependents.append(build_file_node)
 
1342
 
 
1343
  flat_list = root_node.FlattenToList()
 
1344
 
 
1345
  # If there's anything left unvisited, there must be a circular dependency
 
1346
  # (cycle).
 
1347
  if len(flat_list) != len(dependency_nodes):
 
1348
    bad_files = []
 
1349
    for file in dependency_nodes.iterkeys():
 
1350
      if not file in flat_list:
 
1351
        bad_files.append(file)
 
1352
    raise DependencyGraphNode.CircularException, \
 
1353
        'Some files not reachable, cycle in .gyp file dependency graph ' + \
 
1354
        'detected involving some or all of: ' + \
 
1355
        ' '.join(bad_files)
 
1356
 
 
1357
 
1300
1358
def DoDependentSettings(key, flat_list, targets, dependency_nodes):
1301
1359
  # key should be one of all_dependent_settings, direct_dependent_settings,
1302
1360
  # or link_settings.
1959
2017
      TurnIntIntoStrInList(item)
1960
2018
 
1961
2019
 
1962
 
def Load(build_files, variables, includes, depth, generator_input_info, check):
 
2020
def Load(build_files, variables, includes, depth, generator_input_info, check,
 
2021
         circular_check):
1963
2022
  # Set up path_sections and non_configuration_keys with the default data plus
1964
2023
  # the generator-specifc data.
1965
2024
  global path_sections
2015
2074
  # Expand dependencies specified as build_file:*.
2016
2075
  ExpandWildcardDependencies(targets, data)
2017
2076
 
 
2077
  if circular_check:
 
2078
    # Make sure that any targets in a.gyp don't contain dependencies in other
 
2079
    # .gyp files that further depend on a.gyp.
 
2080
    VerifyNoGYPFileCircularDependencies(targets)
 
2081
 
2018
2082
  [dependency_nodes, flat_list] = BuildDependencyList(targets)
2019
2083
 
2020
2084
  # Handle dependent settings of various types.