status_t err;
sp<AaptAssets> assets;
int N;
+ FILE* fp;
+ String8 dependencyFile;
// -c zz_ZZ means do pseudolocalization
ResourceFilter filter;
// Load the assets.
assets = new AaptAssets();
+
+ // Set up the resource gathering in assets if we're going to generate
+ // dependency files
+ if (bundle->getGenDependencies()) {
+ sp<FilePathStore> resPathStore = new FilePathStore;
+ assets->setFullResPaths(resPathStore);
+ sp<FilePathStore> assetPathStore = new FilePathStore;
+ assets->setFullAssetPaths(assetPathStore);
+ }
+
err = assets->slurpFromArgs(bundle);
if (err < 0) {
goto bail;
assets->print();
}
- // If they asked for any files that need to be compiled, do so.
+ // If they asked for any fileAs that need to be compiled, do so.
if (bundle->getResourceSourceDirs().size() || bundle->getAndroidManifestFile()) {
err = buildResources(bundle, assets);
if (err != 0) {
goto bail;
}
+ if (bundle->getGenDependencies()) {
+ if (outputAPKFile) {
+ dependencyFile = String8(outputAPKFile);
+ // Strip the extension and add new one
+ dependencyFile = dependencyFile.getBasePath();
+ dependencyFile.append(".d");
+ } else {
+ dependencyFile = String8(bundle->getRClassDir());
+ dependencyFile.appendPath("R.d");
+ }
+ // Make sure we have a clean dependency file to start with
+ fp = fopen(dependencyFile, "w");
+ fclose(fp);
+ }
+
// Write out R.java constants
if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
if (bundle->getCustomPackage() == NULL) {
err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+ // Copy R.java for libraries
+ if (bundle->getExtraPackages() != NULL) {
+ // Split on colon
+ String8 libs(bundle->getExtraPackages());
+ char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
+ while (packageString != NULL) {
+ err = writeResourceSymbols(bundle, assets, String8(packageString), true);
+ packageString = strtok(NULL, ":");
+ }
+ libs.unlockBuffer();
+ }
} else {
const String8 customPkg(bundle->getCustomPackage());
err = writeResourceSymbols(bundle, assets, customPkg, true);
}
}
+ if (bundle->getGenDependencies()) {
+ // Now that writeResourceSymbols or writeAPK has taken care of writing
+ // the targets to our dependency file, we'll write the prereqs
+ fp = fopen(dependencyFile, "a+");
+ fprintf(fp, " : ");
+ bool includeRaw = (outputAPKFile != NULL);
+ err = writeDependencyPreReqs(bundle, assets, fp, includeRaw);
+ // Also manually add the AndroidManifeset since it's a non-asset
+ fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile());
+ fclose(fp);
+ }
+
retVal = 0;
bail:
if (SourcePos::hasErrors()) {
}
return retVal;
}
+
+/*
+ * Do PNG Crunching
+ * PRECONDITIONS
+ * -S flag points to a source directory containing drawable* folders
+ * -C flag points to destination directory. The folder structure in the
+ * source directory will be mirrored to the destination (cache) directory
+ *
+ * POSTCONDITIONS
+ * Destination directory will be updated to match the PNG files in
+ * the source directory.
+ */
+int doCrunch(Bundle* bundle)
+{
+ fprintf(stdout, "Crunching PNG Files in ");
+ fprintf(stdout, "source dir: %s\n", bundle->getResourceSourceDirs()[0]);
+ fprintf(stdout, "To destination dir: %s\n", bundle->getCrunchedOutputDir());
+
+ updatePreProcessedCache(bundle);
+
+ return NO_ERROR;
+}