]> git.saurik.com Git - android/aapt.git/commitdiff
Add --auto-add-overlay option to aapt.
authorXavier Ducrohet <xav@android.com>
Fri, 5 Feb 2010 02:45:31 +0000 (18:45 -0800)
committerXavier Ducrohet <xav@android.com>
Fri, 5 Feb 2010 02:53:14 +0000 (18:53 -0800)
This option allows resources only present in overlays to be
added automatically instead of being declared through <add-resource>

Change-Id: Iff782311056f6a045193e57d204f7d3413e11b26

Bundle.h
Main.cpp
ResourceTable.cpp
ResourceTable.h

index cbb520388d3721cee920d5ad9d8f9fe7df0c6b7e..558b587c4d8d63aa118b67e2437860eeb2da2d3a 100644 (file)
--- a/Bundle.h
+++ b/Bundle.h
@@ -39,7 +39,7 @@ public:
           mRequireLocalization(false), mPseudolocalize(false),
           mUTF8(false), mEncodingSpecified(false), mValues(false),
           mCompressionMethod(0), mOutputAPKFile(NULL), mManifestPackageNameOverride(NULL),
-          mAssetSourceDir(NULL), mProguardFile(NULL),
+          mAutoAddOverlay(false), mAssetSourceDir(NULL), mProguardFile(NULL),
           mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
           mRClassDir(NULL), mResourceIntermediatesDir(NULL),
           mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
@@ -90,6 +90,8 @@ public:
     void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
     const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride; }
     void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; }
+    bool getAutoAddOverlay() { return mAutoAddOverlay; }
+    void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }
 
     /*
      * Input options.
@@ -181,6 +183,7 @@ private:
     bool        mJunkPath;
     const char* mOutputAPKFile;
     const char* mManifestPackageNameOverride;
+    bool        mAutoAddOverlay;
     const char* mAssetSourceDir;
     const char* mProguardFile;
     const char* mAndroidManifestFile;
index 6675ac270a10e95b22da8d41eea2b14b7cbaa455..6d0a351bd157aa53af3cd24389d867d04c8d7239 100644 (file)
--- a/Main.cpp
+++ b/Main.cpp
@@ -60,6 +60,7 @@ void usage(void)
         "        [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
         "        [--max-sdk-version VAL] [--app-version VAL] \\\n"
         "        [--app-version-name TEXT] [--custom-package VAL] [--utf16] \\\n"
+        "        [--auto-add-overlay] \\\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 ...]] "
@@ -136,6 +137,8 @@ void usage(void)
         "       inserts android:versionName in to manifest.\n"
         "   --custom-package\n"
         "       generates R.java into a different package.\n"
+        "   --auto-add-overlay\n"
+        "       Automatically add resources that are only in overlays.\n"
         "   --utf16\n"
         "       changes default encoding for resources to UTF-16.  Only useful when API\n"
         "       level is set to 7 or higher where the default encoding is UTF-8.\n");
@@ -445,6 +448,8 @@ int main(int argc, char* const argv[])
                         goto bail;
                     }
                     bundle.setManifestPackageNameOverride(argv[0]);
+                } else if (strcmp(cp, "-auto-add-overlay") == 0) {
+                    bundle.setAutoAddOverlay(true);
                 } else {
                     fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp);
                     wantUsage = true;
index a9cbd11b468805332369a295988a9a843c8d3f9b..b682702e7ed1b7350a1638b3b13598cce7235d98 100644 (file)
@@ -1591,7 +1591,7 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos,
                sourcePos.file.striing(), sourcePos.line, String8(type).string());
     }
 #endif
-    if (overlay && !hasBagOrEntry(package, type, name)) {
+    if (overlay && !mBundle->getAutoAddOverlay() && !hasBagOrEntry(package, type, name)) {
         bool canAdd = false;
         sp<Package> p = mPackages.valueFor(package);
         if (p != NULL) {
@@ -3279,12 +3279,13 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry,
                                                        const SourcePos& sourcePos,
                                                        const ResTable_config* config,
                                                        bool doSetIndex,
-                                                       bool overlay)
+                                                       bool overlay,
+                                                       bool autoAddOverlay)
 {
     int pos = -1;
     sp<ConfigList> c = mConfigs.valueFor(entry);
     if (c == NULL) {
-        if (overlay == true && mCanAddEntries.indexOf(entry) < 0) {
+        if (overlay && !autoAddOverlay && mCanAddEntries.indexOf(entry) < 0) {
             sourcePos.error("Resource at %s appears in overlay but not"
                             " in the base package; use <add-resource> to add.\n",
                             String8(entry).string());
@@ -3596,7 +3597,7 @@ sp<ResourceTable::Entry> ResourceTable::getEntry(const String16& package,
     if (t == NULL) {
         return NULL;
     }
-    return t->getEntry(name, sourcePos, config, doSetIndex, overlay);
+    return t->getEntry(name, sourcePos, config, doSetIndex, overlay, mBundle->getAutoAddOverlay());
 }
 
 sp<const ResourceTable::Entry> ResourceTable::getEntry(uint32_t resID,
index cfa75a716b641c69946d39154bfee52765747169..60d09012beda4722ee8f71a019894f5ff34abf16 100644 (file)
@@ -425,7 +425,8 @@ public:
                            const SourcePos& pos,
                            const ResTable_config* config = NULL,
                            bool doSetIndex = false,
-                           bool overlay = false);
+                           bool overlay = false,
+                           bool autoAddOverlay = false);
 
         const SourcePos& getFirstPublicSourcePos() const { return *mFirstPublicSourcePos; }