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

Commit 8eefa048 authored by Alexandria Cornwall's avatar Alexandria Cornwall Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Reorder link steps"

parents ed45cf3c 637b4820
Loading
Loading
Loading
Loading
+23 −26
Original line number Diff line number Diff line
@@ -1191,6 +1191,12 @@ public:
                                                                     mContext->getDiagnostics())) {
            AppInfo& appInfo = maybeAppInfo.value();
            mContext->setCompilationPackage(appInfo.package);
            if (appInfo.minSdkVersion) {
                if (Maybe<int> maybeMinSdkVersion =
                        ResourceUtils::tryParseSdkVersion(appInfo.minSdkVersion.value())) {
                    mContext->setMinSdkVersion(maybeMinSdkVersion.value());
                }
            }
        } else {
            return 1;
        }
@@ -1393,32 +1399,6 @@ public:
            return 1;
        }

        // Must come before ResourceFileFlattener as ResourceFileFlattener
        // relies on the minSdkVersion to properly flatten files.
        Maybe<AppInfo> maybeAppInfo = extractAppInfoFromManifest(manifestXml.get(),
                                                                 mContext->getDiagnostics());
        if (maybeAppInfo && maybeAppInfo.value().minSdkVersion) {
            if (Maybe<int> maybeMinSdkVersion =
                    ResourceUtils::tryParseSdkVersion(maybeAppInfo.value().minSdkVersion.value())) {
                mContext->setMinSdkVersion(maybeMinSdkVersion.value());
            }
        }

        ResourceFileFlattenerOptions fileFlattenerOptions;
        fileFlattenerOptions.keepRawValues = mOptions.staticLib;
        fileFlattenerOptions.doNotCompressAnything = mOptions.doNotCompressAnything;
        fileFlattenerOptions.extensionsToNotCompress = mOptions.extensionsToNotCompress;
        fileFlattenerOptions.noAutoVersion = mOptions.noAutoVersion;
        fileFlattenerOptions.noVersionVectors = mOptions.noVersionVectors;
        fileFlattenerOptions.updateProguardSpec =
                static_cast<bool>(mOptions.generateProguardRulesPath);
        ResourceFileFlattener fileFlattener(fileFlattenerOptions, mContext, &proguardKeepSet);

        if (!fileFlattener.flatten(&mFinalTable, archiveWriter.get())) {
            mContext->getDiagnostics()->error(DiagMessage() << "failed linking file resources");
            return 1;
        }

        if (!mOptions.noAutoVersion) {
            AutoVersioner versioner;
            if (!versioner.consume(mContext, &mFinalTable)) {
@@ -1440,6 +1420,23 @@ public:
            }
        }

        // Write out the table to an archive. Optimizations to the table should come before this
        // step.
        ResourceFileFlattenerOptions fileFlattenerOptions;
        fileFlattenerOptions.keepRawValues = mOptions.staticLib;
        fileFlattenerOptions.doNotCompressAnything = mOptions.doNotCompressAnything;
        fileFlattenerOptions.extensionsToNotCompress = mOptions.extensionsToNotCompress;
        fileFlattenerOptions.noAutoVersion = mOptions.noAutoVersion;
        fileFlattenerOptions.noVersionVectors = mOptions.noVersionVectors;
        fileFlattenerOptions.updateProguardSpec =
                static_cast<bool>(mOptions.generateProguardRulesPath);
        ResourceFileFlattener fileFlattener(fileFlattenerOptions, mContext, &proguardKeepSet);

        if (!fileFlattener.flatten(&mFinalTable, archiveWriter.get())) {
            mContext->getDiagnostics()->error(DiagMessage() << "failed linking file resources");
            return 1;
        }

        if (mOptions.staticLib) {
            if (!flattenTableToPb(&mFinalTable, archiveWriter.get())) {
                mContext->getDiagnostics()->error(DiagMessage()