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

Commit 1a146105 authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge "AAPT2: Add diff command" into nyc-mr1-dev

parents f4f15d58 458b8774
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ testSources := \

toolSources := \
	compile/Compile.cpp \
	diff/Diff.cpp \
	dump/Dump.cpp \
	link/Link.cpp

+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ namespace aapt {
extern int compile(const std::vector<StringPiece>& args);
extern int link(const std::vector<StringPiece>& args);
extern int dump(const std::vector<StringPiece>& args);
extern int diff(const std::vector<StringPiece>& args);

} // namespace aapt

@@ -44,12 +45,14 @@ int main(int argc, char** argv) {
            return aapt::link(args);
        } else if (command == "dump" || command == "d") {
            return aapt::dump(args);
        } else if (command == "diff") {
            return aapt::diff(args);
        }
        std::cerr << "unknown command '" << command << "'\n";
    } else {
        std::cerr << "no command specified\n";
    }

    std::cerr << "\nusage: aapt2 [compile|link|dump] ..." << std::endl;
    std::cerr << "\nusage: aapt2 [compile|link|dump|diff] ..." << std::endl;
    return 1;
}
+11 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ bool ResourceParser::flattenXmlSubtree(xml::XmlPullParser* parser, std::u16strin
                break;
            }

            spanStack.back().lastChar = builder.str().size();
            spanStack.back().lastChar = builder.str().size() - 1;
            outStyleString->spans.push_back(spanStack.back());
            spanStack.pop_back();

@@ -1058,6 +1058,16 @@ bool ResourceParser::parseArrayImpl(xml::XmlPullParser* parser, ParsedResource*

    std::unique_ptr<Array> array = util::make_unique<Array>();

    bool translateable = mOptions.translatable;
    if (Maybe<StringPiece16> translateableAttr = xml::findAttribute(parser, u"translatable")) {
        if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) {
            mDiag->error(DiagMessage(outResource->source)
                         << "invalid value for 'translatable'. Must be a boolean");
            return false;
        }
    }
    array->setTranslateable(translateable);

    bool error = false;
    const size_t depth = parser->getDepth();
    while (xml::XmlPullParser::nextChildNode(parser, depth)) {
+11 −0
Original line number Diff line number Diff line
@@ -189,6 +189,17 @@ std::vector<ResourceConfigValue*> ResourceEntry::findAllValues(const ConfigDescr
    return results;
}

std::vector<ResourceConfigValue*> ResourceEntry::findValuesIf(
        const std::function<bool(ResourceConfigValue*)>& f) {
    std::vector<ResourceConfigValue*> results;
    for (auto& configValue : values) {
        if (f(configValue.get())) {
            results.push_back(configValue.get());
        }
    }
    return results;
}

/**
 * The default handler for collisions. A return value of -1 means keep the
 * existing value, 0 means fail, and +1 means take the incoming value.
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "io/File.h"

#include <android-base/macros.h>
#include <functional>
#include <map>
#include <memory>
#include <string>
@@ -109,6 +110,9 @@ public:
    ResourceConfigValue* findOrCreateValue(const ConfigDescription& config,
                                           const StringPiece& product);
    std::vector<ResourceConfigValue*> findAllValues(const ConfigDescription& config);
    std::vector<ResourceConfigValue*> findValuesIf(
            const std::function<bool(ResourceConfigValue*)>& f);


private:
    DISALLOW_COPY_AND_ASSIGN(ResourceEntry);
Loading