libpng seems to do the same, so our chunk filter should not care what
comes after.
Bug: 38169876
Test: manual
Change-Id: I020ddfe29ac3eb4d5ef9ace5611c6f6497de443d
Generating splits should be possible to do from the optimize command.
This means that a lot of infrastructure around split APKs can be
shared by both the optimize and link phase.
Bug: 35925830
Change-Id: Ia88b9e4bff300a56353b2f7a4a2547c8eb43a299
Test: manual
Pseudolocalization didn't properly handle spans in
strings like "<small><small>Hello</small></small>".
The spans would be identical and when doing range checks
only one of them would be updated.
Switched to a more robust way of extracting the relevant
chunks of a styled string. This uses a stack, which is more
in line with the real representation in XML.
Bug: 34088357
Test: make aapt2_tests
Change-Id: Ia4e4501713e688c96a89e26e4e2b1384f4cd3889
This also enables an AAPT behavior that CTS tests have
come to depend on.
Small files that compress negatively (get larger) are stored
uncompressed. Some CTS tests assume this and try to open these
files by mmapping them, which is only possible if they are
uncompressed.
Bug: 35461578
Test: make aapt2_tests
Change-Id: Id622a6150fe72477ad65d67d1bad897a8ee2ffb9
The XLIFF 'g' tag specifies content that should NOT be translated.
AAPT2's pseudolocalization process should respect it.
Bug:34064599
Test: make libandroidfw_tests
Change-Id: Ice437d7f0ff246730ee04896fd035e2d846148fb
libandroidfw needs to make use of StringPiece, so
move it to libandroidfw and update all code referencing
StringPiece in aapt2.
Test: make libandroidfw_tests libaapt2_tests
Change-Id: I68d7f0fc7c651b048d9d1f5e7971f10ef5349fa1
Use Google3 naming style to match new
projects' and open source google projects' style.
Preferred to do this in a massive CL so as to avoid
style inconsistencies that plague legacy code bases.
This is a relatively NEW code base, may as well keep
it up to date.
Test: name/style refactor - existing tests pass
Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
PngCrunching now has a slightly better heuristic of choosing to encode
an image as a palette or RGB. For small images, RGB compresses much better
than a palette.
The original PNG is used as-is (minus some optional chunks being stripped)
if the resulting crunched PNG is larger than the original.
9-patch handling is abstracted away from PNGs, paving the way
for other 9-patches, like WebP.
TODO: handle PNGs with 9-patch chunks already present, which
should just be passed through. This will allow for 3rd party
tools to generate 9-patches.
TODO: implement cheap transparency: when one color is used to represent
transparent, and all other colors are opaque.
Bug:30053276
Change-Id: I5167f53b91d1efa462d9f03d6b9108d9b541c0c1
* Add explicit keyword to conversion constructors.
* Add NOLINT(implicit) comments for implicit conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
* Use const reference type to avoid unnecessary copy.
Bug: 30413862
Test: build with WITH_TIDY=1
Change-Id: Id6d21961f313a1ad92b15a37fdaa5be9e8ab48e1
Previously the way to name resources in tests was to use reference
notation (@[package:][type/]name). Now we use name notation (no @).
Change-Id: I68f0a36562d89cc78c582d128f370d9556c58707
The --stable-ids flag allows the user to specify a file containing
a list of resource name and resource ID pairs in the form of:
package:type/name = 0xPPTTEEEE
This assigns the given resource the specified ID. It helps ensure
that when adding or removing resources, IDs are assigned in a stable
fashion.
If a package, type, or name is not found, no error or warning is
raised.
Change-Id: Ibc2f4e05cc924be255fedd862d835cb5b18d7584
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.
Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
When an app specifies (or imports) resources with various
configurations for different SDK versions, specifying
a minSdk will make many of those resources unreachable.
Version collapsing will prune out the resources specified
for SDK versions less than the minSdk.
If, however, there is no exact matching resource for the
minSdk version, the next smallest SDK version is kept.
Change-Id: Ic7bcab6c59d65c97c67c8767358abb57cdec60a4
The accent pseudolocalizer would incorrectly process
the byte after the end of the string, which would end
up inserting null characters into the resulting
output.
Change-Id: I5cdabd6b0272d94073f06e180b8cbe7abafa3888
Adds the diff command and various small fixes to issues
discovered when diffing old AAPT built APKs with new AAPT2
built APKS.
Bug:22775504
Change-Id: I682a7fe1cf4b3efa7cbd5d18b333cf2d1046fe1b
Mingw32 4.8 is kind of picky with macros and some complicated template
stuff. Luckily there was another way to represent the
SFINAE code that works on all platforms. Yay!
Change-Id: Idc2e38f47bfdc57b394550bfa0f53cc0b825df25
Android static libraries are like APKs but they contain much more debugging
and source information. We need to treat them differently in 3 ways:
1) When building a static library, we skip things like ID assignment and
product/config stripping. Source information is emitted as well.
2) When building a static library and linking against another
static library, we don't want to merge, we want to simply reference.
3) When building an app that uses static libraries, we want to merge
the static library under the same package with or without mangling.
Bug:25958912
Change-Id: I425e032857936a3e83173c1edc2a6cdc6020b842
When a preferred density is supplied, the closest matching densities
will be selected, the rest stripped from the APK.
Split support will be enabled in a later CL. Command line support is still
needed, but the foundation is ready.
Bug:25958912
Change-Id: I56d599806b4ec4ffa24e17aad48d47130ca05c08
This allows us to preserve the various product definitions during the compile
phase, and allows us to select the product in the link phase.
This allows compiled files to remain product-independent, so that they do not need
to be recompiled when switching targets.
Bug:25958912
Change-Id: Iaa7eed25c834b67a39cdc9be43613e8b5ab6cdd7
Without needing to conform to the runtime data format,
it is much easier to add new features such as debugging symbols
and carrying over product data to link time.
This also simplifies the runtime format parser and serializer,
which will change much less frequently than the protobuf intermediate
format.
Change-Id: I209787bbf087db0a58a534cb8511c51d21133e00
- Add option to rename package in AndroidManifest.xml
- Support default versionName and versionCode
- Accept True and False as valid booleans
Change-Id: I400e350b9dcd0fd1c197d1929144299c7823617d
This is normally an error, but old AAPT didn't check for it correctly,
so many projects violate this. With --legacy, this becomes a warning.
Change-Id: I23647e029930e11b719591cd38609e1b43247e20
Previously the default product wasn't tried if 'default' wasn't specified on the command line.
Also adds support for multiple products.
Change-Id: I1e4872b34bb8d609b6444841a4e7e4dbb3bbb76b
Pseudolocalization happens at the compile phase. Pseudolocalized
values are weak, such that manually specified values will take precedence.
Change-Id: I5e064ce0d270c9f4f9022f75aecedab9d45bc980
We now default host native tests to build both 32-bit and 64-bit
versions.
The 32-bit version of libaapt2_test was broken because it was comparing
an unsigned int to the result from std::count(std::vector), which is a
signed int. The 64-bit version compiled fine, since
std::count(std::vector) returns a long.
Change-Id: I786fcd8a54d9f78b76b19ef82ab8dda6f5c42197
This allows us to compile an entire directory and output to a single
file. This is important to support generated resources in the make
build, since we may not know what resources get generated.
The link step will accept the zip and read the contents of it as if they
were passed in on the command line.
Change-Id: If1a51b0abe772350c24074353eb4989953c2e0cb
Merging local app resources is slightly different than merging
resources from a static library.
Local app resources may not have a package name set, but we do take interest in the
ID set for the package (should be 0x0 or match the ID of the app we're building).
Static library resources have an explicit package name defined for them, so we
only merge resources from that package.
Change-Id: I95e559ae94cc1df6972e77a347b1b37a93674c4d
Unfortunately there is no good way to deal with products in the link phase.
Products are like preprocessor defines in that they are processed early
and change the composition of the compiled unit.
Change-Id: I6d5e15ef60d29df8e83e059ba857c09333993779
An early refactor. Some ideas became clearer as
development continued. Now the various phases are much
clearer and more easily reusable.
Also added a ton of tests!
Change-Id: Ic8f0a70c8222370352e63533b329c40457c0903e