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