imgtools/romtools/rofsbuild/rofsbuild.cpp
changeset 654 7c11c3d8d025
parent 647 53d1ab72f5bc
child 662 60be34e1b006
equal deleted inserted replaced
653:8ee61c1e0c5c 654:7c11c3d8d025
    32 #include "cache/cache.hpp"
    32 #include "cache/cache.hpp"
    33 #include "cache/cachegenerator.hpp"
    33 #include "cache/cachegenerator.hpp"
    34 #include "cache/cachevalidator.hpp"
    34 #include "cache/cachevalidator.hpp"
    35 #include "cache/cacheablelist.hpp"
    35 #include "cache/cacheablelist.hpp"
    36 #include "cache/cachemanager.hpp"
    36 #include "cache/cachemanager.hpp"
       
    37 #include "logging/loggingexception.hpp"
       
    38 #include "logging/logparser.hpp"
    37 #include <malloc.h>
    39 #include <malloc.h>
    38  
    40  
    39 #ifndef WIN32
    41 #ifndef WIN32
    40 #include <unistd.h>
    42 #include <unistd.h>
    41 #include <strings.h>
    43 #include <strings.h>
    44 #define stricmp strcasecmp
    46 #define stricmp strcasecmp
    45 #define _alloca alloca
    47 #define _alloca alloca
    46 #endif
    48 #endif
    47 
    49 
    48 static const TInt RofsbuildMajorVersion=2;
    50 static const TInt RofsbuildMajorVersion=2;
    49 static const TInt RofsbuildMinorVersion=14;
    51 static const TInt RofsbuildMinorVersion=16;
    50 static const TInt RofsbuildPatchVersion=1;
    52 static const TInt RofsbuildPatchVersion=1;
    51 static TBool SizeSummary=EFalse;
    53 static TBool SizeSummary=EFalse;
    52 static TPrintType SizeWhere=EAlways;
    54 static TPrintType SizeWhere=EAlways;
    53 
    55 
    54 static TInt gHeaderType=1;			// EPOC header
    56 static TInt gHeaderType=1;			// EPOC header
    76 string filename;				// to store oby filename passed to Rofsbuild.
    78 string filename;				// to store oby filename passed to Rofsbuild.
    77 TBool reallyHelp = EFalse;	
    79 TBool reallyHelp = EFalse;	
    78 TBool gSmrImage = EFalse;
    80 TBool gSmrImage = EFalse;
    79 string gSmrFileName = "";
    81 string gSmrFileName = "";
    80 static string cmdlogfile = "";
    82 static string cmdlogfile = "";
       
    83 static string loginput = "";
    81 
    84 
    82 //Cache global variables
    85 //Cache global variables
    83 bool gCache = false;
    86 bool gCache = false;
    84 bool gCleanCache = false;
    87 bool gCleanCache = false;
    85 bool gNoCache = false;
    88 bool gNoCache = false;
   113 	"        -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.
   116 	"        -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.
   114 	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
   117 	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
   115 	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
   118 	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
   116 "        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
   119 "        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
   117 "        -k     to enable keepgoing when duplicate files exist in oby\n"
   120 "        -k     to enable keepgoing when duplicate files exist in oby\n"
   118 "        -logfile=<fileName>           specify log file\n";
   121 "        -logfile=<fileName>           specify log file\n"
       
   122 "        -loginput=<log filename>      specify as input a log file and produce as output symbol file.\n";
   119 
   123 
   120 char ReallyHelpText[] =
   124 char ReallyHelpText[] =
   121 "Log Level:\n"
   125 "Log Level:\n"
   122 "        0  produce the default logs\n"
   126 "        0  produce the default logs\n"
   123 "        1  produce file detail logs in addition to the default logs\n"
   127 "        1  produce file detail logs in addition to the default logs\n"
   323 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   327 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   324 				gLowMem = ETrue;
   328 				gLowMem = ETrue;
   325 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
   329 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
   326 				cmdlogfile = argv[i] + 9;
   330 				cmdlogfile = argv[i] + 9;
   327 			}
   331 			}
       
   332 			else if (strnicmp(argv[i], "-loginput=", 10) == 0) {
       
   333 				loginput = argv[i] + 10;
       
   334 			}
   328 			else {
   335 			else {
   329 #ifdef WIN32
   336 #ifdef WIN32
   330 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   337 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   331 #else
   338 #else
   332 				if(0 == access(argv[i],R_OK)){
   339 				if(0 == access(argv[i],R_OK)){
   346 
   353 
   347 	if (paramFileFlag)
   354 	if (paramFileFlag)
   348 		return;
   355 		return;
   349 
   356 
   350 	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
   357 	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
   351 		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
   358 		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0)) && (loginput.length() == 0)){
   352 			Print (EAlways, HelpText);
   359 			Print (EAlways, HelpText);
   353 			if (reallyHelp) {
   360 			if (reallyHelp) {
   354 				ObeyFileReader::KeywordHelp();
   361 				ObeyFileReader::KeywordHelp();
   355 				Print (EAlways, ReallyHelpText);
   362 				Print (EAlways, ReallyHelpText);
   356 			}
   363 			}
   485 #endif		
   492 #endif		
   486 	if(gCPUNum > MAXIMUM_THREADS)
   493 	if(gCPUNum > MAXIMUM_THREADS)
   487 		gCPUNum = MAXIMUM_THREADS;
   494 		gCPUNum = MAXIMUM_THREADS;
   488 	PrintVersion();
   495 	PrintVersion();
   489 	processCommandLine(argc, argv);
   496 	processCommandLine(argc, argv);
       
   497 	if(gThreadNum == 0) {
       
   498 		if(gCPUNum > 0) {
       
   499 			printf("WARNING: The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
       
   500 			gThreadNum = gCPUNum;
       
   501 		}
       
   502 		else {
       
   503 			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
       
   504 			gThreadNum = DEFAULT_THREADS;
       
   505 		}
       
   506 	}
       
   507 	if(loginput.length() >= 1)
       
   508 	{
       
   509 		try
       
   510 		{
       
   511 			LogParser::GetInstance()->ParseSymbol(loginput.c_str());
       
   512 		}
       
   513 		catch(LoggingException le)
       
   514 		{
       
   515 			printf("ERROR: %s\r\n", le.GetErrorMessage());
       
   516 			return 1;
       
   517 		}
       
   518 		return 0;
       
   519 	}
   490 	//if the user wants to clean up the cache, do it only.
   520 	//if the user wants to clean up the cache, do it only.
   491 	if(gCleanCache){
   521 	if(gCleanCache){
   492 		try {
   522 		try {
   493 			CacheManager::GetInstance()->CleanCache();
   523 			CacheManager::GetInstance()->CleanCache();
   494 			Print (EAlways, "Cache has been deleted successfully.\n");
   524 			Print (EAlways, "Cache has been deleted successfully.\n");
   512 	const char *obeyFileName = 0;	
   542 	const char *obeyFileName = 0;	
   513 	if(!filename.empty())
   543 	if(!filename.empty())
   514 		obeyFileName = filename.c_str(); 
   544 		obeyFileName = filename.c_str(); 
   515 	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
   545 	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
   516 		return KErrGeneral;
   546 		return KErrGeneral;
   517 	}
       
   518 	if(gThreadNum == 0) {
       
   519 		if(gCPUNum > 0) {
       
   520 			printf("WARNING: The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
       
   521 			gThreadNum = gCPUNum;
       
   522 		}
       
   523 		else {
       
   524 			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
       
   525 			gThreadNum = DEFAULT_THREADS;
       
   526 		}
       
   527 	}
   547 	}
   528 	// Process drive obey files.
   548 	// Process drive obey files.
   529 	if(gDriveImage) {  
   549 	if(gDriveImage) {  
   530 		char temp = 0;
   550 		char temp = 0;
   531 		char *driveobeyFileName = (char*)_alloca(gDriveFilename.length() + 1);
   551 		char *driveobeyFileName = (char*)_alloca(gDriveFilename.length() + 1);
   580 		} while(temp != 0);
   600 		} while(temp != 0);
   581 		gSmrImage = EFalse;
   601 		gSmrImage = EFalse;
   582 	}
   602 	}
   583 	// Process Rofs Obey files.
   603 	// Process Rofs Obey files.
   584 	if(obeyFileName) {
   604 	if(obeyFileName) {
   585 		if (cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/')
   605 		if (cmdlogfile.empty() || cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/')
   586 			cmdlogfile += "ROFSBUILD.LOG";
   606 			cmdlogfile += "ROFSBUILD.LOG" ;
       
   607 			
   587 	 	H.SetLogFile(cmdlogfile.c_str());
   608 	 	H.SetLogFile(cmdlogfile.c_str());
   588 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   609 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   589 		if (!reader->Open())
   610 		if (!reader->Open())
   590 			return KErrGeneral;
   611 			return KErrGeneral;
   591 
   612