2 // Copyright 2006 The Android Open Source Project
4 // State bundle. Used to pass around stuff like command-line args.
10 #include <utils.h> // android
11 #include <utils/String8.h>
12 #include <utils/Vector.h>
17 typedef enum Command
{
28 * Bundle of goodies, including everything specified on the command line.
33 : mCmd(kCommandUnknown
), mVerbose(false), mAndroidList(false),
34 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
35 mUpdate(false), mExtending(false),
36 mRequireLocalization(false), mPseudolocalize(false),
37 mCompressionMethod(0), mOutputAPKFile(NULL
),
38 mAssetSourceDir(NULL
),
39 mAndroidManifestFile(NULL
), mPublicOutputFile(NULL
),
40 mRClassDir(NULL
), mResourceIntermediatesDir(NULL
),
41 mMinSdkVersion(NULL
), mTargetSdkVersion(NULL
), mMaxSdkVersion(NULL
),
42 mVersionCode(NULL
), mVersionName(NULL
),
48 * Set the command value. Returns "false" if it was previously set.
50 Command
getCommand(void) const { return mCmd
; }
51 void setCommand(Command cmd
) { mCmd
= cmd
; }
54 * Command modifiers. Not all modifiers are appropriate for all
57 bool getVerbose(void) const { return mVerbose
; }
58 void setVerbose(bool val
) { mVerbose
= val
; }
59 bool getAndroidList(void) const { return mAndroidList
; }
60 void setAndroidList(bool val
) { mAndroidList
= val
; }
61 bool getForce(void) const { return mForce
; }
62 void setForce(bool val
) { mForce
= val
; }
63 void setGrayscaleTolerance(int val
) { mGrayscaleTolerance
= val
; }
64 int getGrayscaleTolerance() { return mGrayscaleTolerance
; }
65 bool getMakePackageDirs(void) const { return mMakePackageDirs
; }
66 void setMakePackageDirs(bool val
) { mMakePackageDirs
= val
; }
67 bool getUpdate(void) const { return mUpdate
; }
68 void setUpdate(bool val
) { mUpdate
= val
; }
69 bool getExtending(void) const { return mExtending
; }
70 void setExtending(bool val
) { mExtending
= val
; }
71 bool getRequireLocalization(void) const { return mRequireLocalization
; }
72 void setRequireLocalization(bool val
) { mRequireLocalization
= val
; }
73 bool getPseudolocalize(void) const { return mPseudolocalize
; }
74 void setPseudolocalize(bool val
) { mPseudolocalize
= val
; }
75 int getCompressionMethod(void) const { return mCompressionMethod
; }
76 void setCompressionMethod(int val
) { mCompressionMethod
= val
; }
77 const char* getOutputAPKFile() const { return mOutputAPKFile
; }
78 void setOutputAPKFile(const char* val
) { mOutputAPKFile
= val
; }
83 const char* getAssetSourceDir() const { return mAssetSourceDir
; }
84 void setAssetSourceDir(const char* dir
) { mAssetSourceDir
= dir
; }
85 const android::Vector
<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs
; }
86 void addResourceSourceDir(const char* dir
) { mResourceSourceDirs
.insertAt(dir
,0); }
87 const char* getAndroidManifestFile() const { return mAndroidManifestFile
; }
88 void setAndroidManifestFile(const char* file
) { mAndroidManifestFile
= file
; }
89 const char* getPublicOutputFile() const { return mPublicOutputFile
; }
90 void setPublicOutputFile(const char* file
) { mPublicOutputFile
= file
; }
91 const char* getRClassDir() const { return mRClassDir
; }
92 void setRClassDir(const char* dir
) { mRClassDir
= dir
; }
93 const char* getConfigurations() const { return mConfigurations
.size() > 0 ? mConfigurations
.string() : NULL
; }
94 void addConfigurations(const char* val
) { if (mConfigurations
.size() > 0) { mConfigurations
.append(","); mConfigurations
.append(val
); } else { mConfigurations
= val
; } }
95 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir
; }
96 void setResourceIntermediatesDir(const char* dir
) { mResourceIntermediatesDir
= dir
; }
97 const android::Vector
<const char*>& getPackageIncludes() const { return mPackageIncludes
; }
98 void addPackageInclude(const char* file
) { mPackageIncludes
.add(file
); }
99 const android::Vector
<const char*>& getJarFiles() const { return mJarFiles
; }
100 void addJarFile(const char* file
) { mJarFiles
.add(file
); }
101 const android::Vector
<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions
; }
102 void addNoCompressExtension(const char* ext
) { mNoCompressExtensions
.add(ext
); }
104 const char* getMinSdkVersion() const { return mMinSdkVersion
; }
105 void setMinSdkVersion(const char* val
) { mMinSdkVersion
= val
; }
106 const char* getTargetSdkVersion() const { return mTargetSdkVersion
; }
107 void setTargetSdkVersion(const char* val
) { mTargetSdkVersion
= val
; }
108 const char* getMaxSdkVersion() const { return mMaxSdkVersion
; }
109 void setMaxSdkVersion(const char* val
) { mMaxSdkVersion
= val
; }
110 const char* getVersionCode() const { return mVersionCode
; }
111 void setVersionCode(const char* val
) { mVersionCode
= val
; }
112 const char* getVersionName() const { return mVersionName
; }
113 void setVersionName(const char* val
) { mVersionName
= val
; }
116 * Set and get the file specification.
118 * Note this does NOT make a copy of argv.
120 void setFileSpec(char* const argv
[], int argc
) {
124 int getFileSpecCount(void) const { return mArgc
; }
125 const char* getFileSpecEntry(int idx
) const { return mArgv
[idx
]; }
126 void eatArgs(int n
) {
127 if (n
> mArgc
) n
= mArgc
;
134 * Package count. Nothing to do with anything else here; this is
135 * just a convenient place to stuff it so we don't have to pass it
138 int getPackageCount(void) const { return mPackageCount
; }
139 void setPackageCount(int val
) { mPackageCount
= val
; }
143 /* commands & modifiers */
148 int mGrayscaleTolerance
;
149 bool mMakePackageDirs
;
152 bool mRequireLocalization
;
153 bool mPseudolocalize
;
154 int mCompressionMethod
;
155 const char* mOutputAPKFile
;
156 const char* mAssetSourceDir
;
157 const char* mAndroidManifestFile
;
158 const char* mPublicOutputFile
;
159 const char* mRClassDir
;
160 const char* mResourceIntermediatesDir
;
161 android::String8 mConfigurations
;
162 android::Vector
<const char*> mPackageIncludes
;
163 android::Vector
<const char*> mJarFiles
;
164 android::Vector
<const char*> mNoCompressExtensions
;
165 android::Vector
<const char*> mResourceSourceDirs
;
167 const char* mMinSdkVersion
;
168 const char* mTargetSdkVersion
;
169 const char* mMaxSdkVersion
;
170 const char* mVersionCode
;
171 const char* mVersionName
;
173 /* file specification */