]> git.saurik.com Git - android/aapt.git/blame - Bundle.h
Merge "Add --auto-add-overlay option to aapt."
[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,
28} Command;
29
30/*
31 * Bundle of goodies, including everything specified on the command line.
32 */
33class Bundle {
34public:
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),
28de9b93 40 mUTF8(false), mEncodingSpecified(false), mValues(false),
094e8965 41 mCompressionMethod(0), mOutputAPKFile(NULL), mManifestPackageNameOverride(NULL),
636d3b70 42 mAutoAddOverlay(false), mAssetSourceDir(NULL), mProguardFile(NULL),
a534180c
TAOSP
43 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
44 mRClassDir(NULL), mResourceIntermediatesDir(NULL),
53288885 45 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
fa19db5e 46 mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL),
a534180c
TAOSP
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; }
15c62a5b
KR
79 bool getUTF8(void) const { return mUTF8; }
80 void setUTF8(bool val) { mUTF8 = val; }
28de9b93
KR
81 bool getEncodingSpecified(void) const { return mEncodingSpecified; }
82 void setEncodingSpecified(bool val) { mEncodingSpecified = val; }
7751daa4
DH
83 bool getValues(void) const { return mValues; }
84 void setValues(bool val) { mValues = val; }
a534180c
TAOSP
85 int getCompressionMethod(void) const { return mCompressionMethod; }
86 void setCompressionMethod(int val) { mCompressionMethod = val; }
1e8883fc
DZ
87 bool getJunkPath(void) const { return mJunkPath; }
88 void setJunkPath(bool val) { mJunkPath = val; }
a534180c
TAOSP
89 const char* getOutputAPKFile() const { return mOutputAPKFile; }
90 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
094e8965
JH
91 const char* getManifestPackageNameOverride() const { return mManifestPackageNameOverride; }
92 void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; }
636d3b70
XD
93 bool getAutoAddOverlay() { return mAutoAddOverlay; }
94 void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; }
a534180c 95
1e8883fc
DZ
96 /*
97 * Input options.
a534180c
TAOSP
98 */
99 const char* getAssetSourceDir() const { return mAssetSourceDir; }
100 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
6648ff78
JO
101 const char* getProguardFile() const { return mProguardFile; }
102 void setProguardFile(const char* file) { mProguardFile = file; }
a534180c
TAOSP
103 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
104 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
105 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
106 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
107 const char* getPublicOutputFile() const { return mPublicOutputFile; }
108 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
109 const char* getRClassDir() const { return mRClassDir; }
110 void setRClassDir(const char* dir) { mRClassDir = dir; }
111 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
112 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
113 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
114 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
115 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
116 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
117 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
118 void addJarFile(const char* file) { mJarFiles.add(file); }
119 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
120 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
121
7e486e33 122 const char* getMinSdkVersion() const { return mMinSdkVersion; }
7dc0cd41
KR
123 void setMinSdkVersion(const char* val) {
124 mMinSdkVersion = val;
28de9b93
KR
125 if (!mEncodingSpecified) {
126 setUTF8(isUTF8Available());
127 }
7dc0cd41 128 }
7e486e33
DH
129 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
130 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
131 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
132 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
133 const char* getVersionCode() const { return mVersionCode; }
134 void setVersionCode(const char* val) { mVersionCode = val; }
135 const char* getVersionName() const { return mVersionName; }
136 void setVersionName(const char* val) { mVersionName = val; }
fa19db5e
XD
137 const char* getCustomPackage() const { return mCustomPackage; }
138 void setCustomPackage(const char* val) { mCustomPackage = val; }
1e8883fc 139
a534180c
TAOSP
140 /*
141 * Set and get the file specification.
142 *
143 * Note this does NOT make a copy of argv.
144 */
145 void setFileSpec(char* const argv[], int argc) {
146 mArgc = argc;
147 mArgv = argv;
148 }
149 int getFileSpecCount(void) const { return mArgc; }
150 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
151 void eatArgs(int n) {
152 if (n > mArgc) n = mArgc;
153 mArgv += n;
154 mArgc -= n;
155 }
156
157#if 0
158 /*
159 * Package count. Nothing to do with anything else here; this is
160 * just a convenient place to stuff it so we don't have to pass it
161 * around everywhere.
162 */
163 int getPackageCount(void) const { return mPackageCount; }
164 void setPackageCount(int val) { mPackageCount = val; }
165#endif
166
167private:
168 /* commands & modifiers */
169 Command mCmd;
170 bool mVerbose;
171 bool mAndroidList;
172 bool mForce;
173 int mGrayscaleTolerance;
174 bool mMakePackageDirs;
175 bool mUpdate;
176 bool mExtending;
177 bool mRequireLocalization;
178 bool mPseudolocalize;
15c62a5b 179 bool mUTF8;
28de9b93 180 bool mEncodingSpecified;
7751daa4 181 bool mValues;
a534180c 182 int mCompressionMethod;
1e8883fc 183 bool mJunkPath;
a534180c 184 const char* mOutputAPKFile;
094e8965 185 const char* mManifestPackageNameOverride;
636d3b70 186 bool mAutoAddOverlay;
a534180c 187 const char* mAssetSourceDir;
6648ff78 188 const char* mProguardFile;
a534180c
TAOSP
189 const char* mAndroidManifestFile;
190 const char* mPublicOutputFile;
191 const char* mRClassDir;
192 const char* mResourceIntermediatesDir;
193 android::String8 mConfigurations;
194 android::Vector<const char*> mPackageIncludes;
195 android::Vector<const char*> mJarFiles;
196 android::Vector<const char*> mNoCompressExtensions;
197 android::Vector<const char*> mResourceSourceDirs;
1e8883fc 198
7e486e33
DH
199 const char* mMinSdkVersion;
200 const char* mTargetSdkVersion;
201 const char* mMaxSdkVersion;
202 const char* mVersionCode;
203 const char* mVersionName;
fa19db5e 204 const char* mCustomPackage;
1e8883fc 205
a534180c
TAOSP
206 /* file specification */
207 int mArgc;
208 char* const* mArgv;
209
210#if 0
211 /* misc stuff */
212 int mPackageCount;
213#endif
7dc0cd41
KR
214
215 /* UTF-8 is only available on APIs 7 or above or
216 * SDK levels that have code names.
217 */
218 bool isUTF8Available() {
219 char *end;
220 int minSdkNum = (int)strtol(mMinSdkVersion, &end, 0);
221 if (*end == '\0') {
222 if (minSdkNum < 7) {
223 return false;
224 }
225 }
226 return true;
227 }
a534180c
TAOSP
228};
229
230#endif // __BUNDLE_H