]> git.saurik.com Git - android/aapt.git/blob - Bundle.h
add "junk path" -k option to aapt (DO NOT MERGE)
[android/aapt.git] / Bundle.h
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>
10 #include <utils/Log.h>
11 #include <utils/threads.h>
12 #include <utils/List.h>
13 #include <utils/Errors.h>
14 #include <utils/String8.h>
15 #include <utils/Vector.h>
16
17 /*
18 * Things we can do.
19 */
20 typedef enum Command {
21 kCommandUnknown = 0,
22 kCommandVersion,
23 kCommandList,
24 kCommandDump,
25 kCommandAdd,
26 kCommandRemove,
27 kCommandPackage,
28 } Command;
29
30 /*
31 * Bundle of goodies, including everything specified on the command line.
32 */
33 class Bundle {
34 public:
35 Bundle(void)
36 : mCmd(kCommandUnknown), mVerbose(false), mAndroidList(false),
37 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
38 mUpdate(false), mExtending(false),
39 mRequireLocalization(false), mPseudolocalize(false),
40 mValues(false),
41 mCompressionMethod(0), mOutputAPKFile(NULL),
42 mAssetSourceDir(NULL), mProguardFile(NULL),
43 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
44 mRClassDir(NULL), mResourceIntermediatesDir(NULL),
45 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
46 mVersionCode(NULL), mVersionName(NULL),
47 mArgc(0), mArgv(NULL)
48 {}
49 ~Bundle(void) {}
50
51 /*
52 * Set the command value. Returns "false" if it was previously set.
53 */
54 Command getCommand(void) const { return mCmd; }
55 void setCommand(Command cmd) { mCmd = cmd; }
56
57 /*
58 * Command modifiers. Not all modifiers are appropriate for all
59 * commands.
60 */
61 bool getVerbose(void) const { return mVerbose; }
62 void setVerbose(bool val) { mVerbose = val; }
63 bool getAndroidList(void) const { return mAndroidList; }
64 void setAndroidList(bool val) { mAndroidList = val; }
65 bool getForce(void) const { return mForce; }
66 void setForce(bool val) { mForce = val; }
67 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
68 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
69 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
70 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
71 bool getUpdate(void) const { return mUpdate; }
72 void setUpdate(bool val) { mUpdate = val; }
73 bool getExtending(void) const { return mExtending; }
74 void setExtending(bool val) { mExtending = val; }
75 bool getRequireLocalization(void) const { return mRequireLocalization; }
76 void setRequireLocalization(bool val) { mRequireLocalization = val; }
77 bool getPseudolocalize(void) const { return mPseudolocalize; }
78 void setPseudolocalize(bool val) { mPseudolocalize = val; }
79 bool getValues(void) const { return mValues; }
80 void setValues(bool val) { mValues = val; }
81 int getCompressionMethod(void) const { return mCompressionMethod; }
82 void setCompressionMethod(int val) { mCompressionMethod = val; }
83 bool getJunkPath(void) const { return mJunkPath; }
84 void setJunkPath(bool val) { mJunkPath = val; }
85 const char* getOutputAPKFile() const { return mOutputAPKFile; }
86 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
87
88 /*
89 * Input options.
90 */
91 const char* getAssetSourceDir() const { return mAssetSourceDir; }
92 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
93 const char* getProguardFile() const { return mProguardFile; }
94 void setProguardFile(const char* file) { mProguardFile = file; }
95 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
96 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
97 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
98 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
99 const char* getPublicOutputFile() const { return mPublicOutputFile; }
100 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
101 const char* getRClassDir() const { return mRClassDir; }
102 void setRClassDir(const char* dir) { mRClassDir = dir; }
103 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
104 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
105 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
106 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
107 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
108 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
109 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
110 void addJarFile(const char* file) { mJarFiles.add(file); }
111 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
112 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
113
114 const char* getMinSdkVersion() const { return mMinSdkVersion; }
115 void setMinSdkVersion(const char* val) { mMinSdkVersion = val; }
116 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
117 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
118 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
119 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
120 const char* getVersionCode() const { return mVersionCode; }
121 void setVersionCode(const char* val) { mVersionCode = val; }
122 const char* getVersionName() const { return mVersionName; }
123 void setVersionName(const char* val) { mVersionName = val; }
124
125 /*
126 * Set and get the file specification.
127 *
128 * Note this does NOT make a copy of argv.
129 */
130 void setFileSpec(char* const argv[], int argc) {
131 mArgc = argc;
132 mArgv = argv;
133 }
134 int getFileSpecCount(void) const { return mArgc; }
135 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
136 void eatArgs(int n) {
137 if (n > mArgc) n = mArgc;
138 mArgv += n;
139 mArgc -= n;
140 }
141
142 #if 0
143 /*
144 * Package count. Nothing to do with anything else here; this is
145 * just a convenient place to stuff it so we don't have to pass it
146 * around everywhere.
147 */
148 int getPackageCount(void) const { return mPackageCount; }
149 void setPackageCount(int val) { mPackageCount = val; }
150 #endif
151
152 private:
153 /* commands & modifiers */
154 Command mCmd;
155 bool mVerbose;
156 bool mAndroidList;
157 bool mForce;
158 int mGrayscaleTolerance;
159 bool mMakePackageDirs;
160 bool mUpdate;
161 bool mExtending;
162 bool mRequireLocalization;
163 bool mPseudolocalize;
164 bool mValues;
165 int mCompressionMethod;
166 bool mJunkPath;
167 const char* mOutputAPKFile;
168 const char* mAssetSourceDir;
169 const char* mProguardFile;
170 const char* mAndroidManifestFile;
171 const char* mPublicOutputFile;
172 const char* mRClassDir;
173 const char* mResourceIntermediatesDir;
174 android::String8 mConfigurations;
175 android::Vector<const char*> mPackageIncludes;
176 android::Vector<const char*> mJarFiles;
177 android::Vector<const char*> mNoCompressExtensions;
178 android::Vector<const char*> mResourceSourceDirs;
179
180 const char* mMinSdkVersion;
181 const char* mTargetSdkVersion;
182 const char* mMaxSdkVersion;
183 const char* mVersionCode;
184 const char* mVersionName;
185
186 /* file specification */
187 int mArgc;
188 char* const* mArgv;
189
190 #if 0
191 /* misc stuff */
192 int mPackageCount;
193 #endif
194 };
195
196 #endif // __BUNDLE_H