diff options
author | Adam Lesinski <adamlesinski@google.com> | 2017-05-10 14:56:36 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2017-05-10 15:00:10 -0700 |
commit | 28e6c0bac2f22e63bc044fc44a82ec5282d2709c (patch) | |
tree | 9ab8474507a84ba0c4f84bf68be65a4f8d345528 | |
parent | f93dc8b6504200d0b6d502d924a70a743f9b1411 (diff) |
AAPT2: Add option to disable PNG crunching
When compiling, a developer may want to disable PNG crunching
for a specific set of PNGs.
Bug: 37729284
Test: manual
Change-Id: I134f208f8bb212df07a4eef65b467985a6443375
-rw-r--r-- | tools/aapt2/Main.cpp | 2 | ||||
-rw-r--r-- | tools/aapt2/cmd/Compile.cpp | 5 | ||||
-rw-r--r-- | tools/aapt2/readme.md | 8 |
3 files changed, 13 insertions, 2 deletions
diff --git a/tools/aapt2/Main.cpp b/tools/aapt2/Main.cpp index 01930d0c424b..e45d1420a902 100644 --- a/tools/aapt2/Main.cpp +++ b/tools/aapt2/Main.cpp @@ -27,7 +27,7 @@ namespace aapt { static const char* sMajorVersion = "2"; // Update minor version whenever a feature or flag is added. -static const char* sMinorVersion = "14"; +static const char* sMinorVersion = "15"; int PrintVersion() { std::cerr << "Android Asset Packaging Tool (aapt) " << sMajorVersion << "." diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 5413b336ea90..c192d698b500 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -114,6 +114,7 @@ struct CompileOptions { std::string output_path; Maybe<std::string> res_dir; bool pseudolocalize = false; + bool no_png_crunch = false; bool legacy_mode = false; bool verbose = false; }; @@ -663,6 +664,7 @@ int Compile(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) { "Generate resources for pseudo-locales " "(en-XA and ar-XB)", &options.pseudolocalize) + .OptionalSwitch("--no-crunch", "Disables PNG processing", &options.no_png_crunch) .OptionalSwitch("--legacy", "Treat errors that used to be valid in AAPT as warnings", &options.legacy_mode) .OptionalSwitch("-v", "Enables verbose logging", &verbose); @@ -738,7 +740,8 @@ int Compile(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) { if (!CompileXml(&context, options, path_data, archive_writer.get(), output_filename)) { error = true; } - } else if (path_data.extension == "png" || path_data.extension == "9.png") { + } else if (!options.no_png_crunch && + (path_data.extension == "png" || path_data.extension == "9.png")) { if (!CompilePng(&context, options, path_data, archive_writer.get(), output_filename)) { error = true; } diff --git a/tools/aapt2/readme.md b/tools/aapt2/readme.md index 0291720bb1ac..e92565f3e76e 100644 --- a/tools/aapt2/readme.md +++ b/tools/aapt2/readme.md @@ -1,5 +1,13 @@ # Android Asset Packaging Tool 2.0 (AAPT2) release notes +## Version 2.15 +### `aapt2 compile ...` +- Add `--no-crunch` option to avoid processing PNGs during the compile phase. Note that this + shouldn't be used as a performance optimization, as once the PNG is processed, its result is + cached for incremental linking. This should only be used if the developer has specially + pre-processed the PNG and wants it byte-for-byte identical to the input. + NOTE: 9-patches will not be processed correctly with this flag set. + ## Version 2.14 ### `aapt2 link ...` - If an app is building with a minSdkVersion < 26 and a --package-id XX where XX > 7F, aapt2 |