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 import copy | 5 import copy |
6 import gyp | 6 import gyp |
7 import gyp.common | 7 import gyp.common |
8 import gyp.msvs_emulation | 8 import gyp.msvs_emulation |
9 import gyp.MSVSVersion | 9 import gyp.MSVSVersion |
10 import gyp.system_test | 10 import gyp.system_test |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 # Then write out an edge using the rule. | 511 # Then write out an edge using the rule. |
512 self.ninja.build(outputs, rule_name, inputs, | 512 self.ninja.build(outputs, rule_name, inputs, |
513 order_only=prebuild) | 513 order_only=prebuild) |
514 all_outputs += outputs | 514 all_outputs += outputs |
515 | 515 |
516 self.ninja.newline() | 516 self.ninja.newline() |
517 | 517 |
518 return all_outputs | 518 return all_outputs |
519 | 519 |
| 520 def _GetSourcesForRule(self, main_rule, all_rules): |
| 521 """Get all sources that this rule needs to process. In addition to the |
| 522 rule_sources we have to consider the outputs of other rules.""" |
| 523 sources = main_rule.get('rule_sources', []) |
| 524 rule_ext = '.' + main_rule['extension'] |
| 525 for rule in all_rules: |
| 526 if rule == main_rule: |
| 527 continue |
| 528 # If this rules outputs are processed, and they're something that this |
| 529 # rule cares about, then add to the inputs. |
| 530 if int(rule.get('process_outputs_as_sources', False)): |
| 531 for output in rule['outputs']: |
| 532 if output.endswith(rule_ext): |
| 533 sources.append(output) |
| 534 return sources |
| 535 |
520 def WriteRules(self, rules, extra_sources, prebuild, | 536 def WriteRules(self, rules, extra_sources, prebuild, |
521 extra_mac_bundle_resources): | 537 extra_mac_bundle_resources): |
522 all_outputs = [] | 538 all_outputs = [] |
523 for rule in rules: | 539 for rule in rules: |
524 # First write out a rule for the rule action. | 540 # First write out a rule for the rule action. |
525 name = rule['rule_name'] | 541 name = rule['rule_name'] |
526 args = rule['action'] | 542 args = rule['action'] |
527 description = self.GenerateDescription( | 543 description = self.GenerateDescription( |
528 'RULE', | 544 'RULE', |
529 rule.get('message', None), | 545 rule.get('message', None), |
(...skipping 15 matching lines...) Expand all Loading... |
545 for argument in args: | 561 for argument in args: |
546 for var in special_locals: | 562 for var in special_locals: |
547 if ('${%s}' % var) in argument: | 563 if ('${%s}' % var) in argument: |
548 needed_variables.add(var) | 564 needed_variables.add(var) |
549 | 565 |
550 def cygwin_munge(path): | 566 def cygwin_munge(path): |
551 if is_cygwin: | 567 if is_cygwin: |
552 return path.replace('\\', '/') | 568 return path.replace('\\', '/') |
553 return path | 569 return path |
554 | 570 |
| 571 sources = self._GetSourcesForRule(rule, rules) |
555 # For each source file, write an edge that generates all the outputs. | 572 # For each source file, write an edge that generates all the outputs. |
556 for source in rule.get('rule_sources', []): | 573 for source in sources: |
557 dirname, basename = os.path.split(source) | 574 dirname, basename = os.path.split(source) |
558 root, ext = os.path.splitext(basename) | 575 root, ext = os.path.splitext(basename) |
559 | 576 |
560 # Gather the list of inputs and outputs, expanding $vars if possible. | 577 # Gather the list of inputs and outputs, expanding $vars if possible. |
561 outputs = [self.ExpandRuleVariables(o, root, dirname, | 578 outputs = [self.ExpandRuleVariables(o, root, dirname, |
562 source, ext, basename) | 579 source, ext, basename) |
563 for o in rule['outputs']] | 580 for o in rule['outputs']] |
564 inputs = [self.ExpandRuleVariables(i, root, dirname, | 581 inputs = [self.ExpandRuleVariables(i, root, dirname, |
565 source, ext, basename) | 582 source, ext, basename) |
566 for i in rule.get('inputs', [])] | 583 for i in rule.get('inputs', [])] |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 | 1504 |
1488 user_config = params.get('generator_flags', {}).get('config', None) | 1505 user_config = params.get('generator_flags', {}).get('config', None) |
1489 if user_config: | 1506 if user_config: |
1490 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1507 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1491 user_config) | 1508 user_config) |
1492 else: | 1509 else: |
1493 config_names = target_dicts[target_list[0]]['configurations'].keys() | 1510 config_names = target_dicts[target_list[0]]['configurations'].keys() |
1494 for config_name in config_names: | 1511 for config_name in config_names: |
1495 GenerateOutputForConfig(target_list, target_dicts, data, params, | 1512 GenerateOutputForConfig(target_list, target_dicts, data, params, |
1496 config_name) | 1513 config_name) |
OLD | NEW |