]> git.saurik.com Git - android/aapt.git/blame - Bundle.h
Fix "Too many open files" error for aapt built with Mac OS X SDK 10.6.
[android/aapt.git] / Bundle.h
CommitLineData
a534180c
TAOSP
1//
2// Copyright 2006 The Android Open Source Project
3//
4// State bundle. Used to pass around stuff like command-line args.
5//
6#ifndef __BUNDLE_H
7#define __BUNDLE_H
8
9#include <stdlib.h>
79e5d372
MA
10#include <utils/Log.h>
11#include <utils/threads.h>
12#include <utils/List.h>
13#include <utils/Errors.h>
a534180c
TAOSP
14#include <utils/String8.h>
15#include <utils/Vector.h>
16
17/*
18 * Things we can do.
19 */
20typedef enum Command {
21 kCommandUnknown = 0,
22 kCommandVersion,
23 kCommandList,
24 kCommandDump,
25 kCommandAdd,
26 kCommandRemove,
27 kCommandPackage,
dddb1fc7 28 kCommandCrunch,
a534180c
TAOSP
29} Command;
30
31/*
32 * Bundle of goodies, including everything specified on the command line.
33 */
34class Bundle {
35public:
36 Bundle(void)
37 : mCmd(kCommandUnknown), mVerbose(false), mAndroidList(false),
38 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
39 mUpdate(false), mExtending(false),
40 mRequireLocalization(false), mPseudolocalize(false),
5af43148 41 mWantUTF16(false), mValues(false),
af945cf3
DH
42 mCompressionMethod(0), mOutputAPKFile(NULL),
43 mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL),
52ffc169 44 mAutoAddOverlay(false), mGenDependencies(false),
dddb1fc7
JG
45 mAssetSourceDir(NULL),
46 mCrunchedOutputDir(NULL), mProguardFile(NULL),
a534180c 47 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
5af43148 48 mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
53288885 49 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
bc7b4f40 50 mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mExtraPackages(NULL),
54f200b0 51 mMaxResVersion(NULL), mDebugMode(false), mNonConstantId(false), mProduct(NULL),
dddb1fc7 52 mUseCrunchCache(false), mArgc(0), mArgv(NULL)
a534180c
TAOSP
53 {}
54 ~Bundle(void) {}
55
56 /*
57 * Set the command value. Returns "false" if it was previously set.
58 */
59 Command getCommand(void) const { return mCmd; }
60 void setCommand(Command cmd) { mCmd = cmd; }
61
62 /*
63 * Command modifiers. Not all modifiers are appropriate for all
64 * commands.
65 */
66 bool getVerbose(void) const { return mVerbose; }
67 void setVerbose(bool val) { mVerbose = val; }
68 bool getAndroidList(void) const { return mAndroidList; }
69 void setAndroidList(bool val) { mAndroidList = val; }
70 bool getForce(void) const { return mForce; }
71 void setForce(bool val) { mForce = val; }
72 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
73 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
74 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
75 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
76 bool getUpdate(void) const { return mUpdate; }
77 void setUpdate(bool val) { mUpdate = val; }
78 bool getExtending(void) const { return mExtending; }
79 void setExtending(bool val) { mExtending = val; }
80 bool getRequireLocalization(void) const { return mRequireLocalization; }
81 void setRequireLocalization(bool val) { mRequireLocalization = val; }
82 bool getPseudolocalize(void) const { return mPseudolocalize; }
83 void setPseudolocalize(bool val) { mPseudolocalize = val; }
5af43148
KR
84 bool getWantUTF16(void) const { return mWantUTF16; }
85 void setWantUTF16(bool val) { mWantUTF16 = val; }
7751daa4
DH
86 bool getValues(void) const { return mValues; }
87 void setValues(bool val) { mValues = val; }
a534180c
TAOSP
88 int getCompressionMethod(void) const { return mCompressionMethod; }
89 void setCompressionMethod(int val) { mCompressionMethod = val; }
1e8883fc
DZ
90 bool getJunkPath(void) const { return mJunkPath; }
91 void setJunkPath(bool val) { mJunkPath = val; }
a534180c
TAOSP
92 const char* getOutputAPKFile() const { return mOutputAPKFile; }
93 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
094e8965
JH
94 const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride; }
95 void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; }
af945cf3
DH
96 const char* getInstrumentationPackageNameOverride() const { return mInstrumentationPackageNameOverride; }
97 void setInstrumentationPackageNameOverride(const char * val) { mInstrumentationPackageNameOverride = val; }
636d3b70
XD
98 bool getAutoAddOverlay() { return mAutoAddOverlay; }
99 void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }
52ffc169
JG
100 bool getGenDependencies() { return mGenDependencies; }
101 void setGenDependencies(bool val) { mGenDependencies = val; }
a534180c 102
1e8883fc
DZ
103 /*
104 * Input options.
a534180c
TAOSP
105 */
106 const char* getAssetSourceDir() const { return mAssetSourceDir; }
107 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
dddb1fc7
JG
108 const char* getCrunchedOutputDir() const { return mCrunchedOutputDir; }
109 void setCrunchedOutputDir(const char* dir) { mCrunchedOutputDir = dir; }
6648ff78
JO
110 const char* getProguardFile() const { return mProguardFile; }
111 void setProguardFile(const char* file) { mProguardFile = file; }
a534180c
TAOSP
112 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
113 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
114 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
115 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
116 const char* getPublicOutputFile() const { return mPublicOutputFile; }
117 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
118 const char* getRClassDir() const { return mRClassDir; }
119 void setRClassDir(const char* dir) { mRClassDir = dir; }
120 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
121 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
e29f4ada
DH
122 const char* getPreferredConfigurations() const { return mPreferredConfigurations.size() > 0 ? mPreferredConfigurations.string() : NULL; }
123 void addPreferredConfigurations(const char* val) { if (mPreferredConfigurations.size() > 0) { mPreferredConfigurations.append(","); mPreferredConfigurations.append(val); } else { mPreferredConfigurations = val; } }
a534180c
TAOSP
124 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
125 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
126 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
127 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
128 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
129 void addJarFile(const char* file) { mJarFiles.add(file); }
130 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
131 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
132
5af43148
KR
133 const char* getManifestMinSdkVersion() const { return mManifestMinSdkVersion; }
134 void setManifestMinSdkVersion(const char* val) { mManifestMinSdkVersion = val; }
7e486e33 135 const char* getMinSdkVersion() const { return mMinSdkVersion; }
5af43148 136 void setMinSdkVersion(const char* val) { mMinSdkVersion = val; }
7e486e33
DH
137 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
138 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
139 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
140 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
141 const char* getVersionCode() const { return mVersionCode; }
142 void setVersionCode(const char* val) { mVersionCode = val; }
143 const char* getVersionName() const { return mVersionName; }
144 void setVersionName(const char* val) { mVersionName = val; }
fa19db5e
XD
145 const char* getCustomPackage() const { return mCustomPackage; }
146 void setCustomPackage(const char* val) { mCustomPackage = val; }
bc7b4f40
JG
147 const char* getExtraPackages() const { return mExtraPackages; }
148 void setExtraPackages(const char* val) { mExtraPackages = val; }
73412e58
FK
149 const char* getMaxResVersion() const { return mMaxResVersion; }
150 void setMaxResVersion(const char * val) { mMaxResVersion = val; }
f04c74b7
XD
151 bool getDebugMode() { return mDebugMode; }
152 void setDebugMode(bool val) { mDebugMode = val; }
54f200b0
XD
153 bool getNonConstantId() { return mNonConstantId; }
154 void setNonConstantId(bool val) { mNonConstantId = val; }
b8ea3a3f
EF
155 const char* getProduct() const { return mProduct; }
156 void setProduct(const char * val) { mProduct = val; }
dddb1fc7
JG
157 void setUseCrunchCache(bool val) { mUseCrunchCache = val; }
158 bool getUseCrunchCache() { return mUseCrunchCache; }
1e8883fc 159
a534180c
TAOSP
160 /*
161 * Set and get the file specification.
162 *
163 * Note this does NOT make a copy of argv.
164 */
165 void setFileSpec(char* const argv[], int argc) {
166 mArgc = argc;
167 mArgv = argv;
168 }
169 int getFileSpecCount(void) const { return mArgc; }
170 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
171 void eatArgs(int n) {
172 if (n > mArgc) n = mArgc;
173 mArgv += n;
174 mArgc -= n;
175 }
176
177#if 0
178 /*
179 * Package count. Nothing to do with anything else here; this is
180 * just a convenient place to stuff it so we don't have to pass it
181 * around everywhere.
182 */
183 int getPackageCount(void) const { return mPackageCount; }
184 void setPackageCount(int val) { mPackageCount = val; }
185#endif
186
1bad9d29
KR
187 /* Certain features may only be available on a specific SDK level or
188 * above. SDK levels that have a non-numeric identifier are assumed
189 * to be newer than any SDK level that has a number designated.
5af43148 190 */
1bad9d29 191 bool isMinSdkAtLeast(int desired) {
5af43148
KR
192 /* If the application specifies a minSdkVersion in the manifest
193 * then use that. Otherwise, check what the user specified on
194 * the command line. If neither, it's not available since
195 * the minimum SDK version is assumed to be 1.
196 */
197 const char *minVer;
198 if (mManifestMinSdkVersion != NULL) {
199 minVer = mManifestMinSdkVersion;
200 } else if (mMinSdkVersion != NULL) {
201 minVer = mMinSdkVersion;
202 } else {
203 return false;
204 }
205
206 char *end;
207 int minSdkNum = (int)strtol(minVer, &end, 0);
208 if (*end == '\0') {
1bad9d29 209 if (minSdkNum < desired) {
5af43148
KR
210 return false;
211 }
212 }
213 return true;
214 }
215
a534180c
TAOSP
216private:
217 /* commands & modifiers */
218 Command mCmd;
219 bool mVerbose;
220 bool mAndroidList;
221 bool mForce;
222 int mGrayscaleTolerance;
223 bool mMakePackageDirs;
224 bool mUpdate;
225 bool mExtending;
226 bool mRequireLocalization;
227 bool mPseudolocalize;
5af43148 228 bool mWantUTF16;
7751daa4 229 bool mValues;
a534180c 230 int mCompressionMethod;
1e8883fc 231 bool mJunkPath;
a534180c 232 const char* mOutputAPKFile;
094e8965 233 const char* mManifestPackageNameOverride;
af945cf3 234 const char* mInstrumentationPackageNameOverride;
636d3b70 235 bool mAutoAddOverlay;
52ffc169 236 bool mGenDependencies;
a534180c 237 const char* mAssetSourceDir;
dddb1fc7 238 const char* mCrunchedOutputDir;
6648ff78 239 const char* mProguardFile;
a534180c
TAOSP
240 const char* mAndroidManifestFile;
241 const char* mPublicOutputFile;
242 const char* mRClassDir;
243 const char* mResourceIntermediatesDir;
244 android::String8 mConfigurations;
e29f4ada 245 android::String8 mPreferredConfigurations;
a534180c
TAOSP
246 android::Vector<const char*> mPackageIncludes;
247 android::Vector<const char*> mJarFiles;
248 android::Vector<const char*> mNoCompressExtensions;
249 android::Vector<const char*> mResourceSourceDirs;
1e8883fc 250
5af43148 251 const char* mManifestMinSdkVersion;
7e486e33
DH
252 const char* mMinSdkVersion;
253 const char* mTargetSdkVersion;
254 const char* mMaxSdkVersion;
255 const char* mVersionCode;
256 const char* mVersionName;
fa19db5e 257 const char* mCustomPackage;
bc7b4f40 258 const char* mExtraPackages;
73412e58 259 const char* mMaxResVersion;
f04c74b7 260 bool mDebugMode;
54f200b0 261 bool mNonConstantId;
b8ea3a3f 262 const char* mProduct;
dddb1fc7 263 bool mUseCrunchCache;
1e8883fc 264
a534180c
TAOSP
265 /* file specification */
266 int mArgc;
267 char* const* mArgv;
268
269#if 0
270 /* misc stuff */
271 int mPackageCount;
272#endif
7dc0cd41 273
a534180c
TAOSP
274};
275
276#endif // __BUNDLE_H