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

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

Merge "Fix windows build of AAPT2"

parents 96bba82a ca2fc353
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef AAPT_BIG_BUFFER_H
#define AAPT_BIG_BUFFER_H

#include <cassert>
#include <cstring>
#include <memory>
#include <vector>
+17 −13
Original line number Diff line number Diff line
@@ -157,8 +157,12 @@ bool BinaryResourceParser::getSymbol(const void* data, ResourceNameRef* outSymbo
        return false;
    }

    if (reinterpret_cast<uintptr_t>(data) < reinterpret_cast<uintptr_t>(mData)) {
        return false;
    }

    // We only support 32 bit offsets right now.
    const ptrdiff_t offset = reinterpret_cast<uintptr_t>(data) -
    const uintptr_t offset = reinterpret_cast<uintptr_t>(data) -
            reinterpret_cast<uintptr_t>(mData);
    if (offset > std::numeric_limits<uint32_t>::max()) {
        return false;
@@ -227,7 +231,7 @@ bool BinaryResourceParser::parseSymbolTable(const ResChunk_header* chunk) {
        return false;
    }

    if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != android::NO_ERROR) {
    if (mSymbolPool.setTo(parser.getChunk(), parser.getChunk()->size) != NO_ERROR) {
        Logger::error(mSource)
                << "failed to parse symbol string pool with code: "
                << mSymbolPool.getError()
@@ -252,9 +256,9 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) {
    while (ResChunkPullParser::isGoodEvent(parser.next())) {
        switch (parser.getChunk()->type) {
        case android::RES_STRING_POOL_TYPE:
            if (mValuePool.getError() == android::NO_INIT) {
            if (mValuePool.getError() == NO_INIT) {
                if (mValuePool.setTo(parser.getChunk(), parser.getChunk()->size) !=
                        android::NO_ERROR) {
                        NO_ERROR) {
                    Logger::error(mSource)
                            << "failed to parse value string pool with code: "
                            << mValuePool.getError()
@@ -281,7 +285,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) {

        case RES_TABLE_SOURCE_POOL_TYPE: {
            if (mSourcePool.setTo(getChunkData(*parser.getChunk()),
                        getChunkDataLen(*parser.getChunk())) != android::NO_ERROR) {
                        getChunkDataLen(*parser.getChunk())) != NO_ERROR) {
                Logger::error(mSource)
                        << "failed to parse source pool with code: "
                        << mSourcePool.getError()
@@ -319,7 +323,7 @@ bool BinaryResourceParser::parseTable(const ResChunk_header* chunk) {
}

bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) {
    if (mValuePool.getError() != android::NO_ERROR) {
    if (mValuePool.getError() != NO_ERROR) {
        Logger::error(mSource)
                << "no value string pool for ResTable."
                << std::endl;
@@ -356,9 +360,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) {
    while (ResChunkPullParser::isGoodEvent(parser.next())) {
        switch (parser.getChunk()->type) {
        case android::RES_STRING_POOL_TYPE:
            if (mTypePool.getError() == android::NO_INIT) {
            if (mTypePool.getError() == NO_INIT) {
                if (mTypePool.setTo(parser.getChunk(), parser.getChunk()->size) !=
                        android::NO_ERROR) {
                        NO_ERROR) {
                    Logger::error(mSource)
                            << "failed to parse type string pool with code "
                            << mTypePool.getError()
@@ -366,9 +370,9 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) {
                            << std::endl;
                    return false;
                }
            } else if (mKeyPool.getError() == android::NO_INIT) {
            } else if (mKeyPool.getError() == NO_INIT) {
                if (mKeyPool.setTo(parser.getChunk(), parser.getChunk()->size) !=
                        android::NO_ERROR) {
                        NO_ERROR) {
                    Logger::error(mSource)
                            << "failed to parse key string pool with code "
                            << mKeyPool.getError()
@@ -429,7 +433,7 @@ bool BinaryResourceParser::parsePackage(const ResChunk_header* chunk) {
}

bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) {
    if (mTypePool.getError() != android::NO_ERROR) {
    if (mTypePool.getError() != NO_ERROR) {
        Logger::error(mSource)
                << "no type string pool available for ResTable_typeSpec."
                << std::endl;
@@ -456,14 +460,14 @@ bool BinaryResourceParser::parseTypeSpec(const ResChunk_header* chunk) {
}

bool BinaryResourceParser::parseType(const ResChunk_header* chunk) {
    if (mTypePool.getError() != android::NO_ERROR) {
    if (mTypePool.getError() != NO_ERROR) {
        Logger::error(mSource)
                << "no type string pool available for ResTable_typeSpec."
                << std::endl;
        return false;
    }

    if (mKeyPool.getError() != android::NO_ERROR) {
    if (mKeyPool.getError() != NO_ERROR) {
        Logger::error(mSource)
                << "no key string pool available for ResTable_type."
                << std::endl;
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,11 @@
#include <string>
#include <sys/stat.h>

#ifdef HAVE_MS_C_RUNTIME
// Windows includes.
#include <direct.h>
#endif

namespace aapt {

FileType getFileType(const StringPiece& path) {
@@ -43,10 +48,14 @@ FileType getFileType(const StringPiece& path) {
        return FileType::kBlockDev;
    } else if (S_ISFIFO(sb.st_mode)) {
        return FileType::kFifo;
#if defined(S_ISLNK)
    } else if (S_ISLNK(sb.st_mode)) {
        return FileType::kSymlink;
#endif
#if defined(S_ISSOCK)
    } else if (S_ISSOCK(sb.st_mode)) {
        return FileType::kSocket;
#endif
    } else {
        return FileType::kUnknown;
    }
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "Source.h"
#include "StringPiece.h"

#include <cassert>
#include <string>
#include <vector>

+11 −8
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "ResourceValues.h"
#include "StringPiece.h"

#include <algorithm>
#include <ostream>
#include <set>
#include <sstream>
@@ -87,10 +88,11 @@ bool JavaClassGenerator::generateType(std::ostream& out, const ResourceTableType
        assert(id.isValid());

        if (!isValidSymbol(entry->name)) {
            mError = (std::stringstream()
                    << "invalid symbol name '"
            std::stringstream err;
            err << "invalid symbol name '"
                << StringPiece16(entry->name)
                    << "'").str();
                << "'";
            mError = err.str();
            return false;
        }

@@ -164,10 +166,11 @@ bool JavaClassGenerator::generate(std::ostream& out) {
            for (const auto& entry : type->entries) {
                assert(!entry->values.empty());
                if (!isValidSymbol(entry->name)) {
                    mError = (std::stringstream()
                            << "invalid symbol name '"
                    std::stringstream err;
                    err << "invalid symbol name '"
                        << StringPiece16(entry->name)
                            << "'").str();
                        << "'";
                    mError = err.str();
                    return false;
                }
                entry->values.front().value->accept(*this, GenArgs{ out, *entry });
Loading