Specify private resource package in Android.mk

Private resource package shouldn't be buried in some resource file.
It can now be specified on the command line via the Android.mk file.

Change-Id: I9e3cb0bf54830d6b021077af271913306c024701
This commit is contained in:
Adam Lesinski
2015-12-07 14:02:15 -08:00
parent 5f986095be
commit 78713998f9
4 changed files with 35 additions and 2 deletions

View File

@@ -127,6 +127,12 @@ public:
const android::String8& getPlatformBuildVersionName() { return mPlatformVersionName; }
void setPlatformBuildVersionName(const android::String8& name) { mPlatformVersionName = name; }
const android::String8& getPrivateSymbolsPackage() const { return mPrivateSymbolsPackage; }
void setPrivateSymbolsPackage(const android::String8& package) {
mPrivateSymbolsPackage = package;
}
bool getUTF16StringsOption() {
return mWantUTF16 || !isMinSdkAtLeast(SDK_FROYO);
}
@@ -333,6 +339,7 @@ private:
bool mBuildAppAsSharedLibrary;
android::String8 mPlatformVersionCode;
android::String8 mPlatformVersionName;
android::String8 mPrivateSymbolsPackage;
/* file specification */
int mArgc;

View File

@@ -220,7 +220,9 @@ void usage(void)
" Prevents symbols from being generated for strings that do not have a default\n"
" localization\n"
" --no-version-vectors\n"
" Do not automatically generate versioned copies of vector XML resources.\n",
" Do not automatically generate versioned copies of vector XML resources.\n"
" --private-symbols\n"
" Java package name to use when generating R.java for private resources.\n",
gDefaultIgnoreAssets);
}
@@ -689,6 +691,16 @@ int main(int argc, char* const argv[])
bundle.setPseudolocalize(PSEUDO_ACCENTED | PSEUDO_BIDI);
} else if (strcmp(cp, "-no-version-vectors") == 0) {
bundle.setNoVersionVectors(true);
} else if (strcmp(cp, "-private-symbols") == 0) {
argc--;
argv++;
if (!argc) {
fprintf(stderr, "ERROR: No argument supplied for "
"'--private-symbols' option\n");
wantUsage = true;
goto bail;
}
bundle.setPrivateSymbolsPackage(String8(argv[0]));
} else {
fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp);
wantUsage = true;

View File

@@ -1161,6 +1161,12 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
printf("Creating resources for package %s\n", assets->getPackage().string());
}
// Set the private symbols package if it was declared.
// This can also be declared in XML as <private-symbols name="package" />
if (bundle->getPrivateSymbolsPackage().size() != 0) {
assets->setSymbolsPrivatePackage(bundle->getPrivateSymbolsPackage());
}
ResourceTable::PackageType packageType = ResourceTable::App;
if (bundle->getBuildSharedLibrary()) {
packageType = ResourceTable::SharedLibrary;

View File

@@ -1141,7 +1141,15 @@ status_t compileResourceFile(Bundle* bundle,
}
pkg = String16(block.getAttributeStringValue(pkgIdx, &len));
if (!localHasErrors) {
assets->setSymbolsPrivatePackage(String8(pkg));
SourcePos(in->getPrintableSource(), block.getLineNumber()).warning(
"<private-symbols> is deprecated. Use the command line flag "
"--private-symbols instead.\n");
if (assets->havePrivateSymbols()) {
SourcePos(in->getPrintableSource(), block.getLineNumber()).warning(
"private symbol package already specified. Ignoring...\n");
} else {
assets->setSymbolsPrivatePackage(String8(pkg));
}
}
while ((code=block.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {