]> git.saurik.com Git - android/aapt.git/blobdiff - Command.cpp
Fix "Too many open files" error for aapt built with Mac OS X SDK 10.6.
[android/aapt.git] / Command.cpp
index daf53e06bd7566457694975f15d7df616eeb74d6..637c27da65f931891303b4cdeccc213d53b327ae 100644 (file)
@@ -5,6 +5,7 @@
 //
 #include "Main.h"
 #include "Bundle.h"
 //
 #include "Main.h"
 #include "Bundle.h"
+#include "ResourceFilter.h"
 #include "ResourceTable.h"
 #include "XMLNode.h"
 
 #include "ResourceTable.h"
 #include "XMLNode.h"
 
@@ -368,6 +369,7 @@ enum {
     REQUIRES_SMALLEST_WIDTH_DP_ATTR = 0x01010364,
     COMPATIBLE_WIDTH_LIMIT_DP_ATTR = 0x01010365,
     LARGEST_WIDTH_LIMIT_DP_ATTR = 0x01010366,
     REQUIRES_SMALLEST_WIDTH_DP_ATTR = 0x01010364,
     COMPATIBLE_WIDTH_LIMIT_DP_ATTR = 0x01010365,
     LARGEST_WIDTH_LIMIT_DP_ATTR = 0x01010366,
+    PUBLIC_KEY_ATTR = 0x010103a6,
 };
 
 const char *getComponentName(String8 &pkgName, String8 &componentName) {
 };
 
 const char *getComponentName(String8 &pkgName, String8 &componentName) {
@@ -1021,6 +1023,15 @@ int doDump(Bundle* bundle)
                     } else if (tag == "compatible-screens") {
                         printCompatibleScreens(tree);
                         depth--;
                     } else if (tag == "compatible-screens") {
                         printCompatibleScreens(tree);
                         depth--;
+                    } else if (tag == "package-verifier") {
+                        String8 name = getAttribute(tree, NAME_ATTR, &error);
+                        if (name != "" && error == "") {
+                            String8 publicKey = getAttribute(tree, PUBLIC_KEY_ATTR, &error);
+                            if (publicKey != "" && error == "") {
+                                printf("package-verifier: name='%s' publicKey='%s'\n",
+                                        name.string(), publicKey.string());
+                            }
+                        }
                     }
                 } else if (depth == 3 && withinApplication) {
                     withinActivity = false;
                     }
                 } else if (depth == 3 && withinApplication) {
                     withinActivity = false;
@@ -1546,7 +1557,9 @@ int doPackage(Bundle* bundle)
     assets = new AaptAssets();
 
     // Set up the resource gathering in assets if we're going to generate
     assets = new AaptAssets();
 
     // Set up the resource gathering in assets if we're going to generate
-    // dependency files
+    // dependency files. Every time we encounter a resource while slurping
+    // the tree, we'll add it to these stores so we have full resource paths
+    // to write to a dependency file.
     if (bundle->getGenDependencies()) {
         sp<FilePathStore> resPathStore = new FilePathStore;
         assets->setFullResPaths(resPathStore);
     if (bundle->getGenDependencies()) {
         sp<FilePathStore> resPathStore = new FilePathStore;
         assets->setFullResPaths(resPathStore);
@@ -1560,7 +1573,7 @@ int doPackage(Bundle* bundle)
     }
 
     if (bundle->getVerbose()) {
     }
 
     if (bundle->getVerbose()) {
-        assets->print();
+        assets->print(String8());
     }
 
     // If they asked for any fileAs that need to be compiled, do so.
     }
 
     // If they asked for any fileAs that need to be compiled, do so.
@@ -1577,15 +1590,20 @@ int doPackage(Bundle* bundle)
         goto bail;
     }
 
         goto bail;
     }
 
+    // If we've been asked to generate a dependency file, do that here
     if (bundle->getGenDependencies()) {
     if (bundle->getGenDependencies()) {
+        // If this is the packaging step, generate the dependency file next to
+        // the output apk (e.g. bin/resources.ap_.d)
         if (outputAPKFile) {
             dependencyFile = String8(outputAPKFile);
         if (outputAPKFile) {
             dependencyFile = String8(outputAPKFile);
-            // Strip the extension and add new one
-            dependencyFile = dependencyFile.getBasePath();
+            // Add the .d extension to the dependency file.
             dependencyFile.append(".d");
         } else {
             dependencyFile.append(".d");
         } else {
+            // Else if this is the R.java dependency generation step,
+            // generate the dependency file in the R.java package subdirectory
+            // e.g. gen/com/foo/app/R.java.d
             dependencyFile = String8(bundle->getRClassDir());
             dependencyFile = String8(bundle->getRClassDir());
-            dependencyFile.appendPath("R.d");
+            dependencyFile.appendPath("R.java.d");
         }
         // Make sure we have a clean dependency file to start with
         fp = fopen(dependencyFile, "w");
         }
         // Make sure we have a clean dependency file to start with
         fp = fopen(dependencyFile, "w");
@@ -1595,13 +1613,18 @@ int doPackage(Bundle* bundle)
     // Write out R.java constants
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
         if (bundle->getCustomPackage() == NULL) {
     // Write out R.java constants
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
         if (bundle->getCustomPackage() == NULL) {
+            // Write the R.java file into the appropriate class directory
+            // e.g. gen/com/foo/app/R.java
             err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
             err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
-            // Copy R.java for libraries
+            // If we have library files, we're going to write our R.java file into
+            // the appropriate class directory for those libraries as well.
+            // e.g. gen/com/foo/app/lib/R.java
             if (bundle->getExtraPackages() != NULL) {
                 // Split on colon
                 String8 libs(bundle->getExtraPackages());
                 char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
                 while (packageString != NULL) {
             if (bundle->getExtraPackages() != NULL) {
                 // Split on colon
                 String8 libs(bundle->getExtraPackages());
                 char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
                 while (packageString != NULL) {
+                    // Write the R.java file out with the correct package name
                     err = writeResourceSymbols(bundle, assets, String8(packageString), true);
                     packageString = strtok(NULL, ":");
                 }
                     err = writeResourceSymbols(bundle, assets, String8(packageString), true);
                     packageString = strtok(NULL, ":");
                 }
@@ -1640,6 +1663,10 @@ int doPackage(Bundle* bundle)
         }
     }
 
         }
     }
 
+    // If we've been asked to generate a dependency file, we need to finish up here.
+    // the writeResourceSymbols and writeAPK functions have already written the target
+    // half of the dependency file, now we need to write the prerequisites. (files that
+    // the R.java file or .ap_ file depend on)
     if (bundle->getGenDependencies()) {
         // Now that writeResourceSymbols or writeAPK has taken care of writing
         // the targets to our dependency file, we'll write the prereqs
     if (bundle->getGenDependencies()) {
         // Now that writeResourceSymbols or writeAPK has taken care of writing
         // the targets to our dependency file, we'll write the prereqs
@@ -1647,7 +1674,8 @@ int doPackage(Bundle* bundle)
         fprintf(fp, " : ");
         bool includeRaw = (outputAPKFile != NULL);
         err = writeDependencyPreReqs(bundle, assets, fp, includeRaw);
         fprintf(fp, " : ");
         bool includeRaw = (outputAPKFile != NULL);
         err = writeDependencyPreReqs(bundle, assets, fp, includeRaw);
-        // Also manually add the AndroidManifeset since it's a non-asset
+        // Also manually add the AndroidManifeset since it's not under res/ or assets/
+        // and therefore was not added to our pathstores during slurping
         fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile());
         fclose(fp);
     }
         fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile());
         fclose(fp);
     }