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

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

Issue 1506733002: GYP: Make GYP build deterministic (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Windows-Fixes Created 5 years 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
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from compiler.ast import Const 5 from compiler.ast import Const
6 from compiler.ast import Dict 6 from compiler.ast import Dict
7 from compiler.ast import Discard 7 from compiler.ast import Discard
8 from compiler.ast import List 8 from compiler.ast import List
9 from compiler.ast import Module 9 from compiler.ast import Module
10 from compiler.ast import Node 10 from compiler.ast import Node
11 from compiler.ast import Stmt 11 from compiler.ast import Stmt
12 import compiler 12 import compiler
13 import gyp.common 13 import gyp.common
14 import gyp.simple_copy 14 import gyp.simple_copy
15 import multiprocessing 15 import multiprocessing
16 import optparse 16 import optparse
17 import os.path 17 import os.path
18 import re 18 import re
19 import shlex 19 import shlex
20 import signal 20 import signal
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 import threading 23 import threading
24 import time 24 import time
25 import traceback 25 import traceback
26 from gyp.common import GypError 26 from gyp.common import GypError
27 from gyp.common import OrderedSet 27 from gyp.common import OrderedSet
28 28
29 29
30
Nico 2016/01/13 20:16:54 why this newline?
Zachary Forman 2016/01/18 20:44:36 Reverted
30 # A list of types that are treated as linkable. 31 # A list of types that are treated as linkable.
31 linkable_types = [ 32 linkable_types = [
32 'executable', 33 'executable',
33 'shared_library', 34 'shared_library',
34 'loadable_module', 35 'loadable_module',
35 'mac_kernel_extension', 36 'mac_kernel_extension',
36 ] 37 ]
37 38
38 # A list of sections that contain links to other targets. 39 # A list of sections that contain links to other targets.
39 dependency_sections = ['dependencies', 'export_dependent_settings'] 40 dependency_sections = ['dependencies', 'export_dependent_settings']
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 def __repr__(self): 1533 def __repr__(self):
1533 return '<DependencyGraphNode: %r>' % self.ref 1534 return '<DependencyGraphNode: %r>' % self.ref
1534 1535
1535 def FlattenToList(self): 1536 def FlattenToList(self):
1536 # flat_list is the sorted list of dependencies - actually, the list items 1537 # flat_list is the sorted list of dependencies - actually, the list items
1537 # are the "ref" attributes of DependencyGraphNodes. Every target will 1538 # are the "ref" attributes of DependencyGraphNodes. Every target will
1538 # appear in flat_list after all of its dependencies, and before all of its 1539 # appear in flat_list after all of its dependencies, and before all of its
1539 # dependents. 1540 # dependents.
1540 flat_list = OrderedSet() 1541 flat_list = OrderedSet()
1541 1542
1543 def ExtractNodeRef(node):
1544 """Extracts the object that the node represents from the given node."""
1545 return node.ref
1546
1542 # in_degree_zeros is the list of DependencyGraphNodes that have no 1547 # in_degree_zeros is the list of DependencyGraphNodes that have no
1543 # dependencies not in flat_list. Initially, it is a copy of the children 1548 # dependencies not in flat_list. Initially, it is a copy of the children
1544 # of this node, because when the graph was built, nodes with no 1549 # of this node, because when the graph was built, nodes with no
1545 # dependencies were made implicit dependents of the root node. 1550 # dependencies were made implicit dependents of the root node.
1546 in_degree_zeros = set(self.dependents[:]) 1551 in_degree_zeros = sorted(self.dependents[:], key=ExtractNodeRef)
1547 1552
1548 while in_degree_zeros: 1553 while in_degree_zeros:
1549 # Nodes in in_degree_zeros have no dependencies not in flat_list, so they 1554 # Nodes in in_degree_zeros have no dependencies not in flat_list, so they
1550 # can be appended to flat_list. Take these nodes out of in_degree_zeros 1555 # can be appended to flat_list. Take these nodes out of in_degree_zeros
1551 # as work progresses, so that the next node to process from the list can 1556 # as work progresses, so that the next node to process from the list can
1552 # always be accessed at a consistent position. 1557 # always be accessed at a consistent position.
1553 node = in_degree_zeros.pop() 1558 node = in_degree_zeros.pop()
1554 flat_list.add(node.ref) 1559 flat_list.add(node.ref)
1555 1560
1556 # Look at dependents of the node just added to flat_list. Some of them 1561 # Look at dependents of the node just added to flat_list. Some of them
1557 # may now belong in in_degree_zeros. 1562 # may now belong in in_degree_zeros.
1558 for node_dependent in node.dependents: 1563 for node_dependent in sorted(node.dependents, key=ExtractNodeRef):
1559 is_in_degree_zero = True 1564 is_in_degree_zero = True
1560 # TODO: We want to check through the 1565 # TODO: We want to check through the
1561 # node_dependent.dependencies list but if it's long and we 1566 # node_dependent.dependencies list but if it's long and we
1562 # always start at the beginning, then we get O(n^2) behaviour. 1567 # always start at the beginning, then we get O(n^2) behaviour.
1563 for node_dependent_dependency in node_dependent.dependencies: 1568 for node_dependent_dependency in (sorted(node_dependent.dependencies,
1569 key=ExtractNodeRef)):
1564 if not node_dependent_dependency.ref in flat_list: 1570 if not node_dependent_dependency.ref in flat_list:
1565 # The dependent one or more dependencies not in flat_list. There 1571 # The dependent one or more dependencies not in flat_list. There
1566 # will be more chances to add it to flat_list when examining 1572 # will be more chances to add it to flat_list when examining
1567 # it again as a dependent of those other dependencies, provided 1573 # it again as a dependent of those other dependencies, provided
1568 # that there are no cycles. 1574 # that there are no cycles.
1569 is_in_degree_zero = False 1575 is_in_degree_zero = False
1570 break 1576 break
1571 1577
1572 if is_in_degree_zero: 1578 if is_in_degree_zero:
1573 # All of the dependent's dependencies are already in flat_list. Add 1579 # All of the dependent's dependencies are already in flat_list. Add
1574 # it to in_degree_zeros where it will be processed in a future 1580 # it to in_degree_zeros where it will be processed in a future
1575 # iteration of the outer loop. 1581 # iteration of the outer loop.
1576 in_degree_zeros.add(node_dependent) 1582 in_degree_zeros += [node_dependent]
1577 1583
1578 return list(flat_list) 1584 return list(flat_list)
1579 1585
1580 def FindCycles(self): 1586 def FindCycles(self):
1581 """ 1587 """
1582 Returns a list of cycles in the graph, where each cycle is its own list. 1588 Returns a list of cycles in the graph, where each cycle is its own list.
1583 """ 1589 """
1584 results = [] 1590 results = []
1585 visited = set() 1591 visited = set()
1586 1592
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 ValidateRunAsInTarget(target, target_dict, build_file) 2891 ValidateRunAsInTarget(target, target_dict, build_file)
2886 ValidateActionsInTarget(target, target_dict, build_file) 2892 ValidateActionsInTarget(target, target_dict, build_file)
2887 2893
2888 # Generators might not expect ints. Turn them into strs. 2894 # Generators might not expect ints. Turn them into strs.
2889 TurnIntIntoStrInDict(data) 2895 TurnIntIntoStrInDict(data)
2890 2896
2891 # TODO(mark): Return |data| for now because the generator needs a list of 2897 # TODO(mark): Return |data| for now because the generator needs a list of
2892 # build files that came in. In the future, maybe it should just accept 2898 # build files that came in. In the future, maybe it should just accept
2893 # a list, and not the whole data dict. 2899 # a list, and not the whole data dict.
2894 return [flat_list, targets, data] 2900 return [flat_list, targets, data]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698