MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / writeResourceSymbols

Function writeResourceSymbols

tools/aapt/Resource.cpp:2164–2264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2162}
2163
2164status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
2165 const String8& package, bool includePrivate)
2166{
2167 if (!bundle->getRClassDir()) {
2168 return NO_ERROR;
2169 }
2170
2171 const char* textSymbolsDest = bundle->getOutputTextSymbols();
2172
2173 String8 R("R");
2174 const size_t N = assets->getSymbols().size();
2175 for (size_t i=0; i<N; i++) {
2176 sp<AaptSymbols> symbols = assets->getSymbols().valueAt(i);
2177 String8 className(assets->getSymbols().keyAt(i));
2178 String8 dest(bundle->getRClassDir());
2179
2180 if (bundle->getMakePackageDirs()) {
2181 String8 pkg(package);
2182 const char* last = pkg.string();
2183 const char* s = last-1;
2184 do {
2185 s++;
2186 if (s > last && (*s == '.' || *s == 0)) {
2187 String8 part(last, s-last);
2188 dest.appendPath(part);
2189#ifdef HAVE_MS_C_RUNTIME
2190 _mkdir(dest.string());
2191#else
2192 mkdir(dest.string(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP);
2193#endif
2194 last = s+1;
2195 }
2196 } while (*s);
2197 }
2198 dest.appendPath(className);
2199 dest.append(".java");
2200 FILE* fp = fopen(dest.string(), "w+");
2201 if (fp == NULL) {
2202 fprintf(stderr, "ERROR: Unable to open class file %s: %s\n",
2203 dest.string(), strerror(errno));
2204 return UNKNOWN_ERROR;
2205 }
2206 if (bundle->getVerbose()) {
2207 printf(" Writing symbols for class %s.\n", className.string());
2208 }
2209
2210 fprintf(fp,
2211 "/* AUTO-GENERATED FILE. DO NOT MODIFY.\n"
2212 " *\n"
2213 " * This class was automatically generated by the\n"
2214 " * aapt tool from the resource data it found. It\n"
2215 " * should not be modified by hand.\n"
2216 " */\n"
2217 "\n"
2218 "package %s;\n\n", package.string());
2219
2220 status_t err = writeSymbolClass(fp, assets, includePrivate, symbols,
2221 className, 0, bundle->getNonConstantId());

Callers 1

doPackageFunction · 0.85

Calls 14

writeSymbolClassFunction · 0.85
writeTextSymbolClassFunction · 0.85
getRClassDirMethod · 0.80
getOutputTextSymbolsMethod · 0.80
getMakePackageDirsMethod · 0.80
stringMethod · 0.80
appendPathMethod · 0.80
getVerboseMethod · 0.80
getNonConstantIdMethod · 0.80
getGenDependenciesMethod · 0.80
sizeMethod · 0.65
appendMethod · 0.65

Tested by

no test coverage detected