OLD | NEW |
---|---|
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 |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 self.aux_data[key] = aux_data0[key] | 546 self.aux_data[key] = aux_data0[key] |
547 for new_dependency in dependencies0: | 547 for new_dependency in dependencies0: |
548 if new_dependency not in self.scheduled: | 548 if new_dependency not in self.scheduled: |
549 self.scheduled.add(new_dependency) | 549 self.scheduled.add(new_dependency) |
550 self.dependencies.append(new_dependency) | 550 self.dependencies.append(new_dependency) |
551 self.pending -= 1 | 551 self.pending -= 1 |
552 self.condition.notify() | 552 self.condition.notify() |
553 self.condition.release() | 553 self.condition.release() |
554 | 554 |
555 | 555 |
556 def LoadTargetBuildFileParallel(build_file_path, data, aux_data, | 556 def LoadTargetBuildFilesParallel(build_files, data, aux_data, |
557 variables, includes, depth, check): | 557 variables, includes, depth, check): |
558 parallel_state = ParallelState() | 558 parallel_state = ParallelState() |
559 parallel_state.condition = threading.Condition() | 559 parallel_state.condition = threading.Condition() |
560 parallel_state.dependencies = [build_file_path] | 560 parallel_state.dependencies = list(build_files) |
dmazzoni
2013/08/29 15:04:46
You're converting |build_files| to both a list and
Simon Brenner
2013/08/29 16:15:48
If |build_files| is already a list, list() serves
| |
561 parallel_state.scheduled = set([build_file_path]) | 561 parallel_state.scheduled = set(build_files) |
562 parallel_state.pending = 0 | 562 parallel_state.pending = 0 |
563 parallel_state.data = data | 563 parallel_state.data = data |
564 parallel_state.aux_data = aux_data | 564 parallel_state.aux_data = aux_data |
565 | 565 |
566 try: | 566 try: |
567 parallel_state.condition.acquire() | 567 parallel_state.condition.acquire() |
568 while parallel_state.dependencies or parallel_state.pending: | 568 while parallel_state.dependencies or parallel_state.pending: |
569 if parallel_state.error: | 569 if parallel_state.error: |
570 print >>sys.stderr, ( | 570 print >>sys.stderr, ( |
571 '\n' | 571 '\n' |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2582 | 2582 |
2583 # Load build files. This loads every target-containing build file into | 2583 # Load build files. This loads every target-containing build file into |
2584 # the |data| dictionary such that the keys to |data| are build file names, | 2584 # the |data| dictionary such that the keys to |data| are build file names, |
2585 # and the values are the entire build file contents after "early" or "pre" | 2585 # and the values are the entire build file contents after "early" or "pre" |
2586 # processing has been done and includes have been resolved. | 2586 # processing has been done and includes have been resolved. |
2587 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2587 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
2588 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps | 2588 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps |
2589 # track of the keys corresponding to "target" files. | 2589 # track of the keys corresponding to "target" files. |
2590 data = {'target_build_files': set()} | 2590 data = {'target_build_files': set()} |
2591 aux_data = {} | 2591 aux_data = {} |
2592 for build_file in build_files: | 2592 # Normalize paths everywhere. This is important because paths will be |
2593 # Normalize paths everywhere. This is important because paths will be | 2593 # used as keys to the data dict and for references between input files. |
2594 # used as keys to the data dict and for references between input files. | 2594 build_files = set(map(os.path.normpath, build_files)) |
2595 build_file = os.path.normpath(build_file) | 2595 if parallel: |
2596 try: | 2596 LoadTargetBuildFilesParallel(build_files, data, aux_data, |
dmazzoni
2013/08/29 15:04:46
Fix indentation
| |
2597 if parallel: | 2597 variables, includes, depth, check) |
2598 LoadTargetBuildFileParallel(build_file, data, aux_data, | 2598 else: |
2599 variables, includes, depth, check) | 2599 for build_file in build_files: |
2600 else: | 2600 try: |
2601 LoadTargetBuildFile(build_file, data, aux_data, | 2601 LoadTargetBuildFile(build_file, data, aux_data, |
2602 variables, includes, depth, check, True) | 2602 variables, includes, depth, check, True) |
2603 except Exception, e: | 2603 except Exception, e: |
2604 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) | 2604 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) |
2605 raise | 2605 raise |
2606 | 2606 |
2607 # Build a dict to access each target's subdict by qualified name. | 2607 # Build a dict to access each target's subdict by qualified name. |
2608 targets = BuildTargetsDict(data) | 2608 targets = BuildTargetsDict(data) |
2609 | 2609 |
2610 # Fully qualify all dependency links. | 2610 # Fully qualify all dependency links. |
2611 QualifyDependencies(targets) | 2611 QualifyDependencies(targets) |
2612 | 2612 |
2613 # Remove self-dependencies from targets that have 'prune_self_dependencies' | 2613 # Remove self-dependencies from targets that have 'prune_self_dependencies' |
2614 # set to 1. | 2614 # set to 1. |
2615 RemoveSelfDependencies(targets) | 2615 RemoveSelfDependencies(targets) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2704 ValidateRunAsInTarget(target, target_dict, build_file) | 2704 ValidateRunAsInTarget(target, target_dict, build_file) |
2705 ValidateActionsInTarget(target, target_dict, build_file) | 2705 ValidateActionsInTarget(target, target_dict, build_file) |
2706 | 2706 |
2707 # Generators might not expect ints. Turn them into strs. | 2707 # Generators might not expect ints. Turn them into strs. |
2708 TurnIntIntoStrInDict(data) | 2708 TurnIntIntoStrInDict(data) |
2709 | 2709 |
2710 # TODO(mark): Return |data| for now because the generator needs a list of | 2710 # TODO(mark): Return |data| for now because the generator needs a list of |
2711 # build files that came in. In the future, maybe it should just accept | 2711 # build files that came in. In the future, maybe it should just accept |
2712 # a list, and not the whole data dict. | 2712 # a list, and not the whole data dict. |
2713 return [flat_list, targets, data] | 2713 return [flat_list, targets, data] |
OLD | NEW |