18 Commits

Author SHA1 Message Date
Adam Lesinski
803c7c8079 AAPT2: Enable windows build and make sure it builds
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
2016-04-06 16:24:02 -07:00
Adam Lesinski
64587af817 AAPT2: Support building, linking, and merging static libraries
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
2016-03-04 14:39:01 -08:00
Adam Lesinski
144c5eabe5 AAPT2: Fix segfault when showing error in 9-patch
Change-Id: I8f457212efc27480758a7157455d98b5e316f772
2016-03-01 09:05:11 -08:00
Adam Lesinski
355f285ffd AAPT2: Implement density stripping and initial Split support
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
2016-02-17 18:17:25 -08:00
Adam Lesinski
e4bb9eb5af AAPT2: Introduce notion of 'product' to ResourceTable
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
2016-02-12 22:21:48 -08:00
Adam Lesinski
59e04c6f92 AAPT2: Switch to protobuf for intermediate format
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
2016-02-09 19:59:17 +00:00
Adam Lesinski
52364f7ae3 AAPT2: Variety of small fixes to get the build working
- Add option to rename package in AndroidManifest.xml
- Support default versionName and versionCode
- Accept True and False as valid booleans

Change-Id: I400e350b9dcd0fd1c197d1929144299c7823617d
2016-01-13 18:48:24 -08:00
Adam Lesinski
979ccb2e6f AAPT2: Warn when positional arguments exist and --legacy is on
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
2016-01-11 10:42:19 -08:00
Adam Lesinski
7751afc796 AAPT2: Fix product support
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
2016-01-06 16:18:40 -08:00
Adam Lesinski
198ce1a5e6 Merge "AAPT2: Port AAPT pseudolocalization to AAPT2" 2016-01-06 23:55:06 +00:00
Adam Lesinski
393b5f0d61 AAPT2: Port AAPT pseudolocalization to AAPT2
Pseudolocalization happens at the compile phase. Pseudolocalized
values are weak, such that manually specified values will take precedence.

Change-Id: I5e064ce0d270c9f4f9022f75aecedab9d45bc980
2016-01-06 12:05:41 -08:00
Dan Willemsen
1b1f1b14ee AAPT2: Fix compiler error in 32-bit host test
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
2015-12-22 13:44:56 -08:00
Adam Lesinski
a40e972fda AAPT2: Support compiling a res/ directory and output to zip
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
2015-11-30 11:14:01 -08:00
Adam Lesinski
467f171315 AAPT2: Fail compiling when private symbols are referenced
Also moved some XML specific stuff into its own directory,
and refactored ReferenceLinker a bit.

Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
2015-11-19 14:46:53 -08:00
Adam Lesinski
83f2255f69 AAPT2: Disambiguate merging of resources
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
2015-11-07 11:51:23 -08:00
Adam Lesinski
9f22204c3a AAPT2: Fix small issue with detecting translatable resources
Change-Id: Idd21b5de4d20be06c6f8c8eb5a22ccd68afc4927
2015-11-05 10:56:32 -08:00
Adam Lesinski
9ba47d8130 Filter products during compile phase
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
2015-10-16 15:50:58 -07:00
Adam Lesinski
1ab598f46c AAPT2: Separate out the various steps
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
2015-10-16 12:13:08 -07:00