imgtools/romtools/rofsbuild/rofsbuild.cpp
changeset 626 ac03b93ca9c4
parent 617 3a747a240983
child 631 9435b9008a58
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    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=12;
    49 static const TInt RofsbuildMinorVersion=13;
    50 static const TInt RofsbuildPatchVersion=4;
    50 static const TInt RofsbuildPatchVersion=1;
    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;
    75 string gDriveFilename = "";		// input drive oby filename.
    75 string gDriveFilename = "";		// input drive oby filename.
    76 string filename;				// to store oby filename passed to Rofsbuild.
    76 string filename;				// to store oby filename passed to Rofsbuild.
    77 TBool reallyHelp = EFalse;	
    77 TBool reallyHelp = EFalse;	
    78 TBool gSmrImage = EFalse;
    78 TBool gSmrImage = EFalse;
    79 string gSmrFileName = "";
    79 string gSmrFileName = "";
       
    80 static string rofslogfile = "ROFSBUILD.LOG";
    80 
    81 
    81 //Cache global variables
    82 //Cache global variables
    82 bool gCache = false;
    83 bool gCache = false;
    83 bool gCleanCache = false;
    84 bool gCleanCache = false;
    84 bool gNoCache = false;
    85 bool gNoCache = false;
       
    86 TBool gIsOBYUTF8 = EFalse;
    85 TBool gKeepGoing = EFalse;
    87 TBool gKeepGoing = EFalse;
    86 void PrintVersion() {
    88 void PrintVersion() {
    87 	Print(EAlways,"\nROFSBUILD - Rofs/Datadrive image builder");
    89 	Print(EAlways,"\nROFSBUILD - Rofs/Datadrive image builder");
    88 	Print(EAlways, " V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
    90 	Print(EAlways, " V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
    89 	Print(EAlways,Copyright);
    91 	Print(EAlways,Copyright);
   105 	"        -nocache force the ROFSBUILD not to reuse/generate cached executable files\n"
   107 	"        -nocache force the ROFSBUILD not to reuse/generate cached executable files\n"
   106 	"        -cleancache permanently remove all cached executable files\n"
   108 	"        -cleancache permanently remove all cached executable files\n"
   107 	"        -datadrive=<drive obyfile1>,<drive obyfile2>,... for driveimage creation\n"
   109 	"        -datadrive=<drive obyfile1>,<drive obyfile2>,... for driveimage creation\n"
   108 	"              user can also input rofs oby file if required to generate both.\n"
   110 	"              user can also input rofs oby file if required to generate both.\n"
   109 	"        -smr=<SMR obyfile1>,<SMR obyfile2>,... for SMR partition creation\n"
   111 	"        -smr=<SMR obyfile1>,<SMR obyfile2>,... for SMR partition creation\n"
       
   112 	"        -oby-charset=<charset> used character set in which OBY was written\n"
   110 	"        -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.
   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.
   111 	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
   114 	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
   112 	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
   115 	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
   113 "        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
   116 "        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
   114 "        -k     to enable keepgoing when duplicate files exist in oby\n";
   117 "        -k     to enable keepgoing when duplicate files exist in oby\n"
       
   118 "        -logfile=<fileName>           specify log file\n";
   115 
   119 
   116 char ReallyHelpText[] =
   120 char ReallyHelpText[] =
   117 "Log Level:\n"
   121 "Log Level:\n"
   118 "        0  produce the default logs\n"
   122 "        0  produce the default logs\n"
   119 "        1  produce file detail logs in addition to the default logs\n"
   123 "        1  produce file detail logs in addition to the default logs\n"
   226 						printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
   230 						printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
   227 						gThreadNum = DEFAULT_THREADS;
   231 						gThreadNum = DEFAULT_THREADS;
   228 					}
   232 					}
   229 				}
   233 				}
   230 			}
   234 			}
       
   235 			else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0)
       
   236 			{
       
   237 				if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0))
       
   238 					gIsOBYUTF8 = ETrue;
       
   239 				else
       
   240 					Print(EError, "Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]);
       
   241 			}
   231 			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
   242 			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
   232 				gCompress = ECompressionUncompress;
   243 				gCompress = ECompressionUncompress;
   233 			}
   244 			}
   234 			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
   245 			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
   235 				// next argument should a be method
   246 				// next argument should a be method
   309 				gLogLevel = LOG_LEVEL_FILE_DETAILS;
   320 				gLogLevel = LOG_LEVEL_FILE_DETAILS;
   310 			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
   321 			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
   311 				gLogLevel = DEFAULT_LOG_LEVEL;
   322 				gLogLevel = DEFAULT_LOG_LEVEL;
   312 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   323 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   313 				gLowMem = ETrue;
   324 				gLowMem = ETrue;
       
   325 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
       
   326 				rofslogfile = argv[i] + 9;
       
   327 			}
   314 			else {
   328 			else {
   315 #ifdef WIN32
   329 #ifdef WIN32
   316 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   330 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   317 #else
   331 #else
   318 				if(0 == access(argv[i],R_OK)){
   332 				if(0 == access(argv[i],R_OK)){
   568 		} while(temp != 0);
   582 		} while(temp != 0);
   569 		gSmrImage = EFalse;
   583 		gSmrImage = EFalse;
   570 	}
   584 	}
   571 	// Process Rofs Obey files.
   585 	// Process Rofs Obey files.
   572 	if(obeyFileName) {
   586 	if(obeyFileName) {
   573 		H.SetLogFile("ROFSBUILD.LOG");		
   587 		if (rofslogfile[rofslogfile.size()-1] == '\\' || rofslogfile[rofslogfile.size()-1] == '/')
       
   588 			rofslogfile += "ROFSBUILD.LOG";
       
   589 	 	H.SetLogFile(rofslogfile.c_str());
   574 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   590 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   575 		if (!reader->Open())
   591 		if (!reader->Open())
   576 			return KErrGeneral;
   592 			return KErrGeneral;
   577 
   593 
   578 		E32Rofs* RofsImage = 0;		// for image from obey file
   594 		E32Rofs* RofsImage = 0;		// for image from obey file