AAPT2: Compile --zip flag
Added a --zip flag similar to --dir that allows resources to be passed
into "aapt2 compile" using a zip file.
Also refactored Compile.cpp to be easier to mock and test in the future.
Bug: 74574557
Test: aapt2_tests
Change-Id: Idb90cb97e23a219525bdead38220cbf7bc6f3cab
diff --git a/tools/aapt2/Source.h b/tools/aapt2/Source.h
index 0f312d6..92934c3 100644
--- a/tools/aapt2/Source.h
+++ b/tools/aapt2/Source.h
@@ -31,12 +31,16 @@
struct Source {
std::string path;
Maybe<size_t> line;
+ Maybe<std::string> archive;
Source() = default;
inline Source(const android::StringPiece& path) : path(path.to_string()) { // NOLINT(implicit)
}
+ inline Source(const android::StringPiece& path, const android::StringPiece& archive)
+ : path(path.to_string()), archive(archive.to_string()) {}
+
inline Source(const android::StringPiece& path, size_t line)
: path(path.to_string()), line(line) {}
@@ -45,10 +49,14 @@
}
std::string to_string() const {
- if (line) {
- return ::android::base::StringPrintf("%s:%zd", path.c_str(), line.value());
+ std::string s = path;
+ if (archive) {
+ s = ::android::base::StringPrintf("%s@%s", archive.value().c_str(), s.c_str());
}
- return path;
+ if (line) {
+ s = ::android::base::StringPrintf("%s:%zd", s.c_str(), line.value());
+ }
+ return s;
}
};