parameters: (self, config_name, config, sources, predepends,
                     precompiled_header, case_sensitive_filesystem)
return_statement: return outputs
docstring: Write build rules to compile all of |sources|.
docstring_summary: Write build rules to compile all of |sources|.
docstring_tokens: Write build rules to compile all of |sources| .
function: def WriteSources(self, config_name, config, sources, predepends,
                     precompiled_header, case_sensitive_filesystem):
      """Write build rules to compile all of |sources|."""
      if self.toolset == 'host':
        self.ninja.variable('ar', '$ar_host')
        self.ninja.variable('cc', '$cc_host')
        self.ninja.variable('cxx', '$cxx_host')
        self.ninja.variable('ld', '$ld_host')
  
      extra_defines = []
      if self.flavor == 'mac':
        cflags = self.xcode_settings.GetCflags(config_name)
        cflags_c = self.xcode_settings.GetCflagsC(config_name)
        cflags_cc = self.xcode_settings.GetCflagsCC(config_name)
        cflags_objc = ['$cflags_c'] + \
                      self.xcode_settings.GetCflagsObjC(config_name)
        cflags_objcc = ['$cflags_cc'] + \
                       self.xcode_settings.GetCflagsObjCC(config_name)
      elif self.flavor == 'win':
        cflags = self.msvs_settings.GetCflags(config_name)
        cflags_c = self.msvs_settings.GetCflagsC(config_name)
        cflags_cc = self.msvs_settings.GetCflagsCC(config_name)
        extra_defines = self.msvs_settings.GetComputedDefines(config_name)
        self.WriteVariableList('pdbname', [self.name + '.pdb'])
        self.WriteVariableList('pchprefix', [self.name])
      else:
        cflags = config.get('cflags', [])
        cflags_c = config.get('cflags_c', [])
        cflags_cc = config.get('cflags_cc', [])
  
      defines = config.get('defines', []) + extra_defines
      self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines])
      if self.flavor == 'win':
        self.WriteVariableList('rcflags',
            [QuoteShellArgument(self.ExpandSpecial(f), self.flavor)
             for f in self.msvs_settings.GetRcflags(config_name,
                                                    self.GypPathToNinja)])
  
      include_dirs = config.get('include_dirs', [])
      if self.flavor == 'win':
        include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs,
                                                            config_name)
      self.WriteVariableList('includes',
          [QuoteShellArgument('-I' + self.GypPathToNinja(i), self.flavor)
           for i in include_dirs])
  
      pch_commands = precompiled_header.GetPchBuildCommands()
      if self.flavor == 'mac':
        self.WriteVariableList('cflags_pch_c',
                               [precompiled_header.GetInclude('c')])
        self.WriteVariableList('cflags_pch_cc',
                               [precompiled_header.GetInclude('cc')])
        self.WriteVariableList('cflags_pch_objc',
                               [precompiled_header.GetInclude('m')])
        self.WriteVariableList('cflags_pch_objcc',
                               [precompiled_header.GetInclude('mm')])
  
      self.WriteVariableList('cflags', map(self.ExpandSpecial, cflags))
      self.WriteVariableList('cflags_c', map(self.ExpandSpecial, cflags_c))
      self.WriteVariableList('cflags_cc', map(self.ExpandSpecial, cflags_cc))
      if self.flavor == 'mac':
        self.WriteVariableList('cflags_objc', map(self.ExpandSpecial,
                                                  cflags_objc))
        self.WriteVariableList('cflags_objcc', map(self.ExpandSpecial,
                                                   cflags_objcc))
      self.ninja.newline()
      outputs = []
      for source in sources:
        filename, ext = os.path.splitext(source)
        ext = ext[1:]
        obj_ext = self.obj_ext
        if ext in ('cc', 'cpp', 'cxx'):
          command = 'cxx'
        elif ext == 'c' or (ext in ('s', 'S') and self.flavor != 'win'):
          command = 'cc'
        elif (self.flavor == 'win' and ext == 'asm' and
              self.msvs_settings.GetTargetPlatform(config_name) == 'Win32'):
          # Asm files only get auto assembled for x86 (not x64).
          command = 'asm'
          # Add the _asm suffix as msvs is capable of handling .cc and
          # .asm files of the same name without collision.
          obj_ext = '_asm.obj'
        elif self.flavor == 'mac' and ext == 'm':
          command = 'objc'
        elif self.flavor == 'mac' and ext == 'mm':
          command = 'objcxx'
        elif self.flavor == 'win' and ext == 'rc':
          command = 'rc'
          obj_ext = '.res'
        else:
          # Ignore unhandled extensions.
          continue
        input = self.GypPathToNinja(source)
        output = self.GypPathToUniqueOutput(filename + obj_ext)
        # Ninja's depfile handling gets confused when the case of a filename
        # changes on a case-insensitive file system. To work around that, always
        # convert .o filenames to lowercase on such file systems. See
        # https://github.com/martine/ninja/issues/402 for details.
        if not case_sensitive_filesystem:
          output = output.lower()
        implicit = precompiled_header.GetObjDependencies([input], [output])
        self.ninja.build(output, command, input,
                         implicit=[gch for _, _, gch in implicit],
                         order_only=predepends)
        outputs.append(output)
  
      self.WritePchTargets(pch_commands)
  
      self.ninja.newline()
      return outputs
