summaryrefslogtreecommitdiff
path: root/tools/aapt/Command.cpp
diff options
context:
space:
mode:
author Josiah Gaskin <josiahgaskin@google.com> 2011-06-27 16:26:02 -0700
committer Josiah Gaskin <josiahgaskin@google.com> 2011-07-18 16:37:55 -0700
commit03589cc65355220e0a4a0c816189a9fa25cc81fc (patch)
treeebe98e64c530708e8709025e8ad051c714eab9a3 /tools/aapt/Command.cpp
parent9bf34ca6f85309c65b0ebdf614cb8266401b49ba (diff)
Add generation of dependency file for .ap_ package
Make Aapt generate a dependency file in the same directory as the output ap_ file if the --generate-dependencies flag is set. This dependency file can then be read by the ant exec loop task to see whether to repackage resources. Change-Id: I763679414daf76369700aa599c26dcf78d4de099
Diffstat (limited to 'tools/aapt/Command.cpp')
-rw-r--r--tools/aapt/Command.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 89f45df1b853..8447d7436d5b 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1390,10 +1390,13 @@ int doPackage(Bundle* bundle)
// Load the assets.
assets = new AaptAssets();
- // Set up the resource gathering in assets if we're trying to make R.java
+ // Set up the resource gathering in assets if we're going to generate
+ // dependency files
if (bundle->getGenDependencies()) {
- sp<FilePathStore> pathStore = new FilePathStore;
- assets->setFullResPaths(pathStore);
+ sp<FilePathStore> resPathStore = new FilePathStore;
+ assets->setFullResPaths(resPathStore);
+ sp<FilePathStore> assetPathStore = new FilePathStore;
+ assets->setFullAssetPaths(assetPathStore);
}
err = assets->slurpFromArgs(bundle);
@@ -1420,9 +1423,16 @@ int doPackage(Bundle* bundle)
}
if (bundle->getGenDependencies()) {
- dependencyFile = String8(bundle->getRClassDir());
+ 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
- dependencyFile.appendPath("R.d");
fp = fopen(dependencyFile, "w");
fclose(fp);
}
@@ -1460,19 +1470,6 @@ int doPackage(Bundle* bundle)
}
}
- if (bundle->getGenDependencies()) {
- // Now that writeResourceSymbols has taken care of writing the
- // dependency targets to the dependencyFile, we'll write the
- // pre-requisites.
- fp = fopen(dependencyFile, "a+");
- fprintf(fp, " : ");
- err = writeDependencyPreReqs(bundle, assets, fp);
-
- // Also manually add the AndroidManifeset since it's a non-asset
- fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile());
- fclose(fp);
- }
-
// Write out the ProGuard file
err = writeProguardFile(bundle, assets);
if (err < 0) {
@@ -1488,6 +1485,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()) {