imgtools/romtools/rofsbuild/rofsbuild.cpp
changeset 607 378360dbbdba
parent 590 360bd6b35136
parent 606 30b30f9da0b7
child 609 f76e0f94b7ab
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
    44 #define stricmp strcasecmp
    44 #define stricmp strcasecmp
    45 #define _alloca alloca
    45 #define _alloca alloca
    46 #endif
    46 #endif
    47 
    47 
    48 static const TInt RofsbuildMajorVersion=2;
    48 static const TInt RofsbuildMajorVersion=2;
    49 static const TInt RofsbuildMinorVersion=10;
    49 static const TInt RofsbuildMinorVersion=12;
    50 static const TInt RofsbuildPatchVersion=4;
    50 static const TInt RofsbuildPatchVersion=0;
    51 static TBool SizeSummary=EFalse;
    51 static TBool SizeSummary=EFalse;
    52 static TPrintType SizeWhere=EAlways;
    52 static TPrintType SizeWhere=EAlways;
    53 
    53 
    54 static TInt gHeaderType=1;			// EPOC header
    54 static TInt gHeaderType=1;			// EPOC header
    55 static TInt MAXIMUM_THREADS = 128;
    55 static TInt MAXIMUM_THREADS = 128;
   311 				gLogLevel = DEFAULT_LOG_LEVEL;
   311 				gLogLevel = DEFAULT_LOG_LEVEL;
   312 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   312 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   313 				gLowMem = ETrue;
   313 				gLowMem = ETrue;
   314 			else {
   314 			else {
   315 #ifdef WIN32
   315 #ifdef WIN32
   316 				cout << "Unrecognised option " << argv[i] << "\n";
   316 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   317 #else
   317 #else
   318 				if(0 == access(argv[i],R_OK)){
   318 				if(0 == access(argv[i],R_OK)){
   319 					filename.assign(argv[i]);
   319 					filename.assign(argv[i]);
   320 				}
   320 				}
   321 				else {
   321 				else {
   322 					cout << "Unrecognised option " << argv[i] << "\n";
   322 					Print (EWarning, "Unrecognised option %s\n",argv[i]);
   323 				}
   323 				}
   324 #endif				
   324 #endif				
   325 
   325 
   326 			}
   326 			}
   327 		}
   327 		}
   333 	if (paramFileFlag)
   333 	if (paramFileFlag)
   334 		return;
   334 		return;
   335 
   335 
   336 	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
   336 	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
   337 		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
   337 		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
   338 			PrintVersion();
   338 			Print (EAlways, HelpText);
   339 			cout << HelpText;
       
   340 			if (reallyHelp) {
   339 			if (reallyHelp) {
   341 				ObeyFileReader::KeywordHelp();
   340 				ObeyFileReader::KeywordHelp();
   342 				cout << ReallyHelpText;
   341 				Print (EAlways, ReallyHelpText);
   343 			}
   342 			}
   344 			else if (filename.empty()){
   343 			else if (filename.empty()){
   345 				Print(EError, "Obey filename is missing\n");
   344 				Print(EAlways, "Obey filename is missing\n");
   346 			}
   345 			}
   347 	}	
   346 	}	
   348 }
   347 }
   349 
   348 
   350 /**
   349 /**
   397 		CDriveImage* userImage = new CDriveImage(mainObeyFile);
   396 		CDriveImage* userImage = new CDriveImage(mainObeyFile);
   398 		if(userImage) {	
   397 		if(userImage) {	
   399 			// Drive image creation.
   398 			// Drive image creation.
   400 			retstatus = userImage->CreateImage(alogfile);
   399 			retstatus = userImage->CreateImage(alogfile);
   401 			if(retstatus == KErrNone) {
   400 			if(retstatus == KErrNone) {
   402 				cout << "\nSuccessfully generated the Drive image : " << mainObeyFile->iDriveFileName << "\n";
   401 				Print (EAlways, "\nSuccessfully generated the Drive image : %s \n",mainObeyFile->iDriveFileName);
   403 			}
   402 			}
   404 			else {
   403 			else {
   405 				cout << "\nFailed to generate the Image : " << mainObeyFile->iDriveFileName << "\n";
   404 				Print (EError, "Failed to generate the Image : %s\n",mainObeyFile->iDriveFileName);
   406 			}
   405 			}
   407 			delete userImage; 
   406 			delete userImage; 
   408 		}
   407 		}
   409 		else {
   408 		else {
   410 			retstatus = KErrNoMemory;
   409 			retstatus = KErrNoMemory;
   435 		if(smrImage) {
   434 		if(smrImage) {
   436 			if((retstatus = smrImage->Initialise()) == KErrNone) {
   435 			if((retstatus = smrImage->Initialise()) == KErrNone) {
   437 				retstatus = smrImage->CreateImage();
   436 				retstatus = smrImage->CreateImage();
   438 			}
   437 			}
   439 			if(retstatus == KErrNone) {
   438 			if(retstatus == KErrNone) {
   440 				cout << "\nSuccessfully generated the SMR image : " << smrImage->GetImageName().c_str() << "\n";
   439 				Print (EAlways,  "\nSuccessfully generated the SMR image : %s\n" ,smrImage->GetImageName().c_str());
   441 			}
   440 			}
   442 			else {
   441 			else {
   443 				cout << "\nFailed to generate the Image : " << smrImage->GetImageName().c_str() << "\n";
   442 				Print (EError, "\nFailed to generate the Image : %s\n" ,smrImage->GetImageName().c_str());
   444 			}
   443 			}
   445 			delete smrImage;
   444 			delete smrImage;
   446 		}
   445 		}
   447 		else {
   446 		else {
   448 			retstatus = KErrNoMemory;
   447 			retstatus = KErrNoMemory;
   470 	if (pCPUNum != NULL)
   469 	if (pCPUNum != NULL)
   471 		gCPUNum = atoi(pCPUNum);
   470 		gCPUNum = atoi(pCPUNum);
   472 #endif		
   471 #endif		
   473 	if(gCPUNum > MAXIMUM_THREADS)
   472 	if(gCPUNum > MAXIMUM_THREADS)
   474 		gCPUNum = MAXIMUM_THREADS;
   473 		gCPUNum = MAXIMUM_THREADS;
       
   474 	PrintVersion();
   475 	processCommandLine(argc, argv);
   475 	processCommandLine(argc, argv);
   476 	//if the user wants to clean up the cache, do it only.
   476 	//if the user wants to clean up the cache, do it only.
   477 	if(gCleanCache){
   477 	if(gCleanCache){
   478 		try {
   478 		try {
   479 			CacheManager::GetInstance()->CleanCache();
   479 			CacheManager::GetInstance()->CleanCache();
   480 			printf("Cache has been deleted successfully.\r\n");
   480 			Print (EAlways, "Cache has been deleted successfully.\n");
   481 		}
   481 		}
   482 		catch(CacheException& ce){
   482 		catch(CacheException& ce){
   483 			printf("%s\r\n", ce.GetErrorMessage());
   483 			Print (EError, "%s\n", ce.GetErrorMessage());
   484 			return (TInt)1;
   484 			return (TInt)1;
   485 		}
   485 		}
   486 		return r;
   486 		return r;
   487 	}
   487 	}
   488 	//initialize cache if the user switches on.
   488 	//initialize cache if the user switches on.
   489 	if(gCache) {
   489 	if(gCache) {
   490 		try {
   490 		try {
   491 			CacheManager::GetInstance();
   491 			CacheManager::GetInstance();
   492 		}
   492 		}
   493 		catch(CacheException ce){
   493 		catch(CacheException ce){
   494 			printf("%s\r\n", ce.GetErrorMessage());
   494 			Print (EError, "%s\n", ce.GetErrorMessage());
   495 			return (TInt)1;
   495 			return (TInt)1;
   496 		}
   496 		}
   497 	}
   497 	}
   498 	const char *obeyFileName = 0;	
   498 	const char *obeyFileName = 0;	
   499 	if(!filename.empty())
   499 	if(!filename.empty())
   501 	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
   501 	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
   502 		return KErrGeneral;
   502 		return KErrGeneral;
   503 	}
   503 	}
   504 	if(gThreadNum == 0) {
   504 	if(gThreadNum == 0) {
   505 		if(gCPUNum > 0) {
   505 		if(gCPUNum > 0) {
   506 			printf("The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
   506 			Print (EWarning, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
   507 			gThreadNum = gCPUNum;
   507 			gThreadNum = gCPUNum;
   508 		}
   508 		}
   509 		else {
   509 		else {
   510 			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
   510 			Print (EWarning, "Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
   511 			gThreadNum = DEFAULT_THREADS;
   511 			gThreadNum = DEFAULT_THREADS;
   512 		}
   512 		}
   513 	}
   513 	}
   514 	// Process drive obey files.
   514 	// Process drive obey files.
   515 	if(gDriveImage) {  
   515 	if(gDriveImage) {  
   523 
   523 
   524 			if(*driveobeyFileName) {
   524 			if(*driveobeyFileName) {
   525 				char* logfile = 0;
   525 				char* logfile = 0;
   526 				if(Getlogfile(driveobeyFileName,logfile) == KErrNone) {
   526 				if(Getlogfile(driveobeyFileName,logfile) == KErrNone) {
   527 					H.SetLogFile(logfile);
   527 					H.SetLogFile(logfile);
   528 					PrintVersion();
       
   529 					GetLocalTime();
   528 					GetLocalTime();
   530 					r = ProcessDataDriveMain(driveobeyFileName,logfile);   
   529 					r = ProcessDataDriveMain(driveobeyFileName,logfile);   
   531 					H.CloseLogFile();
   530 					H.CloseLogFile();
   532 					delete[] logfile;
   531 					delete[] logfile;
   533 					if(r == KErrNoMemory)
   532 					if(r == KErrNoMemory)
   534 						return KErrNoMemory;
   533 						return KErrNoMemory;
   535 				}
   534 				}
   536 				else {
   535 				else {
   537 					cout << "Error : Invalid obey file name : " << driveobeyFileName << "\n" ;   
   536 					Print(EError,"Invalid obey file name : %s\n", driveobeyFileName);   
   538 				}
   537 				}
   539 			}
   538 			}
   540 			driveobeyFileName = ptr;
   539 			driveobeyFileName = ptr;
   541 		} while(temp != 0); 
   540 		} while(temp != 0); 
   542 		gDriveImage = EFalse;
   541 		gDriveImage = EFalse;
   552 
   551 
   553 			if(*smrImageObeyFileName){	
   552 			if(*smrImageObeyFileName){	
   554 				char * logfile = 0;
   553 				char * logfile = 0;
   555 				if(Getlogfile(smrImageObeyFileName,logfile) == KErrNone){
   554 				if(Getlogfile(smrImageObeyFileName,logfile) == KErrNone){
   556 					H.SetLogFile(logfile);
   555 					H.SetLogFile(logfile);
   557 					PrintVersion();
       
   558 					GetLocalTime();
   556 					GetLocalTime();
   559 					r = ProcessSmrImageMain(smrImageObeyFileName, logfile);
   557 					r = ProcessSmrImageMain(smrImageObeyFileName, logfile);
   560 					H.CloseLogFile();
   558 					H.CloseLogFile();
   561 					delete[] logfile;
   559 					delete[] logfile;
   562 					if(r == KErrNoMemory)
   560 					if(r == KErrNoMemory)
   563 						return KErrNoMemory;
   561 						return KErrNoMemory;
   564 				}
   562 				}
   565 				else {
   563 				else {
   566 					cout << "Error: Invalid obey file name: " << smrImageObeyFileName << "\n";
   564 					Print(EError,"Invalid obey file name: %s", smrImageObeyFileName);
   567 				}
   565 				}
   568 			}
   566 			}
   569 			smrImageObeyFileName = ptr;
   567 			smrImageObeyFileName = ptr;
   570 		} while(temp != 0);
   568 		} while(temp != 0);
   571 		gSmrImage = EFalse;
   569 		gSmrImage = EFalse;
   572 	}
   570 	}
   573 	// Process Rofs Obey files.
   571 	// Process Rofs Obey files.
   574 	if(obeyFileName) {
   572 	if(obeyFileName) {
   575 		H.SetLogFile("ROFSBUILD.LOG");
   573 		H.SetLogFile("ROFSBUILD.LOG");		
   576 		PrintVersion();
       
   577 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   574 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   578 		if (!reader->Open())
   575 		if (!reader->Open())
   579 			return KErrGeneral;
   576 			return KErrGeneral;
   580 
   577 
   581 		E32Rofs* RofsImage = 0;		// for image from obey file
   578 		E32Rofs* RofsImage = 0;		// for image from obey file
   659 				break;
   656 				break;
   660 			}
   657 			}
   661 			r = extensionRofs->WriteImage(0);	
   658 			r = extensionRofs->WriteImage(0);	
   662 
   659 
   663 			delete extensionRofs;
   660 			delete extensionRofs;
   664 			delete extensionObeyFile;			
       
   665 			extensionRofs = 0;
   661 			extensionRofs = 0;
   666 			extensionObeyFile = 0;
       
   667 		} while (r == KErrNone);
   662 		} while (r == KErrNone);
   668 		if(RofsImage) {
   663 		if(RofsImage) {
   669 			delete RofsImage;									
   664 			delete RofsImage;									
   670 		}
   665 		}
   671 		if(core){
   666 		if(core){