imgtools/romtools/rofsbuild/rofsbuild.cpp
changeset 714 e5a58c351011
parent 708 0757c2976f96
equal deleted inserted replaced
713:7b7f0409fc00 714:e5a58c351011
    87 bool gCleanCache = false;
    87 bool gCleanCache = false;
    88 bool gNoCache = false;
    88 bool gNoCache = false;
    89 TBool gIsOBYUTF8 = EFalse;
    89 TBool gIsOBYUTF8 = EFalse;
    90 TBool gKeepGoing = EFalse;
    90 TBool gKeepGoing = EFalse;
    91 void PrintVersion() {
    91 void PrintVersion() {
    92 	printf("\nROFSBUILD - Rofs/Datadrive image builder");
    92 	Print(EAlways,"\nROFSBUILD - Rofs/Datadrive image builder");
    93 	printf(" V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
    93 	Print(EAlways, " V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
    94 	printf("%s\n\n", "Copyright (c) 1996-2010 Nokia Corporation.");
    94 	Print(EAlways, "Copyright (c) 1996-2010 Nokia Corporation.");
    95 }
    95 }
    96 
    96 
    97 char HelpText[] = 
    97 char HelpText[] = 
    98 	"Syntax: ROFSBUILD [options] obeyfilename(Rofs)\n"
    98 	"Syntax: ROFSBUILD [options] obeyfilename(Rofs)\n"
    99 	"Option: -v verbose,  -?,  -s[log|screen|both] size summary\n"
    99 	"Option: -v verbose,  -?,  -s[log|screen|both] size summary\n"
   164 				if(argv[i][5]) {
   164 				if(argv[i][5]) {
   165 					gSmrImage = ETrue;
   165 					gSmrImage = ETrue;
   166 					gSmrFileName.assign(&argv[i][5]);
   166 					gSmrFileName.assign(&argv[i][5]);
   167 				}
   167 				}
   168 				else {
   168 				else {
   169 					printf ("ERROR: SMR obey file is missing\n");
   169 					Print (EError, "SMR obey file is missing\n");
   170 				}
   170 				}
   171 			} else if (stricmp(argv[i], "-K") == 0) {
   171 			} else if (stricmp(argv[i], "-K") == 0) {
   172 				gKeepGoing = ETrue;
   172 				gKeepGoing = ETrue;
   173 			}else if (stricmp(argv[i], "-SYMBOLS") == 0) {
   173 			}else if (stricmp(argv[i], "-SYMBOLS") == 0) {
   174 				gGenSymbols = ETrue;
   174 				gGenSymbols = ETrue;
   243 			else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0)
   243 			else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0)
   244 			{
   244 			{
   245 				if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0))
   245 				if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0))
   246 					gIsOBYUTF8 = ETrue;
   246 					gIsOBYUTF8 = ETrue;
   247 				else
   247 				else
   248 					printf("ERROR: Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]);
   248 					Print(EError, "Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]);
   249 			}
   249 			}
   250 			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
   250 			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
   251 				gCompress = ECompressionUncompress;
   251 				gCompress = ECompressionUncompress;
   252 			}
   252 			}
   253 			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
   253 			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
   254 				// next argument should a be method
   254 				// next argument should a be method
   255 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   255 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   256 					printf("ERROR: Missing compression method! Set it to default (no compression)!");
   256 					Print (EError, "Missing compression method! Set it to default (no compression)!");
   257 					gCompressionMethod = 0;
   257 					gCompressionMethod = 0;
   258 				}
   258 				}
   259 				else {
   259 				else {
   260 					i++;					
   260 					i++;					
   261 					if( stricmp(argv[i], "NONE") == 0) {
   261 					if( stricmp(argv[i], "NONE") == 0) {
   269 					else if( stricmp(argv[i], "BYTEPAIR") == 0) {
   269 					else if( stricmp(argv[i], "BYTEPAIR") == 0) {
   270 						gCompress = ECompressionCompress;
   270 						gCompress = ECompressionCompress;
   271 						gCompressionMethod = KUidCompressionBytePair;	
   271 						gCompressionMethod = KUidCompressionBytePair;	
   272 					}
   272 					}
   273 					else {
   273 					else {
   274 						printf("ERROR: Unknown compression method! Set it to default (no compression)!");
   274 						Print (EError, "Unknown compression method! Set it to default (no compression)!");
   275 						gCompress = ECompressionUnknown;
   275 						gCompress = ECompressionUnknown;
   276 						gCompressionMethod = 0;		
   276 						gCompressionMethod = 0;		
   277 					}
   277 					}
   278 				}
   278 				}
   279 
   279 
   281 			else if (stricmp(argv[i], "-COREIMAGE") == 0) {
   281 			else if (stricmp(argv[i], "-COREIMAGE") == 0) {
   282 				
   282 				
   283 				gUseCoreImage = ETrue;
   283 				gUseCoreImage = ETrue;
   284 				// next argument should be image filename
   284 				// next argument should be image filename
   285 				if ((i+1 >= argc) || argv[i+1][0] == '-')
   285 				if ((i+1 >= argc) || argv[i+1][0] == '-')
   286 					printf("ERROR: Missing image file name");
   286 					Print (EError, "Missing image file name");
   287 				else {
   287 				else {
   288 					i++;
   288 					i++;
   289 					gImageFilename.assign(argv[i]);
   289 					gImageFilename.assign(argv[i]);
   290 				}
   290 				}
   291 			}
   291 			}
   293 				if(argv[i][11])	{
   293 				if(argv[i][11])	{
   294 					gDriveImage = ETrue; 
   294 					gDriveImage = ETrue; 
   295 					gDriveFilename.assign(&argv[i][11]);	
   295 					gDriveFilename.assign(&argv[i][11]);	
   296 				}
   296 				}
   297 				else {
   297 				else {
   298 					printf("ERROR: Drive obey file is missing\n"); 
   298 					Print (EError, "Drive obey file is missing\n"); 
   299 				}
   299 				}
   300 			}
   300 			}
   301 			else if (argv[i][1] == '?') {
   301 			else if (argv[i][1] == '?') {
   302 				reallyHelp = ETrue;
   302 				reallyHelp = ETrue;
   303 			}
   303 			}
   305 				gEnableStdPathWarning = ETrue;						
   305 				gEnableStdPathWarning = ETrue;						
   306 			}
   306 			}
   307 			else if( stricmp(argv[i], "-LOGLEVEL") == 0) {
   307 			else if( stricmp(argv[i], "-LOGLEVEL") == 0) {
   308 				// next argument should a be loglevel
   308 				// next argument should a be loglevel
   309 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   309 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   310 					printf ("ERROR: Missing loglevel!");
   310 					Print (EError, "Missing loglevel!");
   311 					gLogLevel = DEFAULT_LOG_LEVEL;
   311 					gLogLevel = DEFAULT_LOG_LEVEL;
   312 				}
   312 				}
   313 				else {
   313 				else {
   314 					i++;
   314 					i++;
   315 					if (strcmp(argv[i], "2") == 0)
   315 					if (strcmp(argv[i], "2") == 0)
   317 					if (strcmp(argv[i], "1") == 0)
   317 					if (strcmp(argv[i], "1") == 0)
   318 						gLogLevel = LOG_LEVEL_FILE_DETAILS;
   318 						gLogLevel = LOG_LEVEL_FILE_DETAILS;
   319 					else if (strcmp(argv[i], "0") == 0)
   319 					else if (strcmp(argv[i], "0") == 0)
   320 						gLogLevel = DEFAULT_LOG_LEVEL;
   320 						gLogLevel = DEFAULT_LOG_LEVEL;
   321 					else
   321 					else
   322 						printf("ERROR: Only loglevel 0, 1 or 2 is allowed!");
   322 						Print(EError, "Only loglevel 0, 1 or 2 is allowed!");
   323 				}
   323 				}
   324 			}
   324 			}
   325 			else if( stricmp(argv[i], "-LOGLEVEL2") == 0)
   325 			else if( stricmp(argv[i], "-LOGLEVEL2") == 0)
   326 				gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
   326 				gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
   327 			else if( stricmp(argv[i], "-LOGLEVEL1") == 0)
   327 			else if( stricmp(argv[i], "-LOGLEVEL1") == 0)
   336 			else if (strnicmp(argv[i], "-loginput=", 10) == 0) {
   336 			else if (strnicmp(argv[i], "-loginput=", 10) == 0) {
   337 				loginput = argv[i] + 10;
   337 				loginput = argv[i] + 10;
   338 			}
   338 			}
   339 			else {
   339 			else {
   340 #ifdef WIN32
   340 #ifdef WIN32
   341 				printf ("WARNING: Unrecognised option %s\n",argv[i]);
   341 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   342 #else
   342 #else
   343 				if(0 == access(argv[i],R_OK)){
   343 				if(0 == access(argv[i],R_OK)){
   344 					filename.assign(argv[i]);
   344 					filename.assign(argv[i]);
   345 				}
   345 				}
   346 				else {
   346 				else {
   347 					printf("WARNING: Unrecognised option %s\n",argv[i]);
   347 					Print (EWarning, "Unrecognised option %s\n",argv[i]);
   348 				}
   348 				}
   349 #endif				
   349 #endif				
   350 
   350 
   351 			}
   351 			}
   352 		}
   352 		}
   369 			if (reallyHelp) {
   369 			if (reallyHelp) {
   370 				ObeyFileReader::KeywordHelp();
   370 				ObeyFileReader::KeywordHelp();
   371 				Print (EAlways, ReallyHelpText);
   371 				Print (EAlways, ReallyHelpText);
   372 			}
   372 			}
   373 			else if (filename.empty()){
   373 			else if (filename.empty()){
   374 				printf("WARNING: Obey filename is missing\n");
   374 				Print(EAlways, "Obey filename is missing\n");
   375 			}
   375 			}
   376 	}	
   376 	}	
   377 }
   377 }
   378 
   378 
   379 /**
   379 /**
   497 #else	
   497 #else	
   498 	char* pCPUNum = getenv ("NUMBER_OF_PROCESSORS");
   498 	char* pCPUNum = getenv ("NUMBER_OF_PROCESSORS");
   499 	if (pCPUNum != NULL)
   499 	if (pCPUNum != NULL)
   500 		gCPUNum = atoi(pCPUNum);
   500 		gCPUNum = atoi(pCPUNum);
   501 #endif		
   501 #endif		
   502 	if(gCPUNum > MAXIMUM_THREADS)
   502 	if(gCPUNum > MAXIMUM_THREADS >> 1)
   503 		gCPUNum = MAXIMUM_THREADS;
   503 		gCPUNum = MAXIMUM_THREADS >> 1;
   504 	PrintVersion();
   504 	PrintVersion();
   505 	processCommandLine(argc, argv);
   505 	processCommandLine(argc, argv);
   506 	if(gThreadNum == 0) {
   506 	if(gThreadNum == 0) {
   507 		if(gCPUNum > 0) {
   507 		if(gCPUNum > 0) {
   508 			printf("The double number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum * 2);
   508 			printf("The double number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum * 2);