Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2be56ccb authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android (Google) Code Review
Browse files

Merge "Add --auto-add-overlay option to aapt. DO NOT MERGE" into eclair

parents 19bc31c3 b9d2dc23
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ public:
          mRequireLocalization(false), mPseudolocalize(false),
          mRequireLocalization(false), mPseudolocalize(false),
          mValues(false),
          mValues(false),
          mCompressionMethod(0), mOutputAPKFile(NULL),
          mCompressionMethod(0), mOutputAPKFile(NULL),
          mAssetSourceDir(NULL), mProguardFile(NULL),
          mAutoAddOverlay(false), mAssetSourceDir(NULL), mProguardFile(NULL),
          mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
          mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
          mRClassDir(NULL), mResourceIntermediatesDir(NULL),
          mRClassDir(NULL), mResourceIntermediatesDir(NULL),
          mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
          mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
@@ -84,6 +84,8 @@ public:
    void setJunkPath(bool val) { mJunkPath = val; }
    void setJunkPath(bool val) { mJunkPath = val; }
    const char* getOutputAPKFile() const { return mOutputAPKFile; }
    const char* getOutputAPKFile() const { return mOutputAPKFile; }
    void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
    void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
    bool getAutoAddOverlay() { return mAutoAddOverlay; }
    void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }


    /*
    /*
     * Input options.
     * Input options.
@@ -167,6 +169,7 @@ private:
    int         mCompressionMethod;
    int         mCompressionMethod;
    bool        mJunkPath;
    bool        mJunkPath;
    const char* mOutputAPKFile;
    const char* mOutputAPKFile;
    bool        mAutoAddOverlay;
    const char* mAssetSourceDir;
    const char* mAssetSourceDir;
    const char* mProguardFile;
    const char* mProguardFile;
    const char* mAndroidManifestFile;
    const char* mAndroidManifestFile;
+6 −1
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ void usage(void)
        "        [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
        "        [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
        "        [--max-sdk-version VAL] [--app-version VAL] \\\n"
        "        [--max-sdk-version VAL] [--app-version VAL] \\\n"
        "        [--app-version-name TEXT] [--custom-package VAL] \\\n"
        "        [--app-version-name TEXT] [--custom-package VAL] \\\n"
        "        [--auto-add-overlay] \\\n"
        "        [-I base-package [-I base-package ...]] \\\n"
        "        [-I base-package [-I base-package ...]] \\\n"
        "        [-A asset-source-dir]  [-G class-list-file] [-P public-definitions-file] \\\n"
        "        [-A asset-source-dir]  [-G class-list-file] [-P public-definitions-file] \\\n"
        "        [-S resource-sources [-S resource-sources ...]] "
        "        [-S resource-sources [-S resource-sources ...]] "
@@ -134,7 +135,9 @@ void usage(void)
        "   --version-name\n"
        "   --version-name\n"
        "       inserts android:versionName in to manifest.\n"
        "       inserts android:versionName in to manifest.\n"
        "   --custom-package\n"
        "   --custom-package\n"
        "       generates R.java into a different package.\n");
        "       generates R.java into a different package.\n"
        "   --auto-add-overlay\n"
        "       Automatically add resources that are only in overlays.\n");
}
}


/*
/*
@@ -429,6 +432,8 @@ int main(int argc, char* const argv[])
                        goto bail;
                        goto bail;
                    }
                    }
                    bundle.setCustomPackage(argv[0]);
                    bundle.setCustomPackage(argv[0]);
                } else if (strcmp(cp, "-auto-add-overlay") == 0) {
                    bundle.setAutoAddOverlay(true);
                } else {
                } else {
                    fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp);
                    fprintf(stderr, "ERROR: Unknown option '-%s'\n", cp);
                    wantUsage = true;
                    wantUsage = true;
+5 −4
Original line number Original line Diff line number Diff line
@@ -1587,7 +1587,7 @@ status_t ResourceTable::startBag(const SourcePos& sourcePos,
               sourcePos.file.striing(), sourcePos.line, String8(type).string());
               sourcePos.file.striing(), sourcePos.line, String8(type).string());
    }
    }
#endif
#endif
    if (overlay && !hasBagOrEntry(package, type, name)) {
    if (overlay && !mBundle->getAutoAddOverlay() && !hasBagOrEntry(package, type, name)) {
        bool canAdd = false;
        bool canAdd = false;
        sp<Package> p = mPackages.valueFor(package);
        sp<Package> p = mPackages.valueFor(package);
        if (p != NULL) {
        if (p != NULL) {
@@ -3275,12 +3275,13 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry,
                                                       const SourcePos& sourcePos,
                                                       const SourcePos& sourcePos,
                                                       const ResTable_config* config,
                                                       const ResTable_config* config,
                                                       bool doSetIndex,
                                                       bool doSetIndex,
                                                       bool overlay)
                                                       bool overlay,
                                                       bool autoAddOverlay)
{
{
    int pos = -1;
    int pos = -1;
    sp<ConfigList> c = mConfigs.valueFor(entry);
    sp<ConfigList> c = mConfigs.valueFor(entry);
    if (c == NULL) {
    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"
            sourcePos.error("Resource at %s appears in overlay but not"
                            " in the base package; use <add-resource> to add.\n",
                            " in the base package; use <add-resource> to add.\n",
                            String8(entry).string());
                            String8(entry).string());
@@ -3592,7 +3593,7 @@ sp<ResourceTable::Entry> ResourceTable::getEntry(const String16& package,
    if (t == NULL) {
    if (t == NULL) {
        return 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,
sp<const ResourceTable::Entry> ResourceTable::getEntry(uint32_t resID,
+2 −1
Original line number Original line Diff line number Diff line
@@ -424,7 +424,8 @@ public:
                           const SourcePos& pos,
                           const SourcePos& pos,
                           const ResTable_config* config = NULL,
                           const ResTable_config* config = NULL,
                           bool doSetIndex = false,
                           bool doSetIndex = false,
                           bool overlay = false);
                           bool overlay = false,
                           bool autoAddOverlay = false);


        const SourcePos& getFirstPublicSourcePos() const { return *mFirstPublicSourcePos; }
        const SourcePos& getFirstPublicSourcePos() const { return *mFirstPublicSourcePos; }