parameters: (self, spec, configs, extra_sources)
docstring: Write Makefile code for any 'sources' from the gyp input.
      These are source files necessary to build the current target.
      We need to handle shared_intermediate directory source files as
      a special case by copying them to the intermediate directory and
      treating them as a genereated sources. Otherwise the Android build
      rules won't pick them up.
  
      Args:
        spec, configs: input from gyp.
        extra_sources: Sources generated from Actions or Rules.
docstring_summary: Write Makefile code for any 'sources' from the gyp input.
      These are source files necessary to build the current target.
      We need to handle shared_intermediate directory source files as
      a special case by copying them to the intermediate directory and
      treating them as a genereated sources. Otherwise the Android build
      rules won't pick them up.
docstring_tokens: Write Makefile code for any sources from the gyp input . These are source files necessary to build the current target . We need to handle shared_intermediate directory source files as a special case by copying them to the intermediate directory and treating them as a genereated sources . Otherwise the Android build rules won t pick them up .
function: def WriteSources(self, spec, configs, extra_sources):
      """Write Makefile code for any 'sources' from the gyp input.
      These are source files necessary to build the current target.
      We need to handle shared_intermediate directory source files as
      a special case by copying them to the intermediate directory and
      treating them as a genereated sources. Otherwise the Android build
      rules won't pick them up.
  
      Args:
        spec, configs: input from gyp.
        extra_sources: Sources generated from Actions or Rules.
      """
      sources = filter(make.Compilable, spec.get('sources', []))
      generated_not_sources = [x for x in extra_sources if not make.Compilable(x)]
      extra_sources = filter(make.Compilable, extra_sources)
  
      # Determine and output the C++ extension used by these sources.
      # We simply find the first C++ file and use that extension.
      all_sources = sources + extra_sources
      local_cpp_extension = '.cpp'
      for source in all_sources:
        (root, ext) = os.path.splitext(source)
        if IsCPPExtension(ext):
          local_cpp_extension = ext
          break
      if local_cpp_extension != '.cpp':
        self.WriteLn('LOCAL_CPP_EXTENSION := %s' % local_cpp_extension)
  
      # We need to move any non-generated sources that are coming from the
      # shared intermediate directory out of LOCAL_SRC_FILES and put them
      # into LOCAL_GENERATED_SOURCES. We also need to move over any C++ files
      # that don't match our local_cpp_extension, since Android will only
      # generate Makefile rules for a single LOCAL_CPP_EXTENSION.
      local_files = []
      for source in sources:
        (root, ext) = os.path.splitext(source)
        if '$(gyp_shared_intermediate_dir)' in source:
          extra_sources.append(source)
        elif '$(gyp_intermediate_dir)' in source:
          extra_sources.append(source)
        elif IsCPPExtension(ext) and ext != local_cpp_extension:
          extra_sources.append(source)
        else:
          local_files.append(os.path.normpath(os.path.join(self.path, source)))
  
      # For any generated source, if it is coming from the shared intermediate
      # directory then we add a Make rule to copy them to the local intermediate
      # directory first. This is because the Android LOCAL_GENERATED_SOURCES
      # must be in the local module intermediate directory for the compile rules
      # to work properly. If the file has the wrong C++ extension, then we add
      # a rule to copy that to intermediates and use the new version.
      final_generated_sources = []
      # If a source file gets copied, we still need to add the orginal source
      # directory as header search path, for GCC searches headers in the
      # directory that contains the source file by default.
      origin_src_dirs = []
      for source in extra_sources:
        local_file = source
        if not '$(gyp_intermediate_dir)/' in local_file:
          basename = os.path.basename(local_file)
          local_file = '$(gyp_intermediate_dir)/' + basename
        (root, ext) = os.path.splitext(local_file)
        if IsCPPExtension(ext) and ext != local_cpp_extension:
          local_file = root + local_cpp_extension
        if local_file != source:
          self.WriteLn('%s: %s' % (local_file, self.LocalPathify(source)))
          self.WriteLn('\tmkdir -p $(@D); cp $< $@')
          origin_src_dirs.append(os.path.dirname(source))
        final_generated_sources.append(local_file)
  
      # We add back in all of the non-compilable stuff to make sure that the
      # make rules have dependencies on them.
      final_generated_sources.extend(generated_not_sources)
      self.WriteList(final_generated_sources, 'LOCAL_GENERATED_SOURCES')
  
      origin_src_dirs = gyp.common.uniquer(origin_src_dirs)
      origin_src_dirs = map(Sourceify, map(self.LocalPathify, origin_src_dirs))
      self.WriteList(origin_src_dirs, 'GYP_COPIED_SOURCE_ORIGIN_DIRS')
  
      self.WriteList(local_files, 'LOCAL_SRC_FILES')
  
      # Write out the flags used to compile the source; this must be done last
      # so that GYP_COPIED_SOURCE_ORIGIN_DIRS can be used as an include path.
      self.WriteSourceFlags(spec, configs)
