parameters: (p, rules, output_dir, spec, options)
docstring: 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
docstring_summary: Generate a native rules file.
docstring_tokens: Generate a native rules file .
function: def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options):
    """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
    """
    rules_filename = '%s%s.rules' % (spec['target_name'],
                                     options.suffix)
    rules_file = MSVSToolFile.Writer(os.path.join(output_dir, rules_filename),
                                     spec['target_name'])
    # Add each rule.
    for r in rules:
      rule_name = r['rule_name']
      rule_ext = r['extension']
      inputs = _FixPaths(r.get('inputs', []))
      outputs = _FixPaths(r.get('outputs', []))
      # Skip a rule with no action and no inputs.
      if 'action' not in r and not r.get('rule_sources', []):
        continue
      cmd = _BuildCommandLineForRule(spec, r, has_input_path=True,
                                     do_setup_env=True)
      rules_file.AddCustomBuildRule(name=rule_name,
                                    description=r.get('message', rule_name),
                                    extensions=[rule_ext],
                                    additional_dependencies=inputs,
                                    outputs=outputs,
                                    cmd=cmd)
    # Write out rules file.
    rules_file.WriteIfChanged()
  
    # Add rules file to project.
    p.AddToolFile(rules_filename)
function_tokens: def _GenerateNativeRulesForMSVS ( p , rules , output_dir , spec , options ) : rules_filename = '%s%s.rules' % ( spec [ 'target_name' ] , options . suffix ) rules_file = MSVSToolFile . Writer ( os . path . join ( output_dir , rules_filename ) , spec [ 'target_name' ] ) # Add each rule. for r in rules : rule_name = r [ 'rule_name' ] rule_ext = r [ 'extension' ] inputs = _FixPaths ( r . get ( 'inputs' , [ ] ) ) outputs = _FixPaths ( r . get ( 'outputs' , [ ] ) ) # Skip a rule with no action and no inputs. if 'action' not in r and not r . get ( 'rule_sources' , [ ] ) : continue cmd = _BuildCommandLineForRule ( spec , r , has_input_path = True , do_setup_env = True ) rules_file . AddCustomBuildRule ( name = rule_name , description = r . get ( 'message' , rule_name ) , extensions = [ rule_ext ] , additional_dependencies = inputs , outputs = outputs , cmd = cmd ) # Write out rules file. rules_file . WriteIfChanged ( ) # Add rules file to project. p . AddToolFile ( rules_filename )