summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
AgeCommit message (Collapse)Author
2017-06-02AAPT2: Allow undefined resources (placeholders)Adam Lesinski
A resource defined like so: <item type="drawable" name="foo" /> should be assigned the value @null. The only exception is for <string> resources, which are given the empty string value (since <string></string> is ambiguous). The decision to use "" is based off the fact that old AAPT used to assign "" to all undefined resources, even non-string ones. Bug: 38425050 Test: make aapt2_tests Change-Id: Ib3e0f6f83d16ddd8b279c9fd44a07a37867b85e9
2017-06-02Merge "AAPT2: Allow any value type for <item> without format attr" into oc-devAdam Lesinski
am: 1ac325e4d5 Change-Id: I1b1180f2b33a077b2c46a8466c58d83ed618576e
2017-06-01AAPT2: Allow any value type for <item> without format attrAdam Lesinski
TO bring AAPT2 behavior in-line with AAPT, <item> has a default format of "any", and only becomes restricted with an explicit format attribute. Bug: 62260121 Test: make aapt2_tests Change-Id: Ife416f520e6c2710bb30e3ba3f2d4463794bfa06
2017-05-30Merge "AAPT2: Fix <add-resource> tag for overlays" into oc-devAdam Lesinski
am: 8255ced3f5 Change-Id: Icc420eea48a8379723c0bc84a5f30c03ac2a2492
2017-05-26AAPT2: Fix <add-resource> tag for overlaysAdam Lesinski
Bug: 38355988 Test: make aapt2_tests Change-Id: Iea8887f55f8ceb2c15bd963405fd132916173c0c
2017-05-17Merge "AAPT2: Respect format attr in <array> resource" into oc-devAdam Lesinski
am: dc6da8b4df Change-Id: Ic7aa094d3d663d98fa4bc20eaf436f1f453da5d7
2017-05-16AAPT2: Respect format attr in <array> resourceAdam Lesinski
Bug: 38152130 Test: make aapt2_tests Change-Id: I84f352afb1a8fd2f329354f789aaa36c5ef88e47
2017-05-02Resolve merge conflicts of ccc5b9bbd02a to oc-dev-plus-aospYi Kong
Test: Build Change-Id: I7d3d6bb4c436b2025a0293f9c6475855243f4dd9
2017-05-01SymbolComparator operator() is missing constYi Kong
Clean up, no functionality change. Test: build Bug: 37752547 Change-Id: I7b6f368c0d0776f956a8b99353df7b23cbbc388d
2017-03-31AAPT2: Fix pseudolocalization (again)Adam Lesinski
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
2017-02-22AAPT2: Shared library supportAdam Lesinski
Test: make aapt2_tests Change-Id: I98dddf1367e6c0ac425bb20be46e6ff05f4f2f45
2017-02-08AAPT2: Fix pseudolocalization to respect <xliff:g>Adam Lesinski
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
2017-02-01AAPT2: Support CtsContentTestCases buildAdam Lesinski
- Add <feature-group> to ManifestFixer. - Support <meta-data> in <instrumentation> - Add support for <bag> and type="configVarying". Some CTS tests use this old notation, we need to support it (even though configVarying isn't anything supported by the framework convention). Change-Id: I6946fa633ce513ea8437c1496db883cf27dcf6de Test: make aapt2_tests
2017-01-17Move StringPiece to libandroidfwAdam Lesinski
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
2016-10-26AAPT2: Rename to match new styleAdam Lesinski
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
2016-10-21AAPT2: Ensure string pool ordering is compactAdam Lesinski
Keep styledstrings at the beginning of the StringPool to reduce the padding in the StyledString array. Bug:32336940 Test: manual Change-Id: Iec820c21a54daac40ecc3b2f87517a0f1efc9d3d
2016-10-19Use Google3 style guide with .clang-formatAdam Lesinski
Test: style change only, builds ok Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
2016-09-07AAPT2: Fix issue with styled string indicesAdam Lesinski
Styled strings use spans to denote which part is styled (<b>, <i>, etc). Spans are simply a range of indices into the original string. In Java, we use String and its internal representation, meaning we must encode the indices using UTF16 lengths. When the internal AAPT2 representation of strings switched to UTF8, the indices also began to index into the UTF8 string. This change reverts the indices to use UTF16 lengths. Bug:31170115 Change-Id: I07b8b5b67d2542c7e0a855b601cdbd3ac4ebffb0
2016-08-31AAPT2: Add Inline Complex XML supportAdam Lesinski
See: https://developer.android.com/guide/topics/resources/complex-xml-resources.html Change-Id: I8274c85e25cabf90423141c228697e873167d136
2016-08-15AAPT2: Expose split support to command lineAdam Lesinski
Bug:30445078 Change-Id: If4b8530dba71b9059b8e62c04757da99c1119d22
2016-07-25AAPT2: Add support to specify stable IDsAdam Lesinski
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
2016-07-13AAPT2: Remove usage of u16stringAdam Lesinski
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
2016-04-30AAPT2: Add diff commandAdam Lesinski
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
2016-03-11AAPT2: Add descriptions of Attributes in Styleables for R.javaAdam Lesinski
Change-Id: I69e7b73cbdfe4baf502348397435c501ae29ff5e
2016-02-12AAPT2: Introduce notion of 'product' to ResourceTableAdam Lesinski
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-01-13AAPT2: Variety of small fixes to get the build workingAdam Lesinski
- 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-11AAPT2: Warn when positional arguments exist and --legacy is onAdam Lesinski
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-06AAPT2: Fix product supportAdam Lesinski
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-06AAPT2: Port AAPT pseudolocalization to AAPT2Adam Lesinski
Pseudolocalization happens at the compile phase. Pseudolocalized values are weak, such that manually specified values will take precedence. Change-Id: I5e064ce0d270c9f4f9022f75aecedab9d45bc980
2015-12-17AAPT2: Respect format attribute of <item> tagAdam Lesinski
An <item> is a general tag that can override certain behavior. For instance, this is allowed: <item name="foo" type="integer" format="float">0.4</item> Even though without the format attribute, this would be illegal. Change-Id: I8133ce59e14719a70d7476a1464c3f564c435289
2015-12-10AAPT2: Fix overlay supportAdam Lesinski
Supports the <add-resource> tag and mimics old AAPT behavior of not allowing new resources defined unless <add-resource> was used or --auto-add-overlay was specified. Change-Id: I9b461137357617ade37fd7045b418b8e6450b9c4
2015-11-23AAPT2: Record source/comments for compound values' childrenAdam Lesinski
Values like styles or arrays have children which need to have their source and comments preserved. Change-Id: I6fc713ba36627e6d66c7930b4080cc1403bac207
2015-11-23AAPT2: Verify min/max attr fieldsAdam Lesinski
Integers are now checked to see if they fall in the range of min/max for the attribute they are assigned. Change-Id: I42c435b15fd3f0bd23691c83efccce4ad5973276
2015-11-19AAPT2: Fail compiling when private symbols are referencedAdam Lesinski
Also moved some XML specific stuff into its own directory, and refactored ReferenceLinker a bit. Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
2015-11-16AAPT2: Prevent duplicate enums/flagsAdam Lesinski
Change-Id: I998cba12ac194000e9c778cb620ed7ab33003e7d
2015-11-07AAPT2: Accept aliases defined for external resource typesAdam Lesinski
Resource types that are typically stored outside of the resource table (like layout, xml, drawable) can only have aliases (reference to another resource). Change-Id: Idb768801f02bb142e5be5e438904f221499bd756
2015-11-06AAPT2: Add support for clearer in-progress public attributesAdam Lesinski
Before, the ID assigned to a public resource without an explicitly set id was more difficult to figure out. It would be the next available ID. AAPT2 introduces a new way to specify public attributes in progress. <public-group type="attr" first-id="0x0101047f"> <public name="foo" /> <public name="bar" /> ... </public-group> The IDs assigned to each resource is auto-incremented starting from `first-id`. This also keeps resource's with the same type grouped together so that the auto-incrementing nature is evident. Also, due to how AAPT2 was implemented, this is required :P Change-Id: I95ea92ad0405e87ed0b1766879bb2f1d9d0b636e
2015-11-06AAPT2: Fix inclusion of comments in R.java javadocAdam Lesinski
Comments weren't being copied when merged from the various resource tables. Also refactored the JavaClassGenerator to omit a class if no entries exist for it. Change-Id: I6eaa89b7b3715bc05403635a2baf0d1db3efd142
2015-11-05AAPT2: Fix small issue with detecting translatable resourcesAdam Lesinski
Change-Id: Idd21b5de4d20be06c6f8c8eb5a22ccd68afc4927
2015-11-03AAPT2: Verify positional Java String format arguments in stringsAdam Lesinski
Change-Id: Id415969035a0d5712857c0e11e140155566a960c
2015-10-30AAPT2: Support generating Manifest.javaAdam Lesinski
This includes comments from AndroidManifest.xml. Change-Id: I412d9ecb12bad20a49a683d6b3bea4a0be1235ae
2015-10-22AAPT2: Move comments and source into ValueAdam Lesinski
Values are closely related to where they were defined, so this information should live inside the Value. This also enables comments to be attached to nested Values. Change-Id: Ic7481b5a5f26d0ef248d638e2e29252f88154581
2015-10-22AAPT2: Process <java-symbols> and private symbol packageAdam Lesinski
Need to introduce the idea of multiple levels of visibility to support <java-symbol>. Public, Private, Undefined. Public means it is accessible from outside and requires an ID assigned. Private means that we explicitly want this to be a symbol (show up in R.java), but not visible to other packages. No ID required. Undefined is any normal resource. When --private-symbols is specified in the link phase, these resources will not show up in R.java. Change-Id: Icba89221e08e685dee7683786aa7112baf28c856
2015-10-16Filter products during compile phaseAdam Lesinski
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-16AAPT2: Separate out the various stepsAdam Lesinski
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-05-12AAPT2: Fix issue where @null was wrongly encodedAdam Lesinski
@null must be encoded as TYPE_REFERENCE with a value of 0. TYPE_NULL is used by the runtime as a placeholder when resolving style attributes. If we set a style attribute to TYPE_NULL, the runtime will throw. The runtime will convert a TYPE_REFERENCE with value 0 to a proper null value. Change-Id: Id983ca7e1fbee3124dddafe32f1b5741b824225b
2015-05-12AAPT2: inferred style parent processingAdam Lesinski
Change-Id: I8fbc4feef16b6039cf4c526fcfb767dc75a9c131
2015-05-04Add namespace handling in attribute valuesAdam Lesinski
Previously, you could only reference namespace prefixes in attribute names: <View xmlns:appcompat="http://schemas.android.com/apk/res/android.support.v7.appcompat" appcompat:name="hey" ... Now you can also reference them in resource names within an attribute value: ... android:text="@appcompat:string/confirm" ... Which will be treated as "@android.support.v7.appcompat:string/confirm". Change-Id: Ib076e867a990c80cf877a704eb77cd1ef0b23b52
2015-04-15AAPT2: Add library supportAdam Lesinski
Change-Id: I307f56d9631784ab29ee4156d94886f9b2f25b30
2015-04-03Fix windows build of AAPT2Adam Lesinski
Change-Id: Ib8e1a4322510b582e9600a08d3118842c9abc73c