function_tokens: def WriteSources ( self , spec , configs , extra_sources ) : sources = filter ( make . Compilable , spec . get ( 'sources' , [ ] ) ) generated_not_sources = [ x for x in extra_sources if not make . Compilable ( x ) ] extra_sources = filter ( make . Compilable , extra_sources ) # Determine and output the C++ extension used by these sources. # We simply find the first C++ file and use that extension. all_sources = sources + extra_sources local_cpp_extension = '.cpp' for source in all_sources : ( root , ext ) = os . path . splitext ( source ) if IsCPPExtension ( ext ) : local_cpp_extension = ext break if local_cpp_extension != '.cpp' : self . WriteLn ( 'LOCAL_CPP_EXTENSION := %s' % local_cpp_extension ) # We need to move any non-generated sources that are coming from the # shared intermediate directory out of LOCAL_SRC_FILES and put them # into LOCAL_GENERATED_SOURCES. We also need to move over any C++ files # that don't match our local_cpp_extension, since Android will only # generate Makefile rules for a single LOCAL_CPP_EXTENSION. local_files = [ ] for source in sources : ( root , ext ) = os . path . splitext ( source ) if '$(gyp_shared_intermediate_dir)' in source : extra_sources . append ( source ) elif '$(gyp_intermediate_dir)' in source : extra_sources . append ( source ) elif IsCPPExtension ( ext ) and ext != local_cpp_extension : extra_sources . append ( source ) else : local_files . append ( os . path . normpath ( os . path . join ( self . path , source ) ) ) # For any generated source, if it is coming from the shared intermediate # directory then we add a Make rule to copy them to the local intermediate # directory first. This is because the Android LOCAL_GENERATED_SOURCES # must be in the local module intermediate directory for the compile rules # to work properly. If the file has the wrong C++ extension, then we add # a rule to copy that to intermediates and use the new version. final_generated_sources = [ ] # If a source file gets copied, we still need to add the orginal source # directory as header search path, for GCC searches headers in the # directory that contains the source file by default. origin_src_dirs = [ ] for source in extra_sources : local_file = source if not '$(gyp_intermediate_dir)/' in local_file : basename = os . path . basename ( local_file ) local_file = '$(gyp_intermediate_dir)/' + basename ( root , ext ) = os . path . splitext ( local_file ) if IsCPPExtension ( ext ) and ext != local_cpp_extension : local_file = root + local_cpp_extension if local_file != source : self . WriteLn ( '%s: %s' % ( local_file , self . LocalPathify ( source ) ) ) self . WriteLn ( '\tmkdir -p $(@D); cp $< $@' ) origin_src_dirs . append ( os . path . dirname ( source ) ) final_generated_sources . append ( local_file ) # We add back in all of the non-compilable stuff to make sure that the # make rules have dependencies on them. final_generated_sources . extend ( generated_not_sources ) self . WriteList ( final_generated_sources , 'LOCAL_GENERATED_SOURCES' ) origin_src_dirs = gyp . common . uniquer ( origin_src_dirs ) origin_src_dirs = map ( Sourceify , map ( self . LocalPathify , origin_src_dirs ) ) self . WriteList ( origin_src_dirs , 'GYP_COPIED_SOURCE_ORIGIN_DIRS' ) self . WriteList ( local_files , 'LOCAL_SRC_FILES' ) # Write out the flags used to compile the source; this must be done last # so that GYP_COPIED_SOURCE_ORIGIN_DIRS can be used as an include path. self . WriteSourceFlags ( spec , configs )