diff options
author | Ficus Kirkpatrick <ficus@android.com> | 2010-08-13 13:12:40 -0700 |
---|---|---|
committer | Ficus Kirkpatrick <ficus@android.com> | 2010-08-13 13:12:40 -0700 |
commit | 2a195ae73ffc30f57d2e23b721b61933a7eb4f31 (patch) | |
tree | 17dbd795bf0e6af3956aeee010825465aac282cc | |
parent | 7fce63a9a1c82980ed3393a22beb2b46d2a092e7 (diff) | |
download | base-donut.tar.gz |
Add --max-res-version flag to aapt.donut
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.
Change-Id: I5aa6079368db780cd1a197b7ca598f6a3f3ddcd1
-rw-r--r-- | tools/aapt/AaptAssets.cpp | 10 | ||||
-rw-r--r-- | tools/aapt/Bundle.h | 6 | ||||
-rw-r--r-- | tools/aapt/Main.cpp | 12 |
3 files changed, 27 insertions, 1 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index dbcef6d67480..95525ff8b358 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -1638,6 +1638,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 a6fedf3d34bd..d61f8761cc54 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -40,7 +40,7 @@ public: mAndroidManifestFile(NULL), mPublicOutputFile(NULL), mRClassDir(NULL), mResourceIntermediatesDir(NULL), mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL), - mVersionCode(NULL), mVersionName(NULL), + mVersionCode(NULL), mVersionName(NULL), mMaxResVersion(NULL), mArgc(0), mArgv(NULL) {} ~Bundle(void) {} @@ -115,6 +115,9 @@ public: const char* getVersionName() const { return mVersionName; } void setVersionName(const char* val) { mVersionName = val; } + const char* getMaxResVersion() const { return mMaxResVersion; } + void setMaxResVersion(const char * val) { mMaxResVersion = val; } + /* * Set and get the file specification. * @@ -173,6 +176,7 @@ private: const char* mMaxSdkVersion; const char* mVersionCode; const char* mVersionName; + const char* mMaxResVersion; /* file specification */ int mArgc; diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index 12a04454cb54..cf0548661827 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -57,6 +57,7 @@ void usage(void) " [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n" " [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n" " [--max-sdk-version VAL] [--app-version VAL] \\\n" + " [--max-res-version VAL] \\\n" " [--app-version-name TEXT] \\\n" " [-I base-package [-I base-package ...]] \\\n" " [-A asset-source-dir] [-P public-definitions-file] \\\n" @@ -123,6 +124,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" @@ -380,6 +383,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++; |