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.
(self, module_name, all_sources, link_deps)
| 2187 | self.WriteLn() |
| 2188 | |
| 2189 | def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps): |
| 2190 | """Write a set of LOCAL_XXX definitions for Android NDK. |
| 2191 | |
| 2192 | These variable definitions will be used by Android NDK but do nothing for |
| 2193 | non-Android applications. |
| 2194 | |
| 2195 | Arguments: |
| 2196 | module_name: Android NDK module name, which must be unique among all |
| 2197 | module names. |
| 2198 | all_sources: A list of source files (will be filtered by Compilable). |
| 2199 | link_deps: A list of link dependencies, which must be sorted in |
| 2200 | the order from dependencies to dependents. |
| 2201 | """ |
| 2202 | if self.type not in ("executable", "shared_library", "static_library"): |
| 2203 | return |
| 2204 | |
| 2205 | self.WriteLn("# Variable definitions for Android applications") |
| 2206 | self.WriteLn("include $(CLEAR_VARS)") |
| 2207 | self.WriteLn("LOCAL_MODULE := " + module_name) |
| 2208 | self.WriteLn( |
| 2209 | "LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) " |
| 2210 | "$(DEFS_$(BUILDTYPE)) " |
| 2211 | # LOCAL_CFLAGS is applied to both of C and C++. There is |
| 2212 | # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C |
| 2213 | # sources. |
| 2214 | "$(CFLAGS_C_$(BUILDTYPE)) " |
| 2215 | # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while |
| 2216 | # LOCAL_C_INCLUDES does not expect it. So put it in |
| 2217 | # LOCAL_CFLAGS. |
| 2218 | "$(INCS_$(BUILDTYPE))" |
| 2219 | ) |
| 2220 | # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred. |
| 2221 | self.WriteLn("LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))") |
| 2222 | self.WriteLn("LOCAL_C_INCLUDES :=") |
| 2223 | self.WriteLn("LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)") |
| 2224 | |
| 2225 | # Detect the C++ extension. |
| 2226 | cpp_ext = {".cc": 0, ".cpp": 0, ".cxx": 0} |
| 2227 | default_cpp_ext = ".cpp" |
| 2228 | for filename in all_sources: |
| 2229 | ext = os.path.splitext(filename)[1] |
| 2230 | if ext in cpp_ext: |
| 2231 | cpp_ext[ext] += 1 |
| 2232 | if cpp_ext[ext] > cpp_ext[default_cpp_ext]: |
| 2233 | default_cpp_ext = ext |
| 2234 | self.WriteLn("LOCAL_CPP_EXTENSION := " + default_cpp_ext) |
| 2235 | |
| 2236 | self.WriteList( |
| 2237 | list(map(self.Absolutify, filter(Compilable, all_sources))), |
| 2238 | "LOCAL_SRC_FILES", |
| 2239 | ) |
| 2240 | |
| 2241 | # Filter out those which do not match prefix and suffix and produce |
| 2242 | # the resulting list without prefix and suffix. |
| 2243 | def DepsToModules(deps, prefix, suffix): |
| 2244 | modules = [] |
| 2245 | for filepath in deps: |
| 2246 | filename = os.path.basename(filepath) |