diff options
author | Ficus Kirkpatrick <ficus@android.com> | 2010-08-13 14:01:29 -0700 |
---|---|---|
committer | Ficus Kirkpatrick <ficus@android.com> | 2010-08-13 14:02:58 -0700 |
commit | e9a83c49c7f5c2524226ddefc21105deb14d80db (patch) | |
tree | af749df41913b1380c54a28194ed23b91a0aceac | |
parent | 3a71cd9953bb321e654995b300ff894084ce123b (diff) | |
download | base-e9a83c49c7f5c2524226ddefc21105deb14d80db.tar.gz |
Add --max-res-version flag to aapt.android-cts-2.1_r5android-cts-2.1_r4
aapt will ignore any versioned resource directories over the
specified version (if used). e.g. --max-res-version=6 will
cause layout-land-v7 to be ignored.
Merged from donut.
Change-Id: Ic4908ae85879ec6e0c8be9d3c0fbe285d2e57c43
-rw-r--r-- | tools/aapt/AaptAssets.cpp | 10 | ||||
-rw-r--r-- | tools/aapt/Bundle.h | 4 | ||||
-rw-r--r-- | tools/aapt/Main.cpp | 12 |
3 files changed, 26 insertions, 0 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index c346b90d5a84..20a002dbbd13 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -1695,6 +1695,16 @@ ssize_t AaptAssets::slurpResourceTree(Bundle* bundle, const String8& srcDir) continue; } + if (bundle->getMaxResVersion() != NULL && group.version.length() != 0) { + int maxResInt = atoi(bundle->getMaxResVersion()); + const char *verString = group.version.string(); + int dirVersionInt = atoi(verString + 1); // skip 'v' in version name + if (dirVersionInt > maxResInt) { + fprintf(stderr, "max res %d, skipping %s\n", maxResInt, entry->d_name); + continue; + } + } + FileType type = getFileType(subdirName.string()); if (type == kFileTypeDirectory) { diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h index 74d269d8007c..bec7052a6924 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -44,6 +44,7 @@ public: mRClassDir(NULL), mResourceIntermediatesDir(NULL), mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL), mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), + mMaxResVersion(NULL), mArgc(0), mArgv(NULL) {} ~Bundle(void) {} @@ -125,6 +126,8 @@ public: void setVersionName(const char* val) { mVersionName = val; } const char* getCustomPackage() const { return mCustomPackage; } void setCustomPackage(const char* val) { mCustomPackage = val; } + const char* getMaxResVersion() const { return mMaxResVersion; } + void setMaxResVersion(const char * val) { mMaxResVersion = val; } /* * Set and get the file specification. @@ -188,6 +191,7 @@ private: const char* mVersionCode; const char* mVersionName; const char* mCustomPackage; + const char* mMaxResVersion; /* file specification */ int mArgc; diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index 1a4ec7a47291..81be20bc8c49 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -61,6 +61,7 @@ void usage(void) " [--max-sdk-version VAL] [--app-version VAL] \\\n" " [--app-version-name TEXT] [--custom-package VAL] \\\n" " [--auto-add-overlay] \\\n" + " [--max-res-version VAL] \\\n" " [-I base-package [-I base-package ...]] \\\n" " [-A asset-source-dir] [-G class-list-file] [-P public-definitions-file] \\\n" " [-S resource-sources [-S resource-sources ...]] " @@ -128,6 +129,8 @@ void usage(void) " inserts android:targetSdkVersion in to manifest.\n" " --max-sdk-version\n" " inserts android:maxSdkVersion in to manifest.\n" + " --max-res-version\n" + " ignores versioned resource directories above the given value.\n" " --values\n" " when used with \"dump resources\" also includes resource values.\n" " --version-code\n" @@ -403,6 +406,15 @@ int main(int argc, char* const argv[]) goto bail; } bundle.setMaxSdkVersion(argv[0]); + } else if (strcmp(cp, "-max-res-version") == 0) { + argc--; + argv++; + if (!argc) { + fprintf(stderr, "ERROR: No argument supplied for '--max-res-version' option\n"); + wantUsage = true; + goto bail; + } + bundle.setMaxResVersion(argv[0]); } else if (strcmp(cp, "-version-code") == 0) { argc--; argv++; |