Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e24ccbd authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android Code Review
Browse files

Merge "Add generation of dependency file for .ap_ package"

parents d40c93f6 03589cc6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1685,7 +1685,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;
@@ -1759,7 +1759,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;
+5 −0
Original line number Diff line number Diff line
@@ -550,6 +550,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;
@@ -565,6 +569,7 @@ private:
    KeyedVector<String8, sp<ResourceTypeSet> >* mRes;

    sp<FilePathStore> mFullResPaths;
    sp<FilePathStore> mFullAssetPaths;
};

#endif // __AAPT_ASSETS_H
+27 −18
Original line number Diff line number Diff line
@@ -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()) {
        if (outputAPKFile) {
            dependencyFile = String8(outputAPKFile);
            // Strip the extension and add new one
            dependencyFile = dependencyFile.getBasePath();
            dependencyFile.append(".d");
        } else {
            dependencyFile = String8(bundle->getRClassDir());
        // Make sure we have a clean dependency file to start with
            dependencyFile.appendPath("R.d");
        }
        // Make sure we have a clean dependency file to start with
        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()) {
+1 −1
Original line number Diff line number Diff line
@@ -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"
+2 −1
Original line number Diff line number Diff line
@@ -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
Loading