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]
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 \
1297
1304
return [dependency_nodes, flat_list]
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)
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:
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.
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)
1332
gyp.common.ExceptionAppend(
1333
e, 'while computing dependencies of .gyp file %s' % build_file)
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)
1343
flat_list = root_node.FlattenToList()
1345
# If there's anything left unvisited, there must be a circular dependency
1347
if len(flat_list) != len(dependency_nodes):
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: ' + \
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)
1962
def Load(build_files, variables, includes, depth, generator_input_info, check):
2020
def Load(build_files, variables, includes, depth, generator_input_info, 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)
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)
2018
2082
[dependency_nodes, flat_list] = BuildDependencyList(targets)
2020
2084
# Handle dependent settings of various types.