]> git.saurik.com Git - android/aapt.git/commitdiff
am d5431ed5: am 2e659ae5: am 42755155: Merge "Copy once-created R.java into library...
authorXavier Ducrohet <xav@android.com>
Tue, 19 Jul 2011 17:18:25 +0000 (10:18 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Tue, 19 Jul 2011 17:18:25 +0000 (10:18 -0700)
* commit 'd5431ed5505a42e5e33c8bf7cc2ff72792979be9':
  Copy once-created R.java into library projects

Bundle.h
Command.cpp
Main.cpp

index fa84e938cab4732749f3ca36634947ae8891de95..a32aa7f5c97ec8f6cd464a48ba38458d907d8bd4 100644 (file)
--- a/Bundle.h
+++ b/Bundle.h
@@ -45,7 +45,7 @@ public:
           mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
           mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
           mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
-          mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL),
+          mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mExtraPackages(NULL),
           mMaxResVersion(NULL), mDebugMode(false), mNonConstantId(false), mProduct(NULL),
           mArgc(0), mArgv(NULL)
         {}
@@ -138,6 +138,8 @@ public:
     void setVersionName(const char* val) { mVersionName = val; }
     const char* getCustomPackage() const { return mCustomPackage; }
     void setCustomPackage(const char* val) { mCustomPackage = val; }
+    const char* getExtraPackages() const { return mExtraPackages; }
+    void setExtraPackages(const char* val) { mExtraPackages = val; }
     const char* getMaxResVersion() const { return mMaxResVersion; }
     void setMaxResVersion(const char * val) { mMaxResVersion = val; }
     bool getDebugMode() { return mDebugMode; }
@@ -243,6 +245,7 @@ private:
     const char* mVersionCode;
     const char* mVersionName;
     const char* mCustomPackage;
+    const char* mExtraPackages;
     const char* mMaxResVersion;
     bool        mDebugMode;
     bool        mNonConstantId;
index 7852197ef63726503d0d8e9978a1061d0fedc94e..a369e8042c2cd4903637c6b8359f0373bbe83e2f 100644 (file)
@@ -1569,6 +1569,17 @@ int doPackage(Bundle* bundle)
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
         if (bundle->getCustomPackage() == NULL) {
             err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+            // Copy R.java for libraries
+            if (bundle->getExtraPackages() != NULL) {
+                // Split on semicolon
+                String8 libs(bundle->getExtraPackages());
+                char* packageString = strtok(libs.lockBuffer(libs.length()), ";");
+                while (packageString != NULL) {
+                    err = writeResourceSymbols(bundle, assets, String8(packageString), true);
+                    packageString = strtok(NULL, ";");
+                }
+                libs.unlockBuffer();
+            }
         } else {
             const String8 customPkg(bundle->getCustomPackage());
             err = writeResourceSymbols(bundle, assets, customPkg, true);
index 1e63131eb5bfbe5ee7348a7991eff289a168a32c..732541d7f4b0ac52ce54f5d8019d8911f350c722 100644 (file)
--- a/Main.cpp
+++ b/Main.cpp
@@ -145,6 +145,8 @@ void usage(void)
         "       inserts android:versionName in to manifest.\n"
         "   --custom-package\n"
         "       generates R.java into a different package.\n"
+        "   --extra-packages\n"
+        "       generate R.java for libraries. Separate libraries with ';'.\n"
         "   --auto-add-overlay\n"
         "       Automatically add resources that are only in overlays.\n"
         "   --rename-manifest-package\n"
@@ -475,6 +477,15 @@ int main(int argc, char* const argv[])
                         goto bail;
                     }
                     bundle.setCustomPackage(argv[0]);
+                } else if (strcmp(cp, "-extra-packages") == 0) {
+                    argc--;
+                    argv++;
+                    if (!argc) {
+                        fprintf(stderr, "ERROR: No argument supplied for '--extra-packages' option\n");
+                        wantUsage = true;
+                        goto bail;
+                    }
+                    bundle.setExtraPackages(argv[0]);
                 } else if (strcmp(cp, "-utf16") == 0) {
                     bundle.setWantUTF16(true);
                 } else if (strcmp(cp, "-rename-manifest-package") == 0) {