diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-01-11 13:10:24 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-01-13 18:48:24 -0800 |
commit | 52364f7ae31716d7827ea8f8566f4a28bd30a921 (patch) | |
tree | ce146fb6dc5e9f9b1166964b77273b6481f8258b /tools/aapt2/ResourceUtils.cpp | |
parent | d901155166983adde84d9da2a6b265371191068a (diff) |
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
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r-- | tools/aapt2/ResourceUtils.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index 1dc123e45949..07f62afe05b9 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -176,7 +176,7 @@ bool isAttributeReference(const StringPiece16& str) { /* * Style parent's are a bit different. We accept the following formats: * - * @[[*]package:]style/<entry> + * @[[*]package:][style/]<entry> * ?[[*]package:]style/<entry> * <[*]package>:[style/]<entry> * [[*]package:style/]<entry> @@ -216,14 +216,6 @@ Maybe<Reference> parseStyleParentReference(const StringPiece16& str, std::string *outError = err.str(); return {}; } - } else { - // No type was defined, this should not have a leading identifier. - if (hasLeadingIdentifiers) { - std::stringstream err; - err << "invalid parent reference '" << str << "'"; - *outError = err.str(); - return {}; - } } if (!hasLeadingIdentifiers && ref.package.empty() && !typeStr.empty()) { @@ -294,6 +286,12 @@ std::unique_ptr<BinaryPrimitive> tryParseFlagSymbol(const Attribute* flagAttr, const StringPiece16& str) { android::Res_value flags = { }; flags.dataType = android::Res_value::TYPE_INT_DEC; + flags.data = 0u; + + if (util::trimWhitespace(str).empty()) { + // Empty string is a valid flag (0). + return util::make_unique<BinaryPrimitive>(flags); + } for (StringPiece16 part : util::tokenize(str, u'|')) { StringPiece16 trimmedPart = util::trimWhitespace(part); @@ -386,12 +384,12 @@ std::unique_ptr<BinaryPrimitive> tryParseColor(const StringPiece16& str) { bool tryParseBool(const StringPiece16& str, bool* outValue) { StringPiece16 trimmedStr(util::trimWhitespace(str)); - if (trimmedStr == u"true" || trimmedStr == u"TRUE") { + if (trimmedStr == u"true" || trimmedStr == u"TRUE" || trimmedStr == u"True") { if (outValue) { *outValue = true; } return true; - } else if (trimmedStr == u"false" || trimmedStr == u"FALSE") { + } else if (trimmedStr == u"false" || trimmedStr == u"FALSE" || trimmedStr == u"False") { if (outValue) { *outValue = false; } |