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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 self.aux_data[key] = aux_data0[key] | 545 self.aux_data[key] = aux_data0[key] |
546 for new_dependency in dependencies0: | 546 for new_dependency in dependencies0: |
547 if new_dependency not in self.scheduled: | 547 if new_dependency not in self.scheduled: |
548 self.scheduled.add(new_dependency) | 548 self.scheduled.add(new_dependency) |
549 self.dependencies.append(new_dependency) | 549 self.dependencies.append(new_dependency) |
550 self.pending -= 1 | 550 self.pending -= 1 |
551 self.condition.notify() | 551 self.condition.notify() |
552 self.condition.release() | 552 self.condition.release() |
553 | 553 |
554 | 554 |
555 def LoadTargetBuildFileParallel(build_file_path, data, aux_data, | 555 def LoadTargetBuildFilesParallel(build_files, data, aux_data, |
556 variables, includes, depth, check): | 556 variables, includes, depth, check): |
557 parallel_state = ParallelState() | 557 parallel_state = ParallelState() |
558 parallel_state.condition = threading.Condition() | 558 parallel_state.condition = threading.Condition() |
559 parallel_state.dependencies = [build_file_path] | 559 # Make copies of the build_files argument that we can modify while working. |
560 parallel_state.scheduled = set([build_file_path]) | 560 parallel_state.dependencies = list(build_files) |
| 561 parallel_state.scheduled = set(build_files) |
561 parallel_state.pending = 0 | 562 parallel_state.pending = 0 |
562 parallel_state.data = data | 563 parallel_state.data = data |
563 parallel_state.aux_data = aux_data | 564 parallel_state.aux_data = aux_data |
564 | 565 |
565 try: | 566 try: |
566 parallel_state.condition.acquire() | 567 parallel_state.condition.acquire() |
567 while parallel_state.dependencies or parallel_state.pending: | 568 while parallel_state.dependencies or parallel_state.pending: |
568 if parallel_state.error: | 569 if parallel_state.error: |
569 print >>sys.stderr, ( | 570 print >>sys.stderr, ( |
570 '\n' | 571 '\n' |
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2619 | 2620 |
2620 # Load build files. This loads every target-containing build file into | 2621 # Load build files. This loads every target-containing build file into |
2621 # the |data| dictionary such that the keys to |data| are build file names, | 2622 # the |data| dictionary such that the keys to |data| are build file names, |
2622 # and the values are the entire build file contents after "early" or "pre" | 2623 # and the values are the entire build file contents after "early" or "pre" |
2623 # processing has been done and includes have been resolved. | 2624 # processing has been done and includes have been resolved. |
2624 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2625 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
2625 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps | 2626 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps |
2626 # track of the keys corresponding to "target" files. | 2627 # track of the keys corresponding to "target" files. |
2627 data = {'target_build_files': set()} | 2628 data = {'target_build_files': set()} |
2628 aux_data = {} | 2629 aux_data = {} |
2629 for build_file in build_files: | 2630 # Normalize paths everywhere. This is important because paths will be |
2630 # Normalize paths everywhere. This is important because paths will be | 2631 # used as keys to the data dict and for references between input files. |
2631 # used as keys to the data dict and for references between input files. | 2632 build_files = set(map(os.path.normpath, build_files)) |
2632 build_file = os.path.normpath(build_file) | 2633 if parallel: |
2633 try: | 2634 LoadTargetBuildFilesParallel(build_files, data, aux_data, |
2634 if parallel: | 2635 variables, includes, depth, check) |
2635 LoadTargetBuildFileParallel(build_file, data, aux_data, | 2636 else: |
2636 variables, includes, depth, check) | 2637 for build_file in build_files: |
2637 else: | 2638 try: |
2638 LoadTargetBuildFile(build_file, data, aux_data, | 2639 LoadTargetBuildFile(build_file, data, aux_data, |
2639 variables, includes, depth, check, True) | 2640 variables, includes, depth, check, True) |
2640 except Exception, e: | 2641 except Exception, e: |
2641 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) | 2642 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) |
2642 raise | 2643 raise |
2643 | 2644 |
2644 # Build a dict to access each target's subdict by qualified name. | 2645 # Build a dict to access each target's subdict by qualified name. |
2645 targets = BuildTargetsDict(data) | 2646 targets = BuildTargetsDict(data) |
2646 | 2647 |
2647 # Fully qualify all dependency links. | 2648 # Fully qualify all dependency links. |
2648 QualifyDependencies(targets) | 2649 QualifyDependencies(targets) |
2649 | 2650 |
2650 # Remove self-dependencies from targets that have 'prune_self_dependencies' | 2651 # Remove self-dependencies from targets that have 'prune_self_dependencies' |
2651 # set to 1. | 2652 # set to 1. |
2652 RemoveSelfDependencies(targets) | 2653 RemoveSelfDependencies(targets) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 ValidateRunAsInTarget(target, target_dict, build_file) | 2742 ValidateRunAsInTarget(target, target_dict, build_file) |
2742 ValidateActionsInTarget(target, target_dict, build_file) | 2743 ValidateActionsInTarget(target, target_dict, build_file) |
2743 | 2744 |
2744 # Generators might not expect ints. Turn them into strs. | 2745 # Generators might not expect ints. Turn them into strs. |
2745 TurnIntIntoStrInDict(data) | 2746 TurnIntIntoStrInDict(data) |
2746 | 2747 |
2747 # TODO(mark): Return |data| for now because the generator needs a list of | 2748 # TODO(mark): Return |data| for now because the generator needs a list of |
2748 # build files that came in. In the future, maybe it should just accept | 2749 # build files that came in. In the future, maybe it should just accept |
2749 # a list, and not the whole data dict. | 2750 # a list, and not the whole data dict. |
2750 return [flat_list, targets, data] | 2751 return [flat_list, targets, data] |
OLD | NEW |