summaryrefslogtreecommitdiff
path: root/tools/aapt/Command.cpp
diff options
context:
space:
mode:
authorJosiah Gaskin <josiahgaskin@google.com>2011-06-14 13:57:09 -0700
committerJosiah Gaskin <josiahgaskin@google.com>2011-06-27 16:44:57 -0700
commit9bf34ca6f85309c65b0ebdf614cb8266401b49ba (patch)
tree50708801cb3c58aa23a32bc1a1ad39315e3aeff5 /tools/aapt/Command.cpp
parentce89f1531ed8b96b8b790b3f8b18dd4cf483f7f0 (diff)
Add dependency generation to Aapt for R.java
Make Aapt generate a dependency file in the location specified by RClassDir for R.java if the --generate-dependencies flag is set. This dependency file is then read by the ant exec loop task to see whether to recreate R.java. Change-Id: I7152dac86b6ea0e448ef65e3a95694afe233c789
Diffstat (limited to 'tools/aapt/Command.cpp')
-rw-r--r--tools/aapt/Command.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index c7dfb8fdf362..89f45df1b853 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1353,6 +1353,8 @@ int doPackage(Bundle* bundle)
status_t err;
sp<AaptAssets> assets;
int N;
+ FILE* fp;
+ String8 dependencyFile;
// -c zz_ZZ means do pseudolocalization
ResourceFilter filter;
@@ -1387,6 +1389,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
+ if (bundle->getGenDependencies()) {
+ sp<FilePathStore> pathStore = new FilePathStore;
+ assets->setFullResPaths(pathStore);
+ }
+
err = assets->slurpFromArgs(bundle);
if (err < 0) {
goto bail;
@@ -1396,7 +1405,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) {
@@ -1410,18 +1419,26 @@ int doPackage(Bundle* bundle)
goto bail;
}
+ if (bundle->getGenDependencies()) {
+ dependencyFile = String8(bundle->getRClassDir());
+ // Make sure we have a clean dependency file to start with
+ dependencyFile.appendPath("R.d");
+ 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 semicolon
+ // Split on colon
String8 libs(bundle->getExtraPackages());
- char* packageString = strtok(libs.lockBuffer(libs.length()), ";");
+ char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
while (packageString != NULL) {
err = writeResourceSymbols(bundle, assets, String8(packageString), true);
- packageString = strtok(NULL, ";");
+ packageString = strtok(NULL, ":");
}
libs.unlockBuffer();
}
@@ -1443,6 +1460,19 @@ 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) {