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

Commit 830b6e00 authored by Adam Lesinski's avatar Adam Lesinski Committed by android-build-merger
Browse files

AAPT2: Switch to protobuf for intermediate format am: 59e04c6f

am: 28e44c9c

* commit '28e44c9c':
  AAPT2: Switch to protobuf for intermediate format
parents b038f149 28e44c9c
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ sources := \
	link/TableMerger.cpp \
	link/XmlReferenceLinker.cpp \
	process/SymbolTable.cpp \
	proto/ProtoHelpers.cpp \
	proto/TableProtoDeserializer.cpp \
	proto/TableProtoSerializer.cpp \
	unflatten/BinaryResourceParser.cpp \
	unflatten/ResChunkPullParser.cpp \
	util/BigBuffer.cpp \
@@ -67,13 +70,14 @@ sources := \
	xml/XmlPullParser.cpp \
	xml/XmlUtil.cpp

sources += Format.proto

testSources := \
	compile/IdAssigner_test.cpp \
	compile/PseudolocaleGenerator_test.cpp \
	compile/Pseudolocalizer_test.cpp \
	compile/XmlIdCollector_test.cpp \
	filter/ConfigFilter_test.cpp \
	flatten/FileExportWriter_test.cpp \
	flatten/TableFlattener_test.cpp \
	flatten/XmlFlattener_test.cpp \
	link/AutoVersioner_test.cpp \
@@ -83,7 +87,7 @@ testSources := \
	link/TableMerger_test.cpp \
	link/XmlReferenceLinker_test.cpp \
	process/SymbolTable_test.cpp \
	unflatten/FileExportHeaderReader_test.cpp \
	proto/TableProtoSerializer_test.cpp \
	util/BigBuffer_test.cpp \
	util/Maybe_test.cpp \
	util/StringPiece_test.cpp \
@@ -105,6 +109,7 @@ testSources := \

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

hostLdLibs :=
@@ -119,6 +124,9 @@ hostStaticLibs := \
	libpng \
	libbase

hostSharedLibs := \
	libprotobuf-cpp-lite

ifneq ($(strip $(USE_MINGW)),)
	hostStaticLibs += libz
else
@@ -127,21 +135,23 @@ endif

cFlags := -Wall -Werror -Wno-unused-parameter -UNDEBUG
cppFlags := -std=c++11 -Wno-missing-field-initializers -fno-exceptions -fno-rtti
protoIncludes := $(call generated-sources-dir-for,STATIC_LIBRARIES,libaapt2,HOST)

# ==========================================================
# Build the host static library: libaapt2
# ==========================================================
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE := libaapt2

LOCAL_SRC_FILES := $(sources)
LOCAL_STATIC_LIBRARIES += $(hostStaticLibs)
LOCAL_CFLAGS += $(cFlags)
LOCAL_CPPFLAGS += $(cppFlags)
LOCAL_C_INCLUDES += $(protoIncludes)

include $(BUILD_HOST_STATIC_LIBRARY)


# ==========================================================
# Build the host tests: libaapt2_tests
# ==========================================================
@@ -152,9 +162,11 @@ LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(testSources)

LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs)
LOCAL_SHARED_LIBRARIES += $(hostSharedLibs)
LOCAL_LDLIBS += $(hostLdLibs)
LOCAL_CFLAGS += $(cFlags)
LOCAL_CPPFLAGS += $(cppFlags)
LOCAL_C_INCLUDES += $(protoIncludes)

include $(BUILD_HOST_NATIVE_TEST)

@@ -167,9 +179,11 @@ LOCAL_MODULE := aapt2
LOCAL_SRC_FILES := $(main) $(toolSources)

LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs)
LOCAL_SHARED_LIBRARIES += $(hostSharedLibs)
LOCAL_LDLIBS += $(hostLdLibs)
LOCAL_CFLAGS += $(cFlags)
LOCAL_CPPFLAGS += $(cppFlags)
LOCAL_C_INCLUDES += $(protoIncludes)

include $(BUILD_HOST_EXECUTABLE)

+210 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package aapt.pb;

message ConfigDescription {
	optional bytes data = 1;
	optional string product = 2;
}

message StringPool {
	optional bytes data = 1;
}

message CompiledFile {
	message Symbol {
		optional string resource_name = 1;
		optional uint32 line_no = 2;
	}
	
	optional string resource_name = 1;
	optional ConfigDescription config = 2;
	optional string source_path = 3;
	repeated Symbol exported_symbols = 4;
}

