]> git.saurik.com Git - android/aapt.git/commitdiff
am a125c937: resolved conflicts for merge of 2c311be7 to honeycomb-plus-aosp
authorXavier Ducrohet <xav@android.com>
Thu, 21 Jul 2011 00:18:04 +0000 (17:18 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Thu, 21 Jul 2011 00:18:04 +0000 (17:18 -0700)
* commit 'a125c937de06b1cc43368743592f47513eb88b76':
  Add generation of dependency file for .ap_ package

AaptAssets.cpp
AaptAssets.h
Command.cpp
Main.cpp
Main.h
Package.cpp
Resource.cpp
ZipFile.h

index b35878a7b313fde3f0575c0f4abee28e014077d2..d66cdf01c1f53b5fe178cd1864a35bdf3b3e2956 100644 (file)
@@ -1852,7 +1852,7 @@ ssize_t AaptAssets::slurpFromArgs(Bundle* bundle)
         sp<AaptDir> assetAaptDir = makeDir(String8(kAssetDir));
         AaptGroupEntry group;
         count = assetAaptDir->slurpFullTree(bundle, assetRoot, group,
-                                            String8(), mFullResPaths);
+                                            String8(), mFullAssetPaths);
         if (count < 0) {
             totalCount = count;
             goto bail;
@@ -1926,7 +1926,7 @@ ssize_t AaptAssets::slurpFromArgs(Bundle* bundle)
          * guarantees about ordering, so we're okay with an inorder search
          * using whatever order the OS happens to hand back to us.
          */
-        count = slurpFullTree(bundle, assetRoot, AaptGroupEntry(), String8(), mFullResPaths);
+        count = slurpFullTree(bundle, assetRoot, AaptGroupEntry(), String8(), mFullAssetPaths);
         if (count < 0) {
             /* failure; report error and remove archive */
             totalCount = count;
index a1c7c40818ddc2ec9d99ced133b45da50fc8be87..82dfd71be8e4b1c7f6297409e2eb5fc7e33e36ed 100644 (file)
@@ -560,6 +560,10 @@ public:
     inline void
         setFullResPaths(sp<FilePathStore>& res) { mFullResPaths = res; }
 
+    inline sp<FilePathStore>& getFullAssetPaths() { return mFullAssetPaths; }
+    inline void
+        setFullAssetPaths(sp<FilePathStore>& res) { mFullAssetPaths = res; }
+
 private:
     String8 mPackage;
     SortedVector<AaptGroupEntry> mGroupEntries;
@@ -575,6 +579,7 @@ private:
     KeyedVector<String8, sp<ResourceTypeSet> >* mRes;
 
     sp<FilePathStore> mFullResPaths;
+    sp<FilePathStore> mFullAssetPaths;
 };
 
 #endif // __AAPT_ASSETS_H
index 903c62cef1fe69d3102286d2886530a36f400968..2f9e9bef8218a9d40154eb78f329e5f23a47f0b4 100644 (file)
@@ -1545,10 +1545,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);
@@ -1575,9 +1578,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);
     }
@@ -1615,19 +1625,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) {
@@ -1643,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()) {
index 8edb5b53b194c96cddad9efcbbf4fad44add09af..9887268abd7e51662aed3b0934e207303cd39001 100644 (file)
--- a/Main.cpp
+++ b/Main.cpp
@@ -148,7 +148,7 @@ void usage(void)
         "   --extra-packages\n"
         "       generate R.java for libraries. Separate libraries with ':'.\n"
         "   --generate-dependencies\n"
-        "       generate a dependency file for R.java.\n"
+        "       generate dependency files in the same directories for R.java and resource package\n"
         "   --auto-add-overlay\n"
         "       Automatically add resources that are only in overlays.\n"
         "   --rename-manifest-package\n"
diff --git a/Main.h b/Main.h
index 1df114430fd3869ff8b1f1d3f20bf01825786860..9674c5daa21f866d2108cf6c15e4a25bbe40ce33 100644 (file)
--- a/Main.h
+++ b/Main.h
@@ -46,5 +46,6 @@ int dumpResources(Bundle* bundle);
 String8 getAttribute(const ResXMLTree& tree, const char* ns,
                             const char* attr, String8* outError);
 
-status_t writeDependencyPreReqs(Bundle* bundle, const sp<AaptAssets>& assets, FILE* fp);
+status_t writeDependencyPreReqs(Bundle* bundle, const sp<AaptAssets>& assets,
+                                FILE* fp, bool includeRaw);
 #endif // __MAIN_H
index ab71f34b3c8fe5122d95484439d0bcea1abc9581..57e20b38a66411b1121239c74d63e33dff57e7f2 100644 (file)
@@ -172,6 +172,16 @@ status_t writeAPK(Bundle* bundle, const sp<AaptAssets>& assets,
         }
     }
 
+    if (bundle->getGenDependencies()) {
+        // Add this file to the dependency file
+        String8 dependencyFile = outputFile.getBasePath();
+        dependencyFile.append(".d");
+
+        FILE* fp = fopen(dependencyFile.string(), "a");
+        fprintf(fp, "%s \\\n", outputFile.string());
+        fclose(fp);
+    }
+
     assert(result == NO_ERROR);
 
 bail:
index 99e781dc5a52feba2d9a9833a3c7fd0cfb3cb52a..1d97a4e15c21f40ed0787d5e6cfa8196477775d7 100644 (file)
@@ -2261,11 +2261,11 @@ writeProguardFile(Bundle* bundle, const sp<AaptAssets>& assets)
     return err;
 }
 
-status_t
-writeDependencyPreReqs(Bundle* bundle, const sp<AaptAssets>& assets, FILE* fp)
+// Loops through the string paths and writes them to the file pointer
+// Each file path is written on its own line with a terminating backslash.
+status_t writePathsToFile(const sp<FilePathStore>& files, FILE* fp)
 {
     status_t deps = -1;
-    sp<FilePathStore> files = assets->getFullResPaths();
     for (size_t file_i = 0; file_i < files->size(); ++file_i) {
         // Add the full file path to the dependency file
         fprintf(fp, "%s \\\n", files->itemAt(file_i).string());
@@ -2273,3 +2273,14 @@ writeDependencyPreReqs(Bundle* bundle, const sp<AaptAssets>& assets, FILE* fp)
     }
     return deps;
 }
+
+status_t
+writeDependencyPreReqs(Bundle* bundle, const sp<AaptAssets>& assets, FILE* fp, bool includeRaw)
+{
+    status_t deps = -1;
+    deps += writePathsToFile(assets->getFullResPaths(), fp);
+    if (includeRaw) {
+        deps += writePathsToFile(assets->getFullAssetPaths(), fp);
+    }
+    return deps;
+}
index 78775502884bba157c7be86b88f6c3d9fd7e561f..dbbd072d1692decfe2b79e855d5026f95ca2c8a2 100644 (file)
--- a/ZipFile.h
+++ b/ZipFile.h
@@ -57,7 +57,7 @@ public:
     /*
      * Open a new or existing archive.
      */
-    enum {
+    typedef enum {
         kOpenReadOnly   = 0x01,
         kOpenReadWrite  = 0x02,
         kOpenCreate     = 0x04,     // create if it doesn't exist