Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
AAPT2: Define and Implement AAPT Container Format
Browse files Browse the repository at this point in the history
AAPT Container Format (.apc) is a simple container that
enumerates the various intermediate files that AAPT2 generates
during the compile phase.

The format is defined in formats.md.

For now, continue using the .flat extension for the container file,
and keep making use of the .flata zip for storing multiple files.
This will allow easier integration with existing build systems and allow
the evolution of the APC format to better handle arbitrarily large
files.

Test: make aapt2_tests
Change-Id: Id7216e5b76316bdd683f0fa4eaf2d2da273ba815
  • Loading branch information
Adam Lesinski committed Oct 19, 2017
1 parent d691250 commit 0045116
Show file tree
Hide file tree
Showing 50 changed files with 1,496 additions and 771 deletions.
7 changes: 4 additions & 3 deletions tools/aapt2/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,18 @@ cc_library_host_static {
"filter/AbiFilter.cpp",
"filter/ConfigFilter.cpp",
"format/Archive.cpp",
"format/Container.cpp",
"format/binary/BinaryResourceParser.cpp",
"format/binary/ResChunkPullParser.cpp",
"format/binary/TableFlattener.cpp",
"format/binary/XmlFlattener.cpp",
"format/proto/ProtoDeserialize.cpp",
"format/proto/ProtoSerialize.cpp",
"io/BigBufferStreams.cpp",
"io/BigBufferStream.cpp",
"io/File.cpp",
"io/FileInputStream.cpp",
"io/FileStream.cpp",
"io/FileSystem.cpp",
"io/StringInputStream.cpp",
"io/StringStream.cpp",
"io/Util.cpp",
"io/ZipArchive.cpp",
"link/AutoVersioner.cpp",
Expand Down
2 changes: 1 addition & 1 deletion tools/aapt2/LoadedApk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "format/Archive.h"
#include "format/binary/TableFlattener.h"
#include "format/binary/XmlFlattener.h"
#include "io/BigBufferInputStream.h"
#include "io/BigBufferStream.h"
#include "io/Util.h"
#include "xml/XmlDom.h"

Expand Down
10 changes: 10 additions & 0 deletions tools/aapt2/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,22 @@ struct SourcedResourceName {
};

struct ResourceFile {
enum class Type {
kUnknown,
kPng,
kBinaryXml,
kProtoXml,
};

// Name
ResourceName name;

// Configuration
ConfigDescription config;

// Type
Type type;

// Source
Source source;

Expand Down
2 changes: 1 addition & 1 deletion tools/aapt2/ResourceParser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "ResourceTable.h"
#include "ResourceUtils.h"
#include "ResourceValues.h"
#include "io/StringInputStream.h"
#include "io/StringStream.h"
#include "test/Test.h"
#include "xml/XmlPullParser.h"

Expand Down
1 change: 1 addition & 0 deletions tools/aapt2/ResourceValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ bool FileReference::Flatten(android::Res_value* out_value) const {
FileReference* FileReference::Clone(StringPool* new_pool) const {
FileReference* fr = new FileReference(new_pool->MakeRef(*path));
fr->file = file;
fr->type = type;
fr->comment_ = comment_;
fr->source_ = source_;
return fr;
Expand Down
4 changes: 4 additions & 0 deletions tools/aapt2/ResourceValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ struct FileReference : public BaseItem<FileReference> {
// This field is NOT persisted in any format. It is transient.
io::IFile* file = nullptr;

// FileType of the file pointed to by `file`. This is used to know how to inflate the file,
// or if to inflate at all (just copy).
ResourceFile::Type type = ResourceFile::Type::kUnknown;

FileReference() = default;
explicit FileReference(const StringPool::Ref& path);

Expand Down
15 changes: 12 additions & 3 deletions tools/aapt2/ResourcesInternal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,22 @@ message CompiledFile {
// The configuration for which the resource is defined.
aapt.pb.Configuration config = 2;

enum Type {
UNKNOWN = 0;
PNG = 1;
BINARY_XML = 2;
PROTO_XML = 3;
}

Type type = 3;

// The filesystem path to where the source file originated.
// Mainly used to display helpful error messages.
string source_path = 3;
string source_path = 4;

// Any symbols this file auto-generates/exports (eg. @+id/foo in an XML file).
repeated Symbol exported_symbol = 4;
repeated Symbol exported_symbol = 5;

// If this is a compiled XML file, this is the root node.
aapt.pb.XmlNode xml_root = 5;
aapt.pb.XmlNode xml_root = 6;
}
Loading

0 comments on commit 0045116

Please sign in to comment.