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

Commit 5089e965 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Add default no-compress extensions"

parents c837e4bc 9756dec2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -69,6 +69,17 @@ Flags& Flags::optionalFlagList(const StringPiece& name, const StringPiece& descr
    return *this;
}

Flags& Flags::optionalFlagList(const StringPiece& name, const StringPiece& description,
                               std::unordered_set<std::string>* value) {
    auto func = [value](const StringPiece& arg) -> bool {
        value->insert(arg.toString());
        return true;
    };

    mFlags.push_back(Flag{ name.toString(), description.toString(), func, false, 1, false });
    return *this;
}

Flags& Flags::optionalSwitch(const StringPiece& name, const StringPiece& description,
                             bool* value) {
    auto func = [value](const StringPiece& arg) -> bool {
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <functional>
#include <ostream>
#include <string>
#include <unordered_set>
#include <vector>

namespace aapt {
@@ -37,6 +38,8 @@ public:
                        Maybe<std::string>* value);
    Flags& optionalFlagList(const StringPiece& name, const StringPiece& description,
                            std::vector<std::string>* value);
    Flags& optionalFlagList(const StringPiece& name, const StringPiece& description,
                            std::unordered_set<std::string>* value);
    Flags& optionalSwitch(const StringPiece& name, const StringPiece& description,
                          bool* value);

+11 −2
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ struct LinkOptions {
    bool outputToDirectory = false;
    bool autoAddOverlay = false;
    bool doNotCompressAnything = false;
    std::vector<std::string> extensionsToNotCompress;
    std::unordered_set<std::string> extensionsToNotCompress;
    Maybe<std::string> privateSymbols;
    ManifestFixerOptions manifestFixerOptions;
    std::unordered_set<std::string> products;
@@ -287,7 +287,7 @@ struct ResourceFileFlattenerOptions {
    bool keepRawValues = false;
    bool doNotCompressAnything = false;
    bool updateProguardSpec = false;
    std::vector<std::string> extensionsToNotCompress;
    std::unordered_set<std::string> extensionsToNotCompress;
};

class ResourceFileFlattener {
@@ -1728,6 +1728,15 @@ int link(const std::vector<StringPiece>& args) {
        }
    }

    // Populate some default no-compress extensions that are already compressed.
    options.extensionsToNotCompress.insert({
            ".jpg", ".jpeg", ".png", ".gif",
            ".wav", ".mp2", ".mp3", ".ogg", ".aac",
            ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
            ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
            ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
            ".amr", ".awb", ".wma", ".wmv", ".webm", ".mkv"});

    // Turn off auto versioning for static-libs.
    if (options.staticLib) {
        options.noAutoVersion = true;