function_tokens: def WriteSources ( self , config_name , config , sources , predepends , precompiled_header , case_sensitive_filesystem ) : if self . toolset == 'host' : self . ninja . variable ( 'ar' , '$ar_host' ) self . ninja . variable ( 'cc' , '$cc_host' ) self . ninja . variable ( 'cxx' , '$cxx_host' ) self . ninja . variable ( 'ld' , '$ld_host' ) extra_defines = [ ] if self . flavor == 'mac' : cflags = self . xcode_settings . GetCflags ( config_name ) cflags_c = self . xcode_settings . GetCflagsC ( config_name ) cflags_cc = self . xcode_settings . GetCflagsCC ( config_name ) cflags_objc = [ '$cflags_c' ] + self . xcode_settings . GetCflagsObjC ( config_name ) cflags_objcc = [ '$cflags_cc' ] + self . xcode_settings . GetCflagsObjCC ( config_name ) elif self . flavor == 'win' : cflags = self . msvs_settings . GetCflags ( config_name ) cflags_c = self . msvs_settings . GetCflagsC ( config_name ) cflags_cc = self . msvs_settings . GetCflagsCC ( config_name ) extra_defines = self . msvs_settings . GetComputedDefines ( config_name ) self . WriteVariableList ( 'pdbname' , [ self . name + '.pdb' ] ) self . WriteVariableList ( 'pchprefix' , [ self . name ] ) else : cflags = config . get ( 'cflags' , [ ] ) cflags_c = config . get ( 'cflags_c' , [ ] ) cflags_cc = config . get ( 'cflags_cc' , [ ] ) defines = config . get ( 'defines' , [ ] ) + extra_defines self . WriteVariableList ( 'defines' , [ Define ( d , self . flavor ) for d in defines ] ) if self . flavor == 'win' : self . WriteVariableList ( 'rcflags' , [ QuoteShellArgument ( self . ExpandSpecial ( f ) , self . flavor ) for f in self . msvs_settings . GetRcflags ( config_name , self . GypPathToNinja ) ] ) include_dirs = config . get ( 'include_dirs' , [ ] ) if self . flavor == 'win' : include_dirs = self . msvs_settings . AdjustIncludeDirs ( include_dirs , config_name ) self . WriteVariableList ( 'includes' , [ QuoteShellArgument ( '-I' + self . GypPathToNinja ( i ) , self . flavor ) for i in include_dirs ] ) pch_commands = precompiled_header . GetPchBuildCommands ( ) if self . flavor == 'mac' : self . WriteVariableList ( 'cflags_pch_c' , [ precompiled_header . GetInclude ( 'c' ) ] ) self . WriteVariableList ( 'cflags_pch_cc' , [ precompiled_header . GetInclude ( 'cc' ) ] ) self . WriteVariableList ( 'cflags_pch_objc' , [ precompiled_header . GetInclude ( 'm' ) ] ) self . WriteVariableList ( 'cflags_pch_objcc' , [ precompiled_header . GetInclude ( 'mm' ) ] ) self . WriteVariableList ( 'cflags' , map ( self . ExpandSpecial , cflags ) ) self . WriteVariableList ( 'cflags_c' , map ( self . ExpandSpecial , cflags_c ) ) self . WriteVariableList ( 'cflags_cc' , map ( self . ExpandSpecial , cflags_cc ) ) if self . flavor == 'mac' : self . WriteVariableList ( 'cflags_objc' , map ( self . ExpandSpecial , cflags_objc ) ) self . WriteVariableList ( 'cflags_objcc' , map ( self . ExpandSpecial , cflags_objcc ) ) self . ninja . newline ( ) outputs = [ ] for source in sources : filename , ext = os . path . splitext ( source ) ext = ext [ 1 : ] obj_ext = self . obj_ext if ext in ( 'cc' , 'cpp' , 'cxx' ) : command = 'cxx' elif ext == 'c' or ( ext in ( 's' , 'S' ) and self . flavor != 'win' ) : command = 'cc' elif ( self . flavor == 'win' and ext == 'asm' and self . msvs_settings . GetTargetPlatform ( config_name ) == 'Win32' ) : # Asm files only get auto assembled for x86 (not x64). command = 'asm' # Add the _asm suffix as msvs is capable of handling .cc and # .asm files of the same name without collision. obj_ext = '_asm.obj' elif self . flavor == 'mac' and ext == 'm' : command = 'objc' elif self . flavor == 'mac' and ext == 'mm' : command = 'objcxx' elif self . flavor == 'win' and ext == 'rc' : command = 'rc' obj_ext = '.res' else : # Ignore unhandled extensions. continue input = self . GypPathToNinja ( source ) output = self . GypPathToUniqueOutput ( filename + obj_ext ) # Ninja's depfile handling gets confused when the case of a filename # changes on a case-insensitive file system. To work around that, always # convert .o filenames to lowercase on such file systems. See # https://github.com/martine/ninja/issues/402 for details. if not case_sensitive_filesystem : output = output . lower ( ) implicit = precompiled_header . GetObjDependencies ( [ input ] , [ output ] ) self . ninja . build ( output , command , input , implicit = [ gch for _ , _ , gch in implicit ] , order_only = predepends ) outputs . append ( output ) self . WritePchTargets ( pch_commands ) self . ninja . newline ( ) return outputs