Generate a native rules file. Arguments: p: the target project rules: the set of rules to include output_dir: the directory in which the project/gyp resides spec: the project dict options: global generator options
(p, rules, output_dir, spec, options)
| 609 | |
| 610 | |
| 611 | def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options): |
| 612 | """Generate a native rules file. |
| 613 | |
| 614 | Arguments: |
| 615 | p: the target project |
| 616 | rules: the set of rules to include |
| 617 | output_dir: the directory in which the project/gyp resides |
| 618 | spec: the project dict |
| 619 | options: global generator options |
| 620 | """ |
| 621 | rules_filename = "{}{}.rules".format(spec["target_name"], options.suffix) |
| 622 | rules_file = MSVSToolFile.Writer( |
| 623 | os.path.join(output_dir, rules_filename), spec["target_name"] |
| 624 | ) |
| 625 | # Add each rule. |
| 626 | for r in rules: |
| 627 | rule_name = r["rule_name"] |
| 628 | rule_ext = r["extension"] |
| 629 | inputs = _FixPaths(r.get("inputs", [])) |
| 630 | outputs = _FixPaths(r.get("outputs", [])) |
| 631 | # Skip a rule with no action and no inputs. |
| 632 | if "action" not in r and not r.get("rule_sources", []): |
| 633 | continue |
| 634 | cmd = _BuildCommandLineForRule(spec, r, has_input_path=True, do_setup_env=True) |
| 635 | rules_file.AddCustomBuildRule( |
| 636 | name=rule_name, |
| 637 | description=r.get("message", rule_name), |
| 638 | extensions=[rule_ext], |
| 639 | additional_dependencies=inputs, |
| 640 | outputs=outputs, |
| 641 | cmd=cmd, |
| 642 | ) |
| 643 | # Write out rules file. |
| 644 | rules_file.WriteIfChanged() |
| 645 | |
| 646 | # Add rules file to project. |
| 647 | p.AddToolFile(rules_filename) |
| 648 | |
| 649 | |
| 650 | def _Cygwinify(path): |
no test coverage detected