(self, module_name, all_sources, link_deps)
Write a set of LOCAL_XXX definitions for Android NDK.

    These variable definitions will be used by Android NDK but do nothing for
    non-Android applications.

    Arguments:
      module_name: Android NDK module name, which must be unique among all
          module names.
      all_sources: A list of source files (will be filtered by Compilable).
      link_deps: A list of link dependencies, which must be sorted in
          the order from dependencies to dependents.
Write a set of LOCAL_XXX definitions for Android NDK.
Write a set of LOCAL_XXX definitions for Android NDK .
def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps):
    """Write a set of LOCAL_XXX definitions for Android NDK.

    These variable definitions will be used by Android NDK but do nothing for
    non-Android applications.

    Arguments:
      module_name: Android NDK module name, which must be unique among all
          module names.
      all_sources: A list of source files (will be filtered by Compilable).
      link_deps: A list of link dependencies, which must be sorted in
          the order from dependencies to dependents.
    """
    if self.type not in ('executable', 'shared_library', 'static_library'):
      return

    self.WriteLn('# Variable definitions for Android applications')
    self.WriteLn('include $(CLEAR_VARS)')
    self.WriteLn('LOCAL_MODULE := ' + module_name)
    self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) '
                 '$(DEFS_$(BUILDTYPE)) '
                 # LOCAL_CFLAGS is applied to both of C and C++.  There is
                 # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C
                 # sources.
                 '$(CFLAGS_C_$(BUILDTYPE)) '
                 # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while
                 # LOCAL_C_INCLUDES does not expect it.  So put it in
                 # LOCAL_CFLAGS.
                 '$(INCS_$(BUILDTYPE))')
    # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred.
    self.WriteLn('LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))')
    self.WriteLn('LOCAL_C_INCLUDES :=')
    self.WriteLn('LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)')

    # Detect the C++ extension.
    cpp_ext = {'.cc': 0, '.cpp': 0, '.cxx': 0}
    default_cpp_ext = '.cpp'
    for filename in all_sources:
      ext = os.path.splitext(filename)[1]
      if ext in cpp_ext:
        cpp_ext[ext] += 1
        if cpp_ext[ext] > cpp_ext[default_cpp_ext]:
          default_cpp_ext = ext
    self.WriteLn('LOCAL_CPP_EXTENSION := ' + default_cpp_ext)

    self.WriteList(map(self.Absolutify, filter(Compilable, all_sources)),
                   'LOCAL_SRC_FILES')

    # Filter out those which do not match prefix and suffix and produce
    # the resulting list without prefix and suffix.
    def DepsToModules(deps, prefix, suffix):
      modules = []
      for filepath in deps:
        filename = os.path.basename(filepath)
        if filename.startswith(prefix) and filename.endswith(suffix):
          modules.append(filename[len(prefix):-len(suffix)])
      return modules

    # Retrieve the default value of 'SHARED_LIB_SUFFIX'
    params = {'flavor': 'linux'}
    default_variables = {}
    CalculateVariables(default_variables, params)

    self.WriteList(
        DepsToModules(link_deps,
                      generator_default_variables['SHARED_LIB_PREFIX'],
                      default_variables['SHARED_LIB_SUFFIX']),
        'LOCAL_SHARED_LIBRARIES')
    self.WriteList(
        DepsToModules(link_deps,
                      generator_default_variables['STATIC_LIB_PREFIX'],
                      generator_default_variables['STATIC_LIB_SUFFIX']),
        'LOCAL_STATIC_LIBRARIES')

    if self.type == 'executable':
      self.WriteLn('include $(BUILD_EXECUTABLE)')
    elif self.type == 'shared_library':
      self.WriteLn('include $(BUILD_SHARED_LIBRARY)')
    elif self.type == 'static_library':
      self.WriteLn('include $(BUILD_STATIC_LIBRARY)')
    self.WriteLn()
def WriteAndroidNdkModuleRule ( self , module_name , all_sources , link_deps ) : if self . type not in ( 'executable' , 'shared_library' , 'static_library' ) : return self . WriteLn ( '# Variable definitions for Android applications' ) self . WriteLn ( 'include $(CLEAR_VARS)' ) self . WriteLn ( 'LOCAL_MODULE := ' + module_name ) self . WriteLn ( 'LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) ' '$(DEFS_$(BUILDTYPE)) ' # LOCAL_CFLAGS is applied to both of C and C++.  There is # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C # sources. '$(CFLAGS_C_$(BUILDTYPE)) ' # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while # LOCAL_C_INCLUDES does not expect it.  So put it in # LOCAL_CFLAGS. '$(INCS_$(BUILDTYPE))' ) # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred. self . WriteLn ( 'LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))' ) self . WriteLn ( 'LOCAL_C_INCLUDES :=' ) self . WriteLn ( 'LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)' ) # Detect the C++ extension. cpp_ext = { '.cc' : 0 , '.cpp' : 0 , '.cxx' : 0 } default_cpp_ext = '.cpp' for filename in all_sources : ext = os . path . splitext ( filename ) [ 1 ] if ext in cpp_ext : cpp_ext [ ext ] += 1 if cpp_ext [ ext ] > cpp_ext [ default_cpp_ext ] : default_cpp_ext = ext self . WriteLn ( 'LOCAL_CPP_EXTENSION := ' + default_cpp_ext ) self . WriteList ( map ( self . Absolutify , filter ( Compilable , all_sources ) ) , 'LOCAL_SRC_FILES' ) # Filter out those which do not match prefix and suffix and produce # the resulting list without prefix and suffix. def DepsToModules ( deps , prefix , suffix ) : modules = [ ] for filepath in deps : filename = os . path . basename ( filepath ) if filename . startswith ( prefix ) and filename . endswith ( suffix ) : modules . append ( filename [ len ( prefix ) : - len ( suffix ) ] ) return modules # Retrieve the default value of 'SHARED_LIB_SUFFIX' params = { 'flavor' : 'linux' } default_variables = { } CalculateVariables ( default_variables , params ) self . WriteList ( DepsToModules ( link_deps , generator_default_variables [ 'SHARED_LIB_PREFIX' ] , default_variables [ 'SHARED_LIB_SUFFIX' ] ) , 'LOCAL_SHARED_LIBRARIES' ) self . WriteList ( DepsToModules ( link_deps , generator_default_variables [ 'STATIC_LIB_PREFIX' ] , generator_default_variables [ 'STATIC_LIB_SUFFIX' ] ) , 'LOCAL_STATIC_LIBRARIES' ) if self . type == 'executable' : self . WriteLn ( 'include $(BUILD_EXECUTABLE)' ) elif self . type == 'shared_library' : self . WriteLn ( 'include $(BUILD_SHARED_LIBRARY)' ) elif self . type == 'static_library' : self . WriteLn ( 'include $(BUILD_STATIC_LIBRARY)' ) self . WriteLn ( )