message ResourceTable {
	optional StringPool string_pool = 1;
	optional StringPool source_pool = 2;
	optional StringPool symbol_pool = 3;
	repeated Package packages = 4;
}

message Package {
	optional uint32 package_id = 1;
	optional string package_name = 2;
	repeated Type types = 3;
}

message Type {	
	optional uint32 id = 1;
	optional string name = 2;
	repeated Entry entries = 3;
}

message SymbolStatus {
	enum Visibility {
		Unknown = 0;
		Private = 1;
		Public = 2;
	}
	optional Visibility visibility = 1;
	optional Source source = 2;
	optional string comment = 3;
}

message Entry {
	optional uint32 id = 1;
	optional string name = 2;
	optional SymbolStatus symbol_status = 3;
	repeated ConfigValue config_values = 4;
}

message ConfigValue {
	optional ConfigDescription config = 1;
	optional Value value = 2;
}

message Source {
	optional uint32 path_idx = 1;
	optional uint32 line_no = 2;
	optional uint32 col_no = 3;
}

message Reference {
	enum Type {
		Ref = 0;
		Attr = 1;
	}
	optional Type type = 1;
	optional uint32 id = 2;
	optional uint32 symbol_idx = 3;
	optional bool private = 4;
}

message Id {
}

message String {
	optional uint32 idx = 1;
}

message RawString {
	optional uint32 idx = 1;
}

message FileReference {
	optional uint32 path_idx = 1;
}

message Primitive {
	optional uint32 type = 1;
	optional uint32 data = 2;
}

message Attribute {
	message Symbol {
		optional Source source = 1;
		optional string comment = 2;
		optional Reference name = 3;
		optional uint32 value = 4;
	}
	optional uint32 format_flags = 1;
	optional int32 min_int = 2;
	optional int32 max_int = 3;
	repeated Symbol symbols = 4;
}

message Style {
	message Entry {
		optional Source source = 1;
		optional string comment = 2;
		optional Reference key = 3;
		optional Item item = 4;
	}

	optional Reference parent = 1;
	optional Source parent_source = 2;
	repeated Entry entries = 3;
}

message Styleable {
	message Entry {
		optional Source source = 1;
		optional string comment = 2;
		optional Reference attr = 3;
	}
	repeated Entry entries = 1;
}

message Array {
	message Entry {
		optional Source source = 1;
		optional string comment = 2;
		optional Item item = 3;
	}
	repeated Entry entries = 1;
}

message Plural {
	enum Arity {
		Zero = 0;
		One = 1;
		Two = 2;
		Few = 3;
		Many = 4;
		Other = 5;
	}
		
	message Entry {
		optional Source source = 1;
		optional string comment = 2;
		optional Arity arity = 3;
		optional Item item = 4;
	}
	repeated Entry entries = 1;
}

message Item {
	optional Reference ref = 1;
	optional String str = 2;
	optional RawString raw_str = 3;
	optional FileReference file = 4;
	optional Id id = 5;
	optional Primitive prim = 6;
}

message CompoundValue {
	optional Attribute attr = 1;
	optional Style style = 2;
	optional Styleable styleable = 3;
	optional Array array = 4;
	optional Plural plural = 5;
}

message Value {
	optional Source source = 1;
	optional string comment = 2;
	optional bool weak = 3;
	
	optional Item item = 4;
	optional CompoundValue compound_value = 5;	
}
+4 −1
Original line number Diff line number Diff line
@@ -23,6 +23,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);

} // namespace aapt

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

    std::cerr << "\nusage: aapt2 [compile|link] ..." << std::endl;
    std::cerr << "\nusage: aapt2 [compile|link|dump] ..." << std::endl;
    return 1;
}
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ bool extractResourceName(const StringPiece16& str, StringPiece16* outPackage,
}

bool parseResourceName(const StringPiece16& str, ResourceNameRef* outRef, bool* outPrivate) {
    if (str.empty()) {
        return false;
    }

    size_t offset = 0;
    bool priv = false;
    if (str.data()[0] == u'*') {
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ bool extractResourceName(const StringPiece16& str, StringPiece16* outPackage,
 * `outResource` set to the parsed resource name and `outPrivate` set to true if a '*' prefix
 * was present.
 */
bool parseResourceName(const StringPiece16& str, ResourceNameRef* outResource, bool* outPrivate);
bool parseResourceName(const StringPiece16& str, ResourceNameRef* outResource,
                       bool* outPrivate = nullptr);

/*
 * Returns true if the string was parsed as a reference (@[+][package:]type/name), with
Loading