author | jascui |
Mon, 29 Nov 2010 15:46:44 +0800 | |
changeset 711 | 03a6f48f6e14 |
parent 708 | 0757c2976f96 |
child 714 | e5a58c351011 |
permissions | -rw-r--r-- |
606 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
#include <string.h> |
|
18 |
#include <stdlib.h> |
|
19 |
#include <f32file.h> |
|
20 |
#include "e32image.h" |
|
21 |
#include "h_utl.h" |
|
22 |
#include "h_ver.h" |
|
23 |
#include "r_obey.h" |
|
24 |
#include "r_driveimage.h" |
|
25 |
#include "r_driveutl.h" |
|
26 |
#include "r_coreimage.h" |
|
27 |
#include "parameterfileprocessor.h" |
|
28 |
#include "r_smrimage.h" |
|
29 |
//cache headers |
|
30 |
#include "cache/cacheexception.hpp" |
|
31 |
#include "cache/cacheentry.hpp" |
|
32 |
#include "cache/cache.hpp" |
|
33 |
#include "cache/cachegenerator.hpp" |
|
34 |
#include "cache/cachevalidator.hpp" |
|
35 |
#include "cache/cacheablelist.hpp" |
|
36 |
#include "cache/cachemanager.hpp" |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
37 |
#include "logparser.h" |
606 | 38 |
#include <malloc.h> |
39 |
||
40 |
#ifndef WIN32 |
|
41 |
#include <unistd.h> |
|
42 |
#include <strings.h> |
|
43 |
#include <fstream> |
|
44 |
#define strnicmp strncasecmp |
|
45 |
#define stricmp strcasecmp |
|
46 |
#define _alloca alloca |
|
47 |
#endif |
|
48 |
||
49 |
static const TInt RofsbuildMajorVersion=2; |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
50 |
static const TInt RofsbuildMinorVersion=17; |
708 | 51 |
static const TInt RofsbuildPatchVersion=3; |
606 | 52 |
static TBool SizeSummary=EFalse; |
53 |
static TPrintType SizeWhere=EAlways; |
|
54 |
||
55 |
static TInt gHeaderType=1; // EPOC header |
|
56 |
static TInt MAXIMUM_THREADS = 128; |
|
57 |
static TInt DEFAULT_THREADS = 8; |
|
58 |
ECompression gCompress=ECompressionUnknown; |
|
59 |
TUint gCompressionMethod=0; |
|
60 |
TInt gThreadNum = 0; |
|
61 |
TInt gCPUNum = 0; |
|
62 |
TBool gGenSymbols = EFalse; |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
63 |
TBool gGenBsymbols = EFalse; |
606 | 64 |
TInt gCodePagingOverride = -1; |
65 |
TInt gDataPagingOverride = -1; |
|
66 |
TInt gLogLevel = 0; // Information is logged based on logging level. |
|
67 |
// The default is 0. So all the existing logs are generated as if gLogLevel = 0. |
|
68 |
// If any extra information required, the log level must be appropriately supplied. |
|
69 |
// Currrently, file details in ROM (like, file name in ROM & host, file size, whether |
|
70 |
// the file is hidden etc) are logged when gLogLevel >= LOG_LEVEL_FILE_DETAILS. |
|
71 |
||
72 |
TBool gUseCoreImage = EFalse; // command line option for using core image file |
|
73 |
string gImageFilename = ""; // instead of obey file |
|
74 |
TBool gEnableStdPathWarning = EFalse;// for in-correct destination path warning(executables). |
|
75 |
TBool gLowMem = EFalse; |
|
76 |
extern TBool gDriveImage; // to Support data drive image. |
|
77 |
string gDriveFilename = ""; // input drive oby filename. |
|
78 |
string filename; // to store oby filename passed to Rofsbuild. |
|
79 |
TBool reallyHelp = EFalse; |
|
80 |
TBool gSmrImage = EFalse; |
|
81 |
string gSmrFileName = ""; |
|
647 | 82 |
static string cmdlogfile = ""; |
654 | 83 |
static string loginput = ""; |
606 | 84 |
|
85 |
//Cache global variables |
|
86 |
bool gCache = false; |
|
87 |
bool gCleanCache = false; |
|
88 |
bool gNoCache = false; |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
89 |
TBool gIsOBYUTF8 = EFalse; |
606 | 90 |
TBool gKeepGoing = EFalse; |
91 |
void PrintVersion() { |
|
631 | 92 |
printf("\nROFSBUILD - Rofs/Datadrive image builder"); |
93 |
printf(" V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion); |
|
94 |
printf("%s\n\n", "Copyright (c) 1996-2010 Nokia Corporation."); |
|
606 | 95 |
} |
96 |
||
97 |
char HelpText[] = |
|
98 |
"Syntax: ROFSBUILD [options] obeyfilename(Rofs)\n" |
|
99 |
"Option: -v verbose, -?, -s[log|screen|both] size summary\n" |
|
100 |
" -d<bitmask> set trace mask (DEB build only)\n" |
|
101 |
" -compress compress executable files where possible\n" |
|
102 |
" -j<digit> do the main job with <digit> threads\n" |
|
103 |
" -symbols generate symbol file\n" |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
104 |
" -bsymbols generate binary symbol file\n" |
606 | 105 |
" -compressionmethod none|inflate|bytepair to set the compression\n" |
106 |
" none uncompress the image.\n" |
|
107 |
" inflate compress the image.\n" |
|
108 |
" bytepair compress the image.\n" |
|
109 |
" -coreimage <core image file>\n" |
|
110 |
" -cache allow the ROFSBUILD to reuse/generate cached executable files\n" |
|
111 |
" -nocache force the ROFSBUILD not to reuse/generate cached executable files\n" |
|
112 |
" -cleancache permanently remove all cached executable files\n" |
|
113 |
" -datadrive=<drive obyfile1>,<drive obyfile2>,... for driveimage creation\n" |
|
114 |
" user can also input rofs oby file if required to generate both.\n" |
|
115 |
" -smr=<SMR obyfile1>,<SMR obyfile2>,... for SMR partition creation\n" |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
116 |
" -oby-charset=<charset> used character set in which OBY was written\n" |
606 | 117 |
" -loglevel<level> level of information to log (valid levels are 0,1,2).\n"//Tools like Visual ROM builder need the host/ROM filenames, size & if the file is hidden. |
118 |
" -wstdpath warn if destination path provided for a file is not the standard path\n" |
|
119 |
" -argfile=<FileName> specify argument-file name containing list of command-line arguments\n" |
|
120 |
" -lowmem use memory-mapped file for image build to reduce physical memory consumption\n" |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
121 |
" -k to enable keepgoing when duplicate files exist in oby\n" |
654 | 122 |
" -logfile=<fileName> specify log file\n" |
123 |
" -loginput=<log filename> specify as input a log file and produce as output symbol file.\n"; |
|
606 | 124 |
|
125 |
char ReallyHelpText[] = |
|
126 |
"Log Level:\n" |
|
127 |
" 0 produce the default logs\n" |
|
128 |
" 1 produce file detail logs in addition to the default logs\n" |
|
129 |
" 2 logs e32 header attributes in addition to the level 1 details\n"; |
|
130 |
void processParamfile(const string& aFileName); |
|
131 |
/** |
|
132 |
Process the command line arguments and prints the helpful message if none are supplied. |
|
133 |
@param argc - No. of argument. |
|
134 |
@param *argv[] - Arguments value. |
|
135 |
*/ |
|
136 |
void processCommandLine(int argc, char *argv[], TBool paramFileFlag = EFalse) { |
|
137 |
// If "-argfile" option is passed to rofsbuild, then process the parameters |
|
138 |
// specified in parameter-file first and then the options passed from the command-line. |
|
139 |
||
140 |
string ParamFileArg("-ARGFILE="); |
|
141 |
if(paramFileFlag == EFalse) { |
|
142 |
for (int count = 1; count<argc; count++) { |
|
143 |
string paramFile; |
|
144 |
//strupr(argv[count]); |
|
145 |
if(strnicmp(argv[count],ParamFileArg.c_str(),ParamFileArg.length()) == 0) { |
|
146 |
paramFile.assign(&argv[count][ParamFileArg.length()]); |
|
147 |
processParamfile(paramFile); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
||
152 |
int i = 1; |
|
153 |
while (i<argc) { |
|
154 |
#ifdef __LINUX__ |
|
155 |
if (argv[i][0] == '-') |
|
156 |
#else |
|
157 |
if ((argv[i][0] == '-') || (argv[i][0] == '/')) |
|
158 |
#endif |
|
159 |
{ |
|
160 |
// switch |
|
161 |
if ((argv[i][1] & 0x20) == 'v') |
|
162 |
H.iVerbose = ETrue; |
|
163 |
else if(strnicmp (argv[i], "-SMR=", 5) == 0) { |
|
164 |
if(argv[i][5]) { |
|
165 |
gSmrImage = ETrue; |
|
166 |
gSmrFileName.assign(&argv[i][5]); |
|
167 |
} |
|
168 |
else { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
169 |
printf ("ERROR: SMR obey file is missing\n"); |
606 | 170 |
} |
171 |
} else if (stricmp(argv[i], "-K") == 0) { |
|
172 |
gKeepGoing = ETrue; |
|
173 |
}else if (stricmp(argv[i], "-SYMBOLS") == 0) { |
|
174 |
gGenSymbols = ETrue; |
|
175 |
} |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
176 |
else if (stricmp(argv[i], "-BSYMBOLS") == 0 ) { |
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
177 |
gGenBsymbols = ETrue; |
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
178 |
} |
606 | 179 |
else if (((argv[i][1] | 0x20) == 's') && |
180 |
(((argv[i][2]| 0x20) == 'l')||((argv[i][2] | 0x20) == 's'))) { |
|
181 |
SizeSummary = ETrue; |
|
182 |
if ((argv[i][2]| 0x20) == 'l') |
|
183 |
SizeWhere = ELog; |
|
184 |
else |
|
185 |
SizeWhere = EScreen; |
|
186 |
} |
|
187 |
else if (strnicmp(argv[i],ParamFileArg.c_str(),ParamFileArg.length()) == 0) { |
|
188 |
if (paramFileFlag){ |
|
189 |
string paramFile; |
|
190 |
paramFile.assign(&argv[i][ParamFileArg.length()]); |
|
191 |
processParamfile(paramFile); |
|
192 |
} |
|
193 |
else { |
|
194 |
i++; |
|
195 |
continue; |
|
196 |
} |
|
197 |
} |
|
198 |
else if (stricmp(argv[i], "-COMPRESS") == 0) { |
|
199 |
gCompress = ECompressionCompress; |
|
200 |
gCompressionMethod = KUidCompressionDeflate; |
|
201 |
} |
|
202 |
else if(stricmp(argv[i], "-CACHE") == 0) { |
|
203 |
gCache = true; |
|
204 |
if(gCleanCache || gNoCache) { |
|
205 |
printf("Cache command line options are mutually exclusive, only one option can be used at a time\n"); |
|
206 |
exit(1); |
|
207 |
} |
|
208 |
} |
|
209 |
else if(stricmp(argv[i], "-NOCACHE") == 0) { |
|
210 |
gNoCache = true; |
|
211 |
if(gCleanCache || gCache) { |
|
212 |
printf("Cache command line options are mutually exclusive, only one option can be used at a time\n"); |
|
213 |
exit(1); |
|
214 |
} |
|
215 |
} |
|
216 |
else if(stricmp(argv[i], "-CLEANCACHE") == 0) { |
|
217 |
gCleanCache = true; |
|
218 |
if(gCache || gNoCache) |
|
219 |
{ |
|
220 |
printf("Cache command line options are mutually exclusive, only one option can be used at a time\n"); |
|
221 |
exit(1); |
|
222 |
} |
|
223 |
} |
|
224 |
else if (strnicmp(argv[i], "-J",2) == 0) { |
|
225 |
if(argv[i][2]) |
|
226 |
gThreadNum = atoi(&argv[i][2]); |
|
227 |
else { |
|
228 |
printf("WARNING: The option should be like '-j4'.\n"); |
|
229 |
gThreadNum = 0; |
|
230 |
} |
|
231 |
if(gThreadNum <= 0 || gThreadNum > MAXIMUM_THREADS) { |
|
232 |
printf("WARNING: The number of concurrent jobs set by -j should be between 1 and 128. "); |
|
233 |
if(gCPUNum > 0) { |
|
234 |
printf("WARNING: The number of processors %d is used as the number of concurrent jobs.\n", gCPUNum); |
|
235 |
gThreadNum = gCPUNum; |
|
236 |
} |
|
237 |
else { |
|
238 |
printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS); |
|
239 |
gThreadNum = DEFAULT_THREADS; |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
243 |
else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0) |
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
244 |
{ |
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
245 |
if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0)) |
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
246 |
gIsOBYUTF8 = ETrue; |
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
247 |
else |
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
248 |
printf("ERROR: Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]); |
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
249 |
} |
606 | 250 |
else if (stricmp(argv[i], "-UNCOMPRESS") == 0) { |
251 |
gCompress = ECompressionUncompress; |
|
252 |
} |
|
253 |
else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) { |
|
254 |
// next argument should a be method |
|
255 |
if( (i+1) >= argc || argv[i+1][0] == '-') { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
256 |
printf("ERROR: Missing compression method! Set it to default (no compression)!"); |
606 | 257 |
gCompressionMethod = 0; |
258 |
} |
|
259 |
else { |
|
260 |
i++; |
|
261 |
if( stricmp(argv[i], "NONE") == 0) { |
|
262 |
gCompress = ECompressionUncompress; |
|
263 |
gCompressionMethod = 0; |
|
264 |
} |
|
265 |
else if( stricmp(argv[i], "INFLATE") == 0) { |
|
266 |
gCompress = ECompressionCompress; |
|
267 |
gCompressionMethod = KUidCompressionDeflate; |
|
268 |
} |
|
269 |
else if( stricmp(argv[i], "BYTEPAIR") == 0) { |
|
270 |
gCompress = ECompressionCompress; |
|
271 |
gCompressionMethod = KUidCompressionBytePair; |
|
272 |
} |
|
273 |
else { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
274 |
printf("ERROR: Unknown compression method! Set it to default (no compression)!"); |
606 | 275 |
gCompress = ECompressionUnknown; |
276 |
gCompressionMethod = 0; |
|
277 |
} |
|
278 |
} |
|
279 |
||
280 |
} |
|
281 |
else if (stricmp(argv[i], "-COREIMAGE") == 0) { |
|
282 |
||
283 |
gUseCoreImage = ETrue; |
|
284 |
// next argument should be image filename |
|
285 |
if ((i+1 >= argc) || argv[i+1][0] == '-') |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
286 |
printf("ERROR: Missing image file name"); |
606 | 287 |
else { |
288 |
i++; |
|
289 |
gImageFilename.assign(argv[i]); |
|
290 |
} |
|
291 |
} |
|
292 |
else if (strnicmp(argv[i], "-DATADRIVE=",11) == 0){ |
|
293 |
if(argv[i][11]) { |
|
294 |
gDriveImage = ETrue; |
|
295 |
gDriveFilename.assign(&argv[i][11]); |
|
296 |
} |
|
297 |
else { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
298 |
printf("ERROR: Drive obey file is missing\n"); |
606 | 299 |
} |
300 |
} |
|
301 |
else if (argv[i][1] == '?') { |
|
302 |
reallyHelp = ETrue; |
|
303 |
} |
|
304 |
else if (stricmp(argv[i], "-WSTDPATH") == 0) { // Warn if destination path provided for a executables are incorrect as per platsec. |
|
305 |
gEnableStdPathWarning = ETrue; |
|
306 |
} |
|
307 |
else if( stricmp(argv[i], "-LOGLEVEL") == 0) { |
|
308 |
// next argument should a be loglevel |
|
309 |
if( (i+1) >= argc || argv[i+1][0] == '-') { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
310 |
printf ("ERROR: Missing loglevel!"); |
606 | 311 |
gLogLevel = DEFAULT_LOG_LEVEL; |
312 |
} |
|
313 |
else { |
|
314 |
i++; |
|
315 |
if (strcmp(argv[i], "2") == 0) |
|
316 |
gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES); |
|
317 |
if (strcmp(argv[i], "1") == 0) |
|
318 |
gLogLevel = LOG_LEVEL_FILE_DETAILS; |
|
319 |
else if (strcmp(argv[i], "0") == 0) |
|
320 |
gLogLevel = DEFAULT_LOG_LEVEL; |
|
321 |
else |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
322 |
printf("ERROR: Only loglevel 0, 1 or 2 is allowed!"); |
606 | 323 |
} |
324 |
} |
|
325 |
else if( stricmp(argv[i], "-LOGLEVEL2") == 0) |
|
326 |
gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES); |
|
327 |
else if( stricmp(argv[i], "-LOGLEVEL1") == 0) |
|
328 |
gLogLevel = LOG_LEVEL_FILE_DETAILS; |
|
329 |
else if( stricmp(argv[i], "-LOGLEVEL0") == 0) |
|
330 |
gLogLevel = DEFAULT_LOG_LEVEL; |
|
331 |
else if (stricmp(argv[i], "-LOWMEM") == 0) |
|
332 |
gLowMem = ETrue; |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
333 |
else if (strnicmp(argv[i], "-logfile=",9) ==0) { |
647 | 334 |
cmdlogfile = argv[i] + 9; |
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
617
diff
changeset
|
335 |
} |
654 | 336 |
else if (strnicmp(argv[i], "-loginput=", 10) == 0) { |
337 |
loginput = argv[i] + 10; |
|
338 |
} |
|
606 | 339 |
else { |
340 |
#ifdef WIN32 |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
341 |
printf ("WARNING: Unrecognised option %s\n",argv[i]); |
606 | 342 |
#else |
343 |
if(0 == access(argv[i],R_OK)){ |
|
344 |
filename.assign(argv[i]); |
|
345 |
} |
|
346 |
else { |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
347 |
printf("WARNING: Unrecognised option %s\n",argv[i]); |
606 | 348 |
} |
349 |
#endif |
|
350 |
||
351 |
} |
|
352 |
} |
|
353 |
else // Must be the obey filename |
|
354 |
filename.assign(argv[i]); |
|
355 |
i++; |
|
356 |
} |
|
357 |
||
358 |
if (paramFileFlag) |
|
359 |
return; |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
360 |
if(gGenSymbols && gGenBsymbols) |
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
361 |
{ |
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
362 |
printf("WARNING: Options symbols and bsymbols cannot be used at the same time, the common symbols file will be created this time!\n"); |
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
363 |
gGenBsymbols = EFalse; |
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
364 |
} |
606 | 365 |
|
366 |
if((gDriveImage == EFalse) && (gSmrImage == EFalse) && |
|
654 | 367 |
(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0)) && (loginput.length() == 0)){ |
606 | 368 |
Print (EAlways, HelpText); |
369 |
if (reallyHelp) { |
|
370 |
ObeyFileReader::KeywordHelp(); |
|
371 |
Print (EAlways, ReallyHelpText); |
|
372 |
} |
|
373 |
else if (filename.empty()){ |
|
698
e3ee96a3961c
fix ou1cimx1#651819 rofsbiuld fails to generate correct log info when using multi-thread
marvin shi <marvin.shi@nokia.com>
parents:
694
diff
changeset
|
374 |
printf("WARNING: Obey filename is missing\n"); |
606 | 375 |
} |
376 |
} |
|
377 |
} |
|
378 |
||
379 |
/** |
|
380 |
Function to process parameter-file. |
|
381 |
@param aFileName parameter-file name. |
|
382 |
*/ |
|
383 |
void processParamfile(const string& aFileName) { |
|
384 |
||
385 |
CParameterFileProcessor parameterFile(aFileName); |
|
386 |
// Invoke fuction "ParameterFileProcessor" to process parameter-file. |
|
387 |
if(parameterFile.ParameterFileProcessor()) { |
|
388 |
TUint noOfParameters = parameterFile.GetNoOfArguments(); |
|
389 |
char** parameters = parameterFile.GetParameters(); |
|
390 |
TBool paramFileFlag = ETrue; |
|
391 |
||
392 |
// Invoke function "processCommandLine" to process parameters read from parameter-file. |
|
393 |
processCommandLine(noOfParameters,parameters,paramFileFlag); |
|
394 |
} |
|
395 |
} |
|
396 |
||
397 |
/** |
|
398 |
Main logic for data drive image creation. Called many types depending on no. of drive obey files. |
|
399 |
||
400 |
@param aobeyFileName - Drive obey file. |
|
401 |
@param alogfile - log file name required for file system module. |
|
402 |
||
403 |
@return - returns the status, after processing the drive obey file. |
|
404 |
*/ |
|
647 | 405 |
TInt ProcessDataDriveMain(char* aobeyFileName, const char* alogfile) { |
606 | 406 |
|
407 |
ObeyFileReader *reader = new ObeyFileReader(aobeyFileName); |
|
408 |
||
409 |
if(!reader) |
|
410 |
return KErrNoMemory; |
|
411 |
||
412 |
if(!reader->Open()) |
|
413 |
return KErrGeneral; |
|
414 |
||
415 |
CObeyFile* mainObeyFile = new CObeyFile(*reader); |
|
416 |
||
417 |
if(!mainObeyFile) |
|
418 |
return KErrNoMemory; |
|
419 |
||
420 |
// Process data drive image. |
|
421 |
// let's clear the TRomNode::sDefaultInitialAttr first, 'cause data drive is different from rom image |
|
422 |
TRomNode::sDefaultInitialAttr = 0; |
|
423 |
TInt retstatus = mainObeyFile->ProcessDataDrive(); |
|
424 |
if (retstatus == KErrNone) { |
|
425 |
// Build a Data drive image using the description compiled into the CObeyFile object |
|
426 |
CDriveImage* userImage = new CDriveImage(mainObeyFile); |
|
427 |
if(userImage) { |
|
428 |
// Drive image creation. |
|
429 |
retstatus = userImage->CreateImage(alogfile); |
|
430 |
if(retstatus == KErrNone) { |
|
431 |
Print (EAlways, "\nSuccessfully generated the Drive image : %s \n",mainObeyFile->iDriveFileName); |
|
432 |
} |
|
433 |
else { |
|
434 |
Print (EError, "Failed to generate the Image : %s\n",mainObeyFile->iDriveFileName); |
|
435 |
} |
|
436 |
delete userImage; |
|
437 |
} |
|
438 |
else { |
|
439 |
retstatus = KErrNoMemory; |
|
440 |
} |
|
441 |
} |
|
442 |
// restore |
|
443 |
TRomNode::sDefaultInitialAttr = (TUint8)KEntryAttReadOnly; |
|
444 |
cout << "\n-----------------------------------------------------------\n"; |
|
445 |
||
446 |
delete mainObeyFile; |
|
447 |
delete reader; |
|
448 |
return retstatus; |
|
449 |
} |
|
450 |
||
647 | 451 |
TInt ProcessSmrImageMain(char* aObeyFileName, const char* /* alogfile */) { |
606 | 452 |
ObeyFileReader *reader = new ObeyFileReader(aObeyFileName); |
453 |
if(!reader) |
|
454 |
return KErrNoMemory; |
|
455 |
if(!reader->Open()) |
|
456 |
return KErrGeneral; |
|
457 |
TInt retstatus = 0; |
|
458 |
CObeyFile* mainObeyFile = new CObeyFile(*reader); |
|
459 |
CSmrImage* smrImage = 0; |
|
460 |
if(!mainObeyFile) |
|
461 |
return KErrNoMemory; |
|
462 |
if(mainObeyFile->Process()) { |
|
463 |
smrImage = new CSmrImage(mainObeyFile); |
|
464 |
if(smrImage) { |
|
465 |
if((retstatus = smrImage->Initialise()) == KErrNone) { |
|
466 |
retstatus = smrImage->CreateImage(); |
|
467 |
} |
|
468 |
if(retstatus == KErrNone) { |
|
469 |
Print (EAlways, "\nSuccessfully generated the SMR image : %s\n" ,smrImage->GetImageName().c_str()); |
|
470 |
} |
|
471 |
else { |
|
472 |
Print (EError, "\nFailed to generate the Image : %s\n" ,smrImage->GetImageName().c_str()); |
|
473 |
} |
|
474 |
delete smrImage; |
|
475 |
} |
|
476 |
else { |
|
477 |
retstatus = KErrNoMemory; |
|
478 |
} |
|
479 |
} |
|
480 |
delete mainObeyFile; |
|
481 |
delete reader; |
|
482 |
return retstatus; |
|
483 |
} |
|
484 |
||
485 |
/** |
|
486 |
Rofsbuild Main function, which creates both Rofs and Data drive image. |
|
487 |
||
488 |
@param argc - No. of argument. |
|
489 |
@param *argv[] - Arguments value. |
|
490 |
||
491 |
@return - returns the status to caller. |
|
492 |
*/ |
|
493 |
TInt main(int argc, char *argv[]){ |
|
494 |
TInt r =0; |
|
495 |
#ifdef __LINUX__ |
|
496 |
gCPUNum = sysconf(_SC_NPROCESSORS_CONF); |
|
497 |
#else |
|
498 |
char* pCPUNum = getenv ("NUMBER_OF_PROCESSORS"); |
|
499 |
if (pCPUNum != NULL) |
|
500 |
gCPUNum = atoi(pCPUNum); |
|
501 |
#endif |
|
502 |
if(gCPUNum > MAXIMUM_THREADS) |
|
503 |
gCPUNum = MAXIMUM_THREADS; |
|
504 |
PrintVersion(); |
|
505 |
processCommandLine(argc, argv); |
|
654 | 506 |
if(gThreadNum == 0) { |
507 |
if(gCPUNum > 0) { |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
508 |
printf("The double number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum * 2); |
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
509 |
gThreadNum = gCPUNum * 2; |
654 | 510 |
} |
511 |
else { |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
512 |
printf("Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS); |
654 | 513 |
gThreadNum = DEFAULT_THREADS; |
514 |
} |
|
515 |
} |
|
516 |
if(loginput.length() >= 1) |
|
517 |
{ |
|
518 |
try |
|
519 |
{ |
|
694
c3fbb20e86f0
features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
691
diff
changeset
|
520 |
LogParser::GetInstance(ERofsImage)->ParseSymbol(loginput.c_str()); |
654 | 521 |
} |
522 |
catch(LoggingException le) |
|
523 |
{ |
|
524 |
printf("ERROR: %s\r\n", le.GetErrorMessage()); |
|
525 |
return 1; |
|
526 |
} |
|
527 |
return 0; |
|
528 |
} |
|
606 | 529 |
//if the user wants to clean up the cache, do it only. |
530 |
if(gCleanCache){ |
|
531 |
try { |
|
532 |
CacheManager::GetInstance()->CleanCache(); |
|
533 |
Print (EAlways, "Cache has been deleted successfully.\n"); |
|
534 |
} |
|
535 |
catch(CacheException& ce){ |
|
536 |
Print (EError, "%s\n", ce.GetErrorMessage()); |
|
537 |
return (TInt)1; |
|
538 |
} |
|
539 |
return r; |
|
540 |
} |
|
541 |
//initialize cache if the user switches on. |
|
542 |
if(gCache) { |
|
543 |
try { |
|
544 |
CacheManager::GetInstance(); |
|
545 |
} |
|
546 |
catch(CacheException ce){ |
|
547 |
Print (EError, "%s\n", ce.GetErrorMessage()); |
|
548 |
return (TInt)1; |
|
549 |
} |
|
550 |
} |
|
551 |
const char *obeyFileName = 0; |
|
552 |
if(!filename.empty()) |
|
553 |
obeyFileName = filename.c_str(); |
|
554 |
if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){ |
|
555 |
return KErrGeneral; |
|
556 |
} |
|
557 |
// Process drive obey files. |
|
558 |
if(gDriveImage) { |
|
559 |
char temp = 0; |
|
560 |
char *driveobeyFileName = (char*)_alloca(gDriveFilename.length() + 1); |
|
561 |
memcpy(driveobeyFileName,gDriveFilename.c_str(),gDriveFilename.length() + 1); |
|
562 |
char* ptr = driveobeyFileName; |
|
563 |
do { |
|
564 |
while(((temp = *ptr++) != ',') && (temp != 0)); |
|
565 |
*(--ptr)++ = 0; |
|
566 |
||
567 |
if(*driveobeyFileName) { |
|
647 | 568 |
string logfile = Getlogfile(driveobeyFileName, cmdlogfile); |
569 |
if(logfile.size() > 0) { |
|
570 |
H.SetLogFile(logfile.c_str()); |
|
606 | 571 |
GetLocalTime(); |
647 | 572 |
r = ProcessDataDriveMain(driveobeyFileName,logfile.c_str()); |
606 | 573 |
H.CloseLogFile(); |
574 |
if(r == KErrNoMemory) |
|
575 |
return KErrNoMemory; |
|
576 |
} |
|
577 |
else { |
|
578 |
Print(EError,"Invalid obey file name : %s\n", driveobeyFileName); |
|
579 |
} |
|
580 |
} |
|
581 |
driveobeyFileName = ptr; |
|
582 |
} while(temp != 0); |
|
583 |
gDriveImage = EFalse; |
|
584 |
} |
|
585 |
if(gSmrImage){ |
|
586 |
char temp = 0; |
|
587 |
char *smrImageObeyFileName = (char*)_alloca(gSmrFileName.length() + 1); |
|
588 |
memcpy(smrImageObeyFileName,gSmrFileName.c_str(),gSmrFileName.length() + 1); |
|
589 |
char* ptr = smrImageObeyFileName; |
|
590 |
do { |
|
591 |
while(((temp = *ptr++) != ',') && (temp != 0)); |
|
592 |
*(--ptr)++ = 0; |
|
593 |
||
594 |
if(*smrImageObeyFileName){ |
|
647 | 595 |
string logfile = Getlogfile(smrImageObeyFileName, cmdlogfile); |
596 |
if(logfile.size() > 0) { |
|
597 |
H.SetLogFile(logfile.c_str()); |
|
606 | 598 |
GetLocalTime(); |
647 | 599 |
r = ProcessSmrImageMain(smrImageObeyFileName, logfile.c_str()); |
606 | 600 |
H.CloseLogFile(); |
601 |
if(r == KErrNoMemory) |
|
602 |
return KErrNoMemory; |
|
603 |
} |
|
604 |
else { |
|
605 |
Print(EError,"Invalid obey file name: %s", smrImageObeyFileName); |
|
606 |
} |
|
607 |
} |
|
608 |
smrImageObeyFileName = ptr; |
|
609 |
} while(temp != 0); |
|
610 |
gSmrImage = EFalse; |
|
611 |
} |
|
612 |
// Process Rofs Obey files. |
|
613 |
if(obeyFileName) { |
|
654 | 614 |
if (cmdlogfile.empty() || cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/') |
655 | 615 |
cmdlogfile += "ROFSBUILD.LOG" ; |
616 |
||
647 | 617 |
H.SetLogFile(cmdlogfile.c_str()); |
606 | 618 |
ObeyFileReader *reader = new ObeyFileReader(obeyFileName); |
619 |
if (!reader->Open()) |
|
620 |
return KErrGeneral; |
|
621 |
||
622 |
E32Rofs* RofsImage = 0; // for image from obey file |
|
623 |
CCoreImage *core = 0; // for image from core image file |
|
624 |
MRofsImage* imageInfo = 0; |
|
625 |
CObeyFile *mainObeyFile = new CObeyFile(*reader); |
|
626 |
// need check if obey file has coreimage keyword |
|
627 |
char *file = mainObeyFile->ProcessCoreImage(); |
|
628 |
if (file) { |
|
629 |
// hase coreimage keyword but only use if command line option |
|
630 |
// for coreimage not already selected |
|
631 |
if (!gUseCoreImage){ |
|
632 |
gUseCoreImage = ETrue; |
|
633 |
gImageFilename = file; |
|
634 |
} |
|
635 |
delete []file ; |
|
636 |
} |
|
637 |
if (!gUseCoreImage) { |
|
638 |
r = mainObeyFile->ProcessRofs(); |
|
639 |
if (r == KErrNone) { |
|
640 |
// Build a ROFS image using the description compiled into the CObeyFile object |
|
641 |
RofsImage = new E32Rofs( mainObeyFile ); |
|
642 |
if( !RofsImage ) { |
|
643 |
if(gCache || gCleanCache) |
|
644 |
delete CacheManager::GetInstance(); |
|
645 |
return KErrNoMemory; |
|
646 |
} |
|
647 |
r = RofsImage->Create(); |
|
648 |
||
649 |
if( KErrNone == r ) { |
|
650 |
RofsImage->WriteImage( gHeaderType ); |
|
651 |
} |
|
652 |
imageInfo = RofsImage; |
|
653 |
mainObeyFile->Release(); |
|
654 |
if(gCache || gCleanCache) |
|
655 |
delete CacheManager::GetInstance(); |
|
656 |
} |
|
657 |
else if (r != KErrNotFound){ |
|
658 |
return r; |
|
659 |
} |
|
660 |
} |
|
661 |
else { |
|
662 |
// need to use core image |
|
663 |
RCoreImageReader *reader = new RCoreImageReader(gImageFilename.c_str()); |
|
664 |
if (!reader) { |
|
665 |
return KErrNoMemory; |
|
666 |
} |
|
667 |
core = new CCoreImage(reader); |
|
668 |
if (!core) { |
|
669 |
return KErrNoMemory; |
|
670 |
} |
|
671 |
r = core->ProcessImage(); |
|
672 |
if (r != KErrNone) { |
|
673 |
return r; |
|
674 |
} |
|
675 |
imageInfo = core; |
|
676 |
mainObeyFile->SkipToExtension(); |
|
677 |
} |
|
678 |
||
679 |
do { |
|
680 |
CObeyFile* extensionObeyFile = new CObeyFile(*reader); |
|
681 |
r = extensionObeyFile->ProcessExtensionRofs(imageInfo); |
|
682 |
if (r == KErrEof){ |
|
683 |
if(RofsImage){ |
|
684 |
delete RofsImage; |
|
685 |
} |
|
686 |
if(core){ |
|
687 |
delete core; |
|
688 |
} |
|
689 |
delete extensionObeyFile; |
|
690 |
return KErrNone; |
|
691 |
} |
|
692 |
if (r != KErrNone){ |
|
693 |
break; |
|
694 |
} |
|
695 |
E32Rofs* extensionRofs = new E32Rofs(extensionObeyFile); |
|
696 |
r = extensionRofs->CreateExtension(imageInfo); |
|
697 |
if (r!= KErrNone){ |
|
698 |
delete extensionRofs; |
|
699 |
delete extensionObeyFile; |
|
700 |
break; |
|
701 |
} |
|
702 |
r = extensionRofs->WriteImage(0); |
|
703 |
||
704 |
delete extensionRofs; |
|
705 |
extensionRofs = 0; |
|
706 |
} while (r == KErrNone); |
|
707 |
if(RofsImage) { |
|
708 |
delete RofsImage; |
|
709 |
} |
|
710 |
if(core){ |
|
711 |
delete core; |
|
712 |
} |
|
713 |
delete mainObeyFile; |
|
714 |
} |
|
715 |
return r; |
|
716 |
}//end of main. |