X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/2a35a945dbd5cb2edf6ce32f6bd9e37ca1af4c49..c1b83bdbc6526f4c8f366bc3716f46b4ad93b0fd:/Command.cpp diff --git a/Command.cpp b/Command.cpp index 7852197..daf53e0 100644 --- a/Command.cpp +++ b/Command.cpp @@ -1508,6 +1508,8 @@ int doPackage(Bundle* bundle) status_t err; sp assets; int N; + FILE* fp; + String8 dependencyFile; // -c zz_ZZ means do pseudolocalization ResourceFilter filter; @@ -1542,6 +1544,16 @@ int doPackage(Bundle* bundle) // 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 resPathStore = new FilePathStore; + assets->setFullResPaths(resPathStore); + sp assetPathStore = new FilePathStore; + assets->setFullAssetPaths(assetPathStore); + } + err = assets->slurpFromArgs(bundle); if (err < 0) { goto bail; @@ -1551,7 +1563,7 @@ int doPackage(Bundle* bundle) 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) { @@ -1565,10 +1577,36 @@ int doPackage(Bundle* bundle) 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); @@ -1602,6 +1640,18 @@ int doPackage(Bundle* bundle) } } + 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()) { @@ -1609,3 +1659,25 @@ bail: } 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; +}