(self, name, args, description, is_cygwin, env, pool,
                        depfile=None)
return rule_name, args
Write out a new ninja "rule" statement for a given command.

    Returns the name of the new rule, and a copy of |args| with variables
    expanded.
Write out a new ninja "rule" statement for a given command.
Write out a new ninja rule statement for a given command .
def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool,
                        depfile=None):
    """Write out a new ninja "rule" statement for a given command.

    Returns the name of the new rule, and a copy of |args| with variables
    expanded."""

    if self.flavor == 'win':
      args = [self.msvs_settings.ConvertVSMacros(
                  arg, self.base_to_build, config=self.config_name)
              for arg in args]
      description = self.msvs_settings.ConvertVSMacros(
          description, config=self.config_name)
    elif self.flavor == 'mac':
      # |env| is an empty list on non-mac.
      args = [gyp.xcode_emulation.ExpandEnvVars(arg, env) for arg in args]
      description = gyp.xcode_emulation.ExpandEnvVars(description, env)

    # TODO: we shouldn't need to qualify names; we do it because
    # currently the ninja rule namespace is global, but it really
    # should be scoped to the subninja.
    rule_name = self.name
    if self.toolset == 'target':
      rule_name += '.' + self.toolset
    rule_name += '.' + name
    rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name)

    # Remove variable references, but not if they refer to the magic rule
    # variables.  This is not quite right, as it also protects these for
    # actions, not just for rules where they are valid. Good enough.
    protect = [ '${root}', '${dirname}', '${source}', '${ext}', '${name}' ]
    protect = '(?!' + '|'.join(map(re.escape, protect)) + ')'
    description = re.sub(protect + r'\$', '_', description)

    # gyp dictates that commands are run from the base directory.
    # cd into the directory before running, and adjust paths in
    # the arguments to point to the proper locations.
    rspfile = None
    rspfile_content = None
    args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args]
    if self.flavor == 'win':
      rspfile = rule_name + '.$unique_name.rsp'
      # The cygwin case handles this inside the bash sub-shell.
      run_in = '' if is_cygwin else ' ' + self.build_to_base
      if is_cygwin:
        rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine(
            args, self.build_to_base)
      else:
        rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args)
      command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable +
                 rspfile + run_in)
    else:
      env = self.ComputeExportEnvString(env)
      command = gyp.common.EncodePOSIXShellList(args)
      command = 'cd %s; ' % self.build_to_base + env + command

    # GYP rules/actions express being no-ops by not touching their outputs.
    # Avoid executing downstream dependencies in this case by specifying
    # restat=1 to ninja.
    self.ninja.rule(rule_name, command, description, depfile=depfile,
                    restat=True, pool=pool,
                    rspfile=rspfile, rspfile_content=rspfile_content)
    self.ninja.newline()

    return rule_name, args
def WriteNewNinjaRule ( self , name , args , description , is_cygwin , env , pool , depfile = None ) : if self . flavor == 'win' : args = [ self . msvs_settings . ConvertVSMacros ( arg , self . base_to_build , config = self . config_name ) for arg in args ] description = self . msvs_settings . ConvertVSMacros ( description , config = self . config_name ) elif self . flavor == 'mac' : # |env| is an empty list on non-mac. args = [ gyp . xcode_emulation . ExpandEnvVars ( arg , env ) for arg in args ] description = gyp . xcode_emulation . ExpandEnvVars ( description , env ) # TODO: we shouldn't need to qualify names; we do it because # currently the ninja rule namespace is global, but it really # should be scoped to the subninja. rule_name = self . name if self . toolset == 'target' : rule_name += '.' + self . toolset rule_name += '.' + name rule_name = re . sub ( '[^a-zA-Z0-9_]' , '_' , rule_name ) # Remove variable references, but not if they refer to the magic rule # variables.  This is not quite right, as it also protects these for # actions, not just for rules where they are valid. Good enough. protect = [ '${root}' , '${dirname}' , '${source}' , '${ext}' , '${name}' ] protect = '(?!' + '|' . join ( map ( re . escape , protect ) ) + ')' description = re . sub ( protect + r'\$' , '_' , description ) # gyp dictates that commands are run from the base directory. # cd into the directory before running, and adjust paths in # the arguments to point to the proper locations. rspfile = None rspfile_content = None args = [ self . ExpandSpecial ( arg , self . base_to_build ) for arg in args ] if self . flavor == 'win' : rspfile = rule_name + '.$unique_name.rsp' # The cygwin case handles this inside the bash sub-shell. run_in = '' if is_cygwin else ' ' + self . build_to_base if is_cygwin : rspfile_content = self . msvs_settings . BuildCygwinBashCommandLine ( args , self . build_to_base ) else : rspfile_content = gyp . msvs_emulation . EncodeRspFileList ( args ) command = ( '%s gyp-win-tool action-wrapper $arch ' % sys . executable + rspfile + run_in ) else : env = self . ComputeExportEnvString ( env ) command = gyp . common . EncodePOSIXShellList ( args ) command = 'cd %s; ' % self . build_to_base + env + command # GYP rules/actions express being no-ops by not touching their outputs. # Avoid executing downstream dependencies in this case by specifying # restat=1 to ninja. self . ninja . rule ( rule_name , command , description , depfile = depfile , restat = True , pool = pool , rspfile = rspfile , rspfile_content = rspfile_content ) self . ninja . newline ( ) return rule_name , args