imgtools/romtools/rombuild/rombuild.cpp
changeset 626 ac03b93ca9c4
parent 617 3a747a240983
child 631 9435b9008a58
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    30 const TInt KRomLoaderHeaderNone=0;
    30 const TInt KRomLoaderHeaderNone=0;
    31 const TInt KRomLoaderHeaderEPOC=1;
    31 const TInt KRomLoaderHeaderEPOC=1;
    32 const TInt KRomLoaderHeaderCOFF=2;
    32 const TInt KRomLoaderHeaderCOFF=2;
    33 
    33 
    34 static const TInt RombuildMajorVersion=2;
    34 static const TInt RombuildMajorVersion=2;
    35 static const TInt RombuildMinorVersion=17;
    35 static const TInt RombuildMinorVersion=18;
    36 static const TInt RombuildPatchVersion=4;
    36 static const TInt RombuildPatchVersion=1;
    37 static TBool SizeSummary=EFalse;
    37 static TBool SizeSummary=EFalse;
    38 static TPrintType SizeWhere=EAlways;
    38 static TPrintType SizeWhere=EAlways;
    39 static string compareROMName = "";
    39 static string compareROMName = "";
    40 static TInt MAXIMUM_THREADS = 128;
    40 static TInt MAXIMUM_THREADS = 128;
    41 static TInt DEFAULT_THREADS = 8;
    41 static TInt DEFAULT_THREADS = 8;
       
    42 static string romlogfile = "ROMBUILD.LOG";
    42 
    43 
    43 string filename;			// to store oby filename passed to Rombuild.
    44 string filename;			// to store oby filename passed to Rombuild.
    44 TBool reallyHelp=EFalse;
    45 TBool reallyHelp=EFalse;
    45 TInt gCPUNum = 0;
    46 TInt gCPUNum = 0;
    46 TInt gThreadNum = 0;
    47 TInt gThreadNum = 0;
    47 char* g_pCharCPUNum = NULL;
    48 char* g_pCharCPUNum = NULL;
    48 TBool gGenDepGraph = EFalse;
    49 TBool gGenDepGraph = EFalse;
    49 string gDepInfoFile = "";
    50 string gDepInfoFile = "";
    50 TBool gGenSymbols = EFalse ;
    51 TBool gGenSymbols = EFalse ;
       
    52 TBool gIsOBYUTF8 = EFalse;
    51 void PrintVersion() {
    53 void PrintVersion() {
    52  	Print(EAlways,"\nROMBUILD - Rom builder");
    54  	Print(EAlways,"\nROMBUILD - Rom builder");
    53   	Print(EAlways, " V%d.%d.%d\n", RombuildMajorVersion, RombuildMinorVersion, RombuildPatchVersion);
    55   	Print(EAlways, " V%d.%d.%d\n", RombuildMajorVersion, RombuildMinorVersion, RombuildPatchVersion);
    54   	Print(EAlways,Copyright);
    56   	Print(EAlways,Copyright);
    55 	}
    57 	}
    70 	"                                      unpaged 	compress unpaged section only\n\n"	
    72 	"                                      unpaged 	compress unpaged section only\n\n"	
    71 	"        -j<digit>                     do the main job with <digit> threads\n"
    73 	"        -j<digit>                     do the main job with <digit> threads\n"
    72 	"        -symbols                      generate symbol file\n"
    74 	"        -symbols                      generate symbol file\n"
    73 	"        -compressionmethod <method>   method one of none|inflate|bytepair to set the compression\n"
    75 	"        -compressionmethod <method>   method one of none|inflate|bytepair to set the compression\n"
    74 	"        -no-sorted-romfs              do not add sorted entries arrays (6.1 compatible)\n"
    76 	"        -no-sorted-romfs              do not add sorted entries arrays (6.1 compatible)\n"
       
    77 	"        -oby-charset=<charset> used character set in which OBY was written\n"
    75 	"        -geninc                       to generate include file for licensee tools to use\n"			// DEF095619
    78 	"        -geninc                       to generate include file for licensee tools to use\n"			// DEF095619
    76 	"        -loglevel<level>              level of information to log (valid levels are 0,1,2,3,4).\n" //Tools like Visual ROM builder need the host/ROM filenames, size & if the file is hidden.
    79 	"        -loglevel<level>              level of information to log (valid levels are 0,1,2,3,4).\n" //Tools like Visual ROM builder need the host/ROM filenames, size & if the file is hidden.
    77 	"        -wstdpath                     warn if destination path provided for a file is not a standard path\n"
    80 	"        -wstdpath                     warn if destination path provided for a file is not a standard path\n"
    78 	"        -argfile=<fileName>           specify argument-file name containing list of command-line arguments to rombuild\n"
    81 	"        -argfile=<fileName>           specify argument-file name containing list of command-line arguments to rombuild\n"
    79 	"        -lowmem                       use memory-mapped file for image build to reduce physical memory consumption\n"
    82 	"        -lowmem                       use memory-mapped file for image build to reduce physical memory consumption\n"
    80 	"        -coreimage=<core image file>  to pass the core image as input for extension ROM image generation\n"
    83 	"        -coreimage=<core image file>  to pass the core image as input for extension ROM image generation\n"
    81 	"        -k                            to enable keepgoing when duplicate files exist in oby\n";
    84 	"        -k                            to enable keepgoing when duplicate files exist in oby\n"
       
    85 	"        -logfile=<fileName>           specify log file\n";
    82 
    86 
    83 
    87 
    84 char ReallyHelpText[] =
    88 char ReallyHelpText[] =
    85 	"Priorities:\n"
    89 	"Priorities:\n"
    86 	"        low background foreground high windowserver\n"
    90 	"        low background foreground high windowserver\n"
   254 						}
   258 						}
   255 						
   259 						
   256 					delete[] parameter;
   260 					delete[] parameter;
   257 					}
   261 					}
   258 				}	
   262 				}	
       
   263 			else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0)
       
   264 			{
       
   265 				if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0))
       
   266 					gIsOBYUTF8 = ETrue;
       
   267 				else
       
   268 					Print(EError, "Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]);
       
   269 			}
   259 			else if( stricmp(arg, "compressionmethod") == 0 ) {
   270 			else if( stricmp(arg, "compressionmethod") == 0 ) {
   260  				// next argument should be a method
   271  				// next argument should be a method
   261 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   272 				if( (i+1) >= argc || argv[i+1][0] == '-') {
   262  					Print (EError, "Missing compression method! Set it to default (no compression)!");
   273  					Print (EError, "Missing compression method! Set it to default (no compression)!");
   263 					gEnableCompress=EFalse;
   274 					gEnableCompress=EFalse;
   332 					gImageFilename.assign(arg + 10);	
   343 					gImageFilename.assign(arg + 10);	
   333 				}
   344 				}
   334 				else {
   345 				else {
   335  					Print (EError, "Core ROM image file is missing\n"); 
   346  					Print (EError, "Core ROM image file is missing\n"); 
   336 				}
   347 				}
       
   348 			}
       
   349 			else if (strnicmp(arg, "logfile=",8) ==0) {
       
   350 				romlogfile = arg + 8;
   337 			}
   351 			}
   338 			else 
   352 			else 
   339 #ifdef WIN32
   353 #ifdef WIN32
   340 				cout << "Unrecognised option " << argv[i] << "\n";
   354 				cout << "Unrecognised option " << argv[i] << "\n";
   341 #else
   355 #else
   422 		delete[]  temp;
   436 		delete[]  temp;
   423 	} 		
   437 	} 		
   424 }
   438 }
   425 
   439 
   426 int main(int argc, char *argv[])  {
   440 int main(int argc, char *argv[])  {
   427  	H.SetLogFile("ROMBUILD.LOG");
       
   428 	TInt r = 0;
   441 	TInt r = 0;
   429 #ifdef __LINUX__
   442 #ifdef __LINUX__
   430 	gCPUNum = sysconf(_SC_NPROCESSORS_CONF);
   443 	gCPUNum = sysconf(_SC_NPROCESSORS_CONF);
   431 #else
   444 #else
   432 	g_pCharCPUNum = getenv("NUMBER_OF_PROCESSORS");
   445 	g_pCharCPUNum = getenv("NUMBER_OF_PROCESSORS");
   438 
   451 
   439  	processCommandLine(argc, argv);
   452  	processCommandLine(argc, argv);
   440  	if(filename.empty())
   453  	if(filename.empty())
   441    		return KErrGeneral;
   454    		return KErrGeneral;
   442 		
   455 		
       
   456 	if (romlogfile[romlogfile.size()-1] == '\\' || romlogfile[romlogfile.size()-1] == '/')
       
   457 		romlogfile += "ROMBUILD.LOG";
       
   458  	H.SetLogFile(romlogfile.c_str());
       
   459 
   443     if(gThreadNum == 0) {
   460     if(gThreadNum == 0) {
   444  		if(gCPUNum > 0 && gCPUNum <= MAXIMUM_THREADS) {
   461  		if(gCPUNum > 0 && gCPUNum <= MAXIMUM_THREADS) {
   445  			Print(EAlways, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
   462  			Print(EAlways, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
   446 			gThreadNum = gCPUNum;
   463 			gThreadNum = gCPUNum;
   447 		}
   464 		}