diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2018-08-02 16:16:45 -0700 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2018-08-14 15:42:01 -0700 |
commit | f3649d669059b924ce9eb3eb7909cbf0a2ed31a8 (patch) | |
tree | 9c484a1b455554f6939d066a4418ec4747a7cbd3 /tools/aapt2/Source.h | |
parent | 196a2956b2ddee915c524e5c0f511e5ce90cc7b4 (diff) |
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
Diffstat (limited to 'tools/aapt2/Source.h')
-rw-r--r-- | tools/aapt2/Source.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/aapt2/Source.h b/tools/aapt2/Source.h index 0f312d6998f1..92934c343960 100644 --- a/tools/aapt2/Source.h +++ b/tools/aapt2/Source.h @@ -31,12 +31,16 @@ namespace aapt { 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 @@ struct Source { } std::string to_string() const { + std::string s = path; + if (archive) { + s = ::android::base::StringPrintf("%s@%s", archive.value().c_str(), s.c_str()); + } if (line) { - return ::android::base::StringPrintf("%s:%zd", path.c_str(), line.value()); + s = ::android::base::StringPrintf("%s:%zd", s.c_str(), line.value()); } - return path; + return s; } }; |