summaryrefslogtreecommitdiffstats
path: root/tools/aapt
diff options
context:
space:
mode:
authorChirayu Desai <cdesai@cyanogenmod.org>2013-05-06 12:21:31 +0530
committerSteve Kondik <shade@chemlab.org>2013-05-06 00:49:54 -0700
commite1e339e4a47658920c7e575ee0b618b0ab116cb0 (patch)
treeaa126f132f1c948a6fb139a39865a17a7e5aeab7 /tools/aapt
parent923546df75cd564c53d7dd30dc141a033f090d27 (diff)
downloadframeworks_base-e1e339e4a47658920c7e575ee0b618b0ab116cb0.zip
frameworks_base-e1e339e4a47658920c7e575ee0b618b0ab116cb0.tar.gz
frameworks_base-e1e339e4a47658920c7e575ee0b618b0ab116cb0.tar.bz2
aapt: allow toggling "errors instead of warnings"
* This patch makes the default behaviour same as AOSP, treating untranslatable strings in any but the default locale as warnings. * Setting the environment variable AAPT_ERROR_ON_WARNING to anything will make those warnings, errors. Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org> Change-Id: I7da98d277495a7646ad64ba2f7e6a6bf14290f98
Diffstat (limited to 'tools/aapt')
-rw-r--r--tools/aapt/ResourceTable.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 61d62fd..0019eb1 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -14,6 +14,7 @@
#include <androidfw/ResourceTypes.h>
#include <utils/ByteOrder.h>
#include <stdarg.h>
+#include <stdlib.h>
#define NOISY(x) //x
@@ -790,6 +791,7 @@ status_t compileResourceFile(Bundle* bundle,
const String16 myPackage(assets->getPackage());
bool hasErrors = false;
+ bool errorOnWarning = getenv("AAPT_ERROR_ON_WARNING") != NULL ? true : false;
bool fileIsTranslatable = true;
if (strstr(in->getPrintableSource().string(), "donottranslate") != NULL) {
@@ -1281,11 +1283,13 @@ status_t compileResourceFile(Bundle* bundle,
curIsFormatted = false;
// Untranslatable strings must only exist in the default [empty] locale
if (locale.size() > 0) {
- fprintf(stderr, "aapt: error: string '%s' in %s marked untranslatable but exists"
+ fprintf(stderr, "aapt: warning: string '%s' in %s marked untranslatable but exists"
" in locale '%s'\n", String8(name).string(),
bundle->getResourceSourceDirs()[0],
locale.string());
- hasErrors = localHasErrors = true;
+ if (errorOnWarning) {
+ hasErrors = localHasErrors = true;
+ }
} else {
// Intentionally empty block:
//
@@ -1389,11 +1393,13 @@ status_t compileResourceFile(Bundle* bundle,
curIsFormatted = false;
// Untranslatable strings must only exist in the default [empty] locale
if (locale.size() > 0) {
- fprintf(stderr, "aapt: error: string-array '%s' in %s marked untranslatable but exists"
+ fprintf(stderr, "aapt: warning: string-array '%s' in %s marked untranslatable but exists"
" in locale '%s'\n", String8(name).string(),
bundle->getResourceSourceDirs()[0],
locale.string());
- hasErrors = localHasErrors = true;
+ if (errorOnWarning) {
+ hasErrors = localHasErrors = true;
+ }
}
break;
}
@@ -2527,9 +2533,9 @@ ResourceTable::addLocalization(const String16& name, const String8& locale)
* Flag various sorts of localization problems. '+' indicates checks already implemented;
* '-' indicates checks that will be implemented in the future.
*
- * + A localized string for which no default-locale version exists => error
+ * + A localized string for which no default-locale version exists => warning or error
* + A string for which no version in an explicitly-requested locale exists => warning
- * + A localized translation of an translateable="false" string => error
+ * + A localized translation of an translateable="false" string => warning or error
* - A localized string not provided in every locale used by the table
*/
status_t
@@ -2537,6 +2543,7 @@ ResourceTable::validateLocalizations(void)
{
status_t err = NO_ERROR;
const String8 defaultLocale;
+ bool errorOnWarning = getenv("AAPT_ERROR_ON_WARNING") != NULL ? true : false;
// For all strings...
for (map<String16, set<String8> >::iterator nameIter = mLocalizations.begin();
@@ -2546,7 +2553,7 @@ ResourceTable::validateLocalizations(void)
// Look for strings with no default localization
if (configSet.count(defaultLocale) == 0) {
- fprintf(stderr, "aapt: error: string '%s' has no default translation in %s; found:",
+ fprintf(stderr, "aapt: warning: string '%s' has no default translation in %s; found:",
String8(nameIter->first).string(), mBundle->getResourceSourceDirs()[0]);
for (set<String8>::const_iterator locales = configSet.begin();
locales != configSet.end();
@@ -2554,7 +2561,9 @@ ResourceTable::validateLocalizations(void)
fprintf(stderr, " %s", (*locales).string());
}
fprintf(stderr, "\n");
- err = BAD_VALUE;
+ if (errorOnWarning) {
+ err = BAD_VALUE;
+ }
}
// Check that all requested localizations are present for this string