OLD | NEW |
1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 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 import copy | 5 import copy |
6 import hashlib | 6 import hashlib |
7 import multiprocessing | 7 import multiprocessing |
8 import os.path | 8 import os.path |
9 import re | 9 import re |
10 import signal | 10 import signal |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 outputs = [] | 523 outputs = [] |
524 for source in filter(lambda x: x.endswith('.idl'), spec['sources']): | 524 for source in filter(lambda x: x.endswith('.idl'), spec['sources']): |
525 self._WinIdlRule(source, prebuild, outputs) | 525 self._WinIdlRule(source, prebuild, outputs) |
526 return outputs | 526 return outputs |
527 | 527 |
528 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, | 528 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, |
529 mac_bundle_depends): | 529 mac_bundle_depends): |
530 """Write out the Actions, Rules, and Copies steps. Return a path | 530 """Write out the Actions, Rules, and Copies steps. Return a path |
531 representing the outputs of these steps.""" | 531 representing the outputs of these steps.""" |
532 outputs = [] | 532 outputs = [] |
| 533 if self.is_mac_bundle: |
| 534 mac_bundle_resources = spec.get('mac_bundle_resources', [])[:] |
| 535 else: |
| 536 mac_bundle_resources = [] |
533 extra_mac_bundle_resources = [] | 537 extra_mac_bundle_resources = [] |
534 | 538 |
535 if 'actions' in spec: | 539 if 'actions' in spec: |
536 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, | 540 outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, |
537 extra_mac_bundle_resources) | 541 extra_mac_bundle_resources) |
538 if 'rules' in spec: | 542 if 'rules' in spec: |
539 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, | 543 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, |
| 544 mac_bundle_resources, |
540 extra_mac_bundle_resources) | 545 extra_mac_bundle_resources) |
541 if 'copies' in spec: | 546 if 'copies' in spec: |
542 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) | 547 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) |
543 | 548 |
544 if 'sources' in spec and self.flavor == 'win': | 549 if 'sources' in spec and self.flavor == 'win': |
545 outputs += self.WriteWinIdlFiles(spec, prebuild) | 550 outputs += self.WriteWinIdlFiles(spec, prebuild) |
546 | 551 |
547 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) | 552 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) |
548 | 553 |
549 if self.is_mac_bundle: | 554 if self.is_mac_bundle: |
550 mac_bundle_resources = spec.get('mac_bundle_resources', []) + \ | 555 self.WriteMacBundleResources( |
551 extra_mac_bundle_resources | 556 mac_bundle_resources + extra_mac_bundle_resources, mac_bundle_depends) |
552 self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends) | |
553 self.WriteMacInfoPlist(mac_bundle_depends) | 557 self.WriteMacInfoPlist(mac_bundle_depends) |
554 | 558 |
555 return stamp | 559 return stamp |
556 | 560 |
557 def GenerateDescription(self, verb, message, fallback): | 561 def GenerateDescription(self, verb, message, fallback): |
558 """Generate and return a description of a build step. | 562 """Generate and return a description of a build step. |
559 | 563 |
560 |verb| is the short summary, e.g. ACTION or RULE. | 564 |verb| is the short summary, e.g. ACTION or RULE. |
561 |message| is a hand-written description, or None if not available. | 565 |message| is a hand-written description, or None if not available. |
562 |fallback| is the gyp-level name of the step, usable as a fallback. | 566 |fallback| is the gyp-level name of the step, usable as a fallback. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 # Then write out an edge using the rule. | 603 # Then write out an edge using the rule. |
600 self.ninja.build(outputs, rule_name, inputs, | 604 self.ninja.build(outputs, rule_name, inputs, |
601 order_only=prebuild) | 605 order_only=prebuild) |
602 all_outputs += outputs | 606 all_outputs += outputs |
603 | 607 |
604 self.ninja.newline() | 608 self.ninja.newline() |
605 | 609 |
606 return all_outputs | 610 return all_outputs |
607 | 611 |
608 def WriteRules(self, rules, extra_sources, prebuild, | 612 def WriteRules(self, rules, extra_sources, prebuild, |
609 extra_mac_bundle_resources): | 613 mac_bundle_resources, extra_mac_bundle_resources): |
610 env = self.GetSortedXcodeEnv() | 614 env = self.GetSortedXcodeEnv() |
611 all_outputs = [] | 615 all_outputs = [] |
612 for rule in rules: | 616 for rule in rules: |
613 # First write out a rule for the rule action. | 617 # First write out a rule for the rule action. |
614 name = '%s_%s' % (rule['rule_name'], | 618 name = '%s_%s' % (rule['rule_name'], |
615 hashlib.md5(self.qualified_target).hexdigest()) | 619 hashlib.md5(self.qualified_target).hexdigest()) |
616 # Skip a rule with no action and no inputs. | 620 # Skip a rule with no action and no inputs. |
617 if 'action' not in rule and not rule.get('rule_sources', []): | 621 if 'action' not in rule and not rule.get('rule_sources', []): |
618 continue | 622 continue |
619 args = rule['action'] | 623 args = rule['action'] |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 # Gather the list of inputs and outputs, expanding $vars if possible. | 657 # Gather the list of inputs and outputs, expanding $vars if possible. |
654 outputs = [self.ExpandRuleVariables(o, root, dirname, | 658 outputs = [self.ExpandRuleVariables(o, root, dirname, |
655 source, ext, basename) | 659 source, ext, basename) |
656 for o in rule['outputs']] | 660 for o in rule['outputs']] |
657 inputs = [self.ExpandRuleVariables(i, root, dirname, | 661 inputs = [self.ExpandRuleVariables(i, root, dirname, |
658 source, ext, basename) | 662 source, ext, basename) |
659 for i in rule.get('inputs', [])] | 663 for i in rule.get('inputs', [])] |
660 | 664 |
661 if int(rule.get('process_outputs_as_sources', False)): | 665 if int(rule.get('process_outputs_as_sources', False)): |
662 extra_sources += outputs | 666 extra_sources += outputs |
663 if int(rule.get('process_outputs_as_mac_bundle_resources', False)): | 667 |
| 668 was_mac_bundle_resource = source in mac_bundle_resources |
| 669 if was_mac_bundle_resource or \ |
| 670 int(rule.get('process_outputs_as_mac_bundle_resources', False)): |
664 extra_mac_bundle_resources += outputs | 671 extra_mac_bundle_resources += outputs |
| 672 # Note: This is n_resources * n_outputs_in_rule. Put to-be-removed |
| 673 # items in a set and remove them all in a single pass if this becomes |
| 674 # a performance issue. |
| 675 if was_mac_bundle_resource: |
| 676 mac_bundle_resources.remove(source) |
665 | 677 |
666 extra_bindings = [] | 678 extra_bindings = [] |
667 for var in needed_variables: | 679 for var in needed_variables: |
668 if var == 'root': | 680 if var == 'root': |
669 extra_bindings.append(('root', cygwin_munge(root))) | 681 extra_bindings.append(('root', cygwin_munge(root))) |
670 elif var == 'dirname': | 682 elif var == 'dirname': |
671 # '$dirname' is a parameter to the rule action, which means | 683 # '$dirname' is a parameter to the rule action, which means |
672 # it shouldn't be converted to a Ninja path. But we don't | 684 # it shouldn't be converted to a Ninja path. But we don't |
673 # want $!PRODUCT_DIR in there either. | 685 # want $!PRODUCT_DIR in there either. |
674 dirname_expanded = self.ExpandSpecial(dirname, self.base_to_build) | 686 dirname_expanded = self.ExpandSpecial(dirname, self.base_to_build) |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 arglists.append( | 2086 arglists.append( |
2075 (target_list, target_dicts, data, params, config_name)) | 2087 (target_list, target_dicts, data, params, config_name)) |
2076 pool.map(CallGenerateOutputForConfig, arglists) | 2088 pool.map(CallGenerateOutputForConfig, arglists) |
2077 except KeyboardInterrupt, e: | 2089 except KeyboardInterrupt, e: |
2078 pool.terminate() | 2090 pool.terminate() |
2079 raise e | 2091 raise e |
2080 else: | 2092 else: |
2081 for config_name in config_names: | 2093 for config_name in config_names: |
2082 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2094 GenerateOutputForConfig(target_list, target_dicts, data, params, |
2083 config_name) | 2095 config_name) |
OLD | NEW |