imgtools/romtools/rofsbuild/rofsbuild.cpp
author Zheng Shen <zheng.shen@nokia.com>
Wed, 13 Oct 2010 16:27:55 +0800
changeset 647 53d1ab72f5bc
parent 631 9435b9008a58
child 654 7c11c3d8d025
child 655 3f65fd25dfd4
permissions -rw-r--r--
ROM Tools 13.1.0.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     1
/*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     2
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     3
* All rights reserved.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     4
* This component and the accompanying materials are made available
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     6
* which accompanies this distribution, and is available
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     8
*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
     9
* Initial Contributors:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    10
* Nokia Corporation - initial contribution.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    11
*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    12
* Contributors:
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    13
*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    14
* Description: 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    15
*
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    16
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    17
#include <string.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    18
#include <stdlib.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    19
#include <f32file.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    20
#include "e32image.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    21
#include "h_utl.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    22
#include "h_ver.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    23
#include "r_obey.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    24
#include "r_driveimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    25
#include "r_driveutl.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    26
#include "r_coreimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    27
#include "parameterfileprocessor.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    28
#include "r_smrimage.h"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    29
//cache headers
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    30
#include "cache/cacheexception.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    31
#include "cache/cacheentry.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    32
#include "cache/cache.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    33
#include "cache/cachegenerator.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    34
#include "cache/cachevalidator.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    35
#include "cache/cacheablelist.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    36
#include "cache/cachemanager.hpp"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    37
#include <malloc.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    38
 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    39
#ifndef WIN32
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    40
#include <unistd.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    41
#include <strings.h>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    42
#include <fstream>
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    43
#define strnicmp strncasecmp
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    44
#define stricmp strcasecmp
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    45
#define _alloca alloca
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    46
#endif
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    47
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    48
static const TInt RofsbuildMajorVersion=2;
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
    49
static const TInt RofsbuildMinorVersion=14;
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
    50
static const TInt RofsbuildPatchVersion=1;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    51
static TBool SizeSummary=EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    52
static TPrintType SizeWhere=EAlways;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    53
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    54
static TInt gHeaderType=1;			// EPOC header
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    55
static TInt MAXIMUM_THREADS = 128;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    56
static TInt DEFAULT_THREADS = 8;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    57
ECompression gCompress=ECompressionUnknown;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    58
TUint  gCompressionMethod=0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    59
TInt gThreadNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    60
TInt gCPUNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    61
TBool gGenSymbols = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    62
TInt gCodePagingOverride = -1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    63
TInt gDataPagingOverride = -1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    64
TInt gLogLevel = 0;	// Information is logged based on logging level.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    65
// The default is 0. So all the existing logs are generated as if gLogLevel = 0.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    66
// If any extra information required, the log level must be appropriately supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    67
// Currrently, file details in ROM (like, file name in ROM & host, file size, whether
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    68
// the file is hidden etc) are logged when gLogLevel >= LOG_LEVEL_FILE_DETAILS.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    69
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    70
TBool gUseCoreImage = EFalse; // command line option for using core image file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    71
string gImageFilename = "";	// instead of obey file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    72
TBool gEnableStdPathWarning = EFalse;// for in-correct destination path warning(executables).
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    73
TBool gLowMem = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    74
extern TBool gDriveImage;		// to Support data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    75
string gDriveFilename = "";		// input drive oby filename.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    76
string filename;				// to store oby filename passed to Rofsbuild.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    77
TBool reallyHelp = EFalse;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    78
TBool gSmrImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    79
string gSmrFileName = "";
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
    80
static string cmdlogfile = "";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    81
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    82
//Cache global variables
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    83
bool gCache = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    84
bool gCleanCache = false;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    85
bool gNoCache = false;
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
    86
TBool gIsOBYUTF8 = EFalse;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    87
TBool gKeepGoing = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    88
void PrintVersion() {
631
9435b9008a58 ROM Tools 13.1.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
    89
	printf("\nROFSBUILD - Rofs/Datadrive image builder");
9435b9008a58 ROM Tools 13.1.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
    90
	printf(" V%d.%d.%d\n", RofsbuildMajorVersion, RofsbuildMinorVersion, RofsbuildPatchVersion);
9435b9008a58 ROM Tools 13.1.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
    91
	printf("%s\n\n", "Copyright (c) 1996-2010 Nokia Corporation.");
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    92
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    93
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    94
char HelpText[] = 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    95
	"Syntax: ROFSBUILD [options] obeyfilename(Rofs)\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    96
	"Option: -v verbose,  -?,  -s[log|screen|both] size summary\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    97
	"        -d<bitmask> set trace mask (DEB build only)\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    98
	"        -compress   compress executable files where possible\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
    99
	"        -j<digit> do the main job with <digit> threads\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   100
	"        -symbols generate symbol file\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   101
	"        -compressionmethod none|inflate|bytepair to set the compression\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   102
	"              none     uncompress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   103
	"              inflate  compress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   104
	"              bytepair compress the image.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   105
	"        -coreimage <core image file>\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   106
	"        -cache allow the ROFSBUILD to reuse/generate cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   107
	"        -nocache force the ROFSBUILD not to reuse/generate cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   108
	"        -cleancache permanently remove all cached executable files\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   109
	"        -datadrive=<drive obyfile1>,<drive obyfile2>,... for driveimage creation\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   110
	"              user can also input rofs oby file if required to generate both.\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   111
	"        -smr=<SMR obyfile1>,<SMR obyfile2>,... for SMR partition creation\n"
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   112
	"        -oby-charset=<charset> used character set in which OBY was written\n"
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   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.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   114
	"        -wstdpath   warn if destination path provided for a file is not the standard path\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   115
	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   116
"        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   117
"        -k     to enable keepgoing when duplicate files exist in oby\n"
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   118
"        -logfile=<fileName>           specify log file\n";
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   119
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   120
char ReallyHelpText[] =
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   121
"Log Level:\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   122
"        0  produce the default logs\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   123
"        1  produce file detail logs in addition to the default logs\n"
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   124
"        2  logs e32 header attributes in addition to the level 1 details\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   125
void processParamfile(const string& aFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   126
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   127
Process the command line arguments and prints the helpful message if none are supplied.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   128
@param argc    - No. of argument.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   129
@param *argv[] - Arguments value.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   130
*/ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   131
void processCommandLine(int argc, char *argv[], TBool paramFileFlag = EFalse) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   132
	// If "-argfile" option is passed to rofsbuild, then process the parameters
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   133
	// specified in parameter-file first and then the options passed from the command-line.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   134
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   135
	string ParamFileArg("-ARGFILE=");	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   136
	if(paramFileFlag == EFalse) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   137
		for (int count = 1; count<argc; count++) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   138
			string paramFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   139
			//strupr(argv[count]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   140
			if(strnicmp(argv[count],ParamFileArg.c_str(),ParamFileArg.length()) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   141
				paramFile.assign(&argv[count][ParamFileArg.length()]);									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   142
				processParamfile(paramFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   143
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   144
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   145
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   146
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   147
	int i = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   148
	while (i<argc) {		 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   149
#ifdef __LINUX__	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   150
		if (argv[i][0] == '-') 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   151
#else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   152
		if ((argv[i][0] == '-') || (argv[i][0] == '/'))
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   153
#endif
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   154
		{ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   155
			// switch
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   156
			if ((argv[i][1] & 0x20) == 'v')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   157
				H.iVerbose = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   158
			else if(strnicmp (argv[i], "-SMR=", 5) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   159
				if(argv[i][5]) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   160
					gSmrImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   161
					gSmrFileName.assign(&argv[i][5]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   162
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   163
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   164
					Print (EError, "SMR obey file is missing\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   165
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   166
			} else if (stricmp(argv[i], "-K") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   167
				gKeepGoing = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   168
			}else if (stricmp(argv[i], "-SYMBOLS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   169
				gGenSymbols = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   170
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   171
			else if (((argv[i][1] | 0x20) == 's') &&  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   172
				(((argv[i][2]| 0x20) == 'l')||((argv[i][2] | 0x20) == 's'))) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   173
					SizeSummary = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   174
					if ((argv[i][2]| 0x20) == 'l')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   175
						SizeWhere = ELog;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   176
					else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   177
						SizeWhere = EScreen;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   178
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   179
			else if (strnicmp(argv[i],ParamFileArg.c_str(),ParamFileArg.length()) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   180
				if (paramFileFlag){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   181
					string paramFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   182
					paramFile.assign(&argv[i][ParamFileArg.length()]);		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   183
					processParamfile(paramFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   184
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   185
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   186
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   187
					continue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   188
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   189
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   190
			else if (stricmp(argv[i], "-COMPRESS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   191
				gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   192
				gCompressionMethod = KUidCompressionDeflate;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   193
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   194
			else if(stricmp(argv[i], "-CACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   195
				gCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   196
				if(gCleanCache || gNoCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   197
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   198
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   199
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   200
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   201
			else if(stricmp(argv[i], "-NOCACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   202
				gNoCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   203
				if(gCleanCache || gCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   204
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   205
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   206
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   207
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   208
			else if(stricmp(argv[i], "-CLEANCACHE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   209
				gCleanCache = true;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   210
				if(gCache || gNoCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   211
				{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   212
					printf("Cache command line options are mutually exclusive, only one option can be used at a time\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   213
					exit(1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   214
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   215
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   216
			else if (strnicmp(argv[i], "-J",2) == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   217
				if(argv[i][2])
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   218
					gThreadNum = atoi(&argv[i][2]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   219
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   220
					printf("WARNING: The option should be like '-j4'.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   221
					gThreadNum = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   222
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   223
				if(gThreadNum <= 0 || gThreadNum > MAXIMUM_THREADS) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   224
					printf("WARNING: The number of concurrent jobs set by -j should be between 1 and 128. ");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   225
					if(gCPUNum > 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   226
						printf("WARNING: The number of processors %d is used as the number of concurrent jobs.\n", gCPUNum);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   227
						gThreadNum = gCPUNum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   228
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   229
					else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   230
						printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   231
						gThreadNum = DEFAULT_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   232
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   233
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   234
			}
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   235
			else if(strnicmp(argv[i], "-OBY-CHARSET=", 13) == 0)
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   236
			{
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   237
				if((stricmp(&argv[i][13], "UTF8")==0) || (stricmp(&argv[i][13], "UTF-8")==0))
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   238
					gIsOBYUTF8 = ETrue;
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   239
				else
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   240
					Print(EError, "Invalid encoding %s, default system internal encoding will be used.\n", &argv[i][13]);
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   241
			}
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   242
			else if (stricmp(argv[i], "-UNCOMPRESS") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   243
				gCompress = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   244
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   245
			else if( stricmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   246
				// next argument should a be method
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   247
				if( (i+1) >= argc || argv[i+1][0] == '-') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   248
					Print (EError, "Missing compression method! Set it to default (no compression)!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   249
					gCompressionMethod = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   250
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   251
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   252
					i++;					
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   253
					if( stricmp(argv[i], "NONE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   254
						gCompress = ECompressionUncompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   255
						gCompressionMethod = 0;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   256
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   257
					else if( stricmp(argv[i], "INFLATE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   258
						gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   259
						gCompressionMethod = KUidCompressionDeflate;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   260
					}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   261
					else if( stricmp(argv[i], "BYTEPAIR") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   262
						gCompress = ECompressionCompress;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   263
						gCompressionMethod = KUidCompressionBytePair;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   264
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   265
					else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   266
						Print (EError, "Unknown compression method! Set it to default (no compression)!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   267
						gCompress = ECompressionUnknown;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   268
						gCompressionMethod = 0;		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   269
					}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   270
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   271
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   272
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   273
			else if (stricmp(argv[i], "-COREIMAGE") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   274
				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   275
				gUseCoreImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   276
				// next argument should be image filename
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   277
				if ((i+1 >= argc) || argv[i+1][0] == '-')
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   278
					Print (EError, "Missing image file name");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   279
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   280
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   281
					gImageFilename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   282
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   283
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   284
			else if (strnicmp(argv[i], "-DATADRIVE=",11) == 0){  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   285
				if(argv[i][11])	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   286
					gDriveImage = ETrue; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   287
					gDriveFilename.assign(&argv[i][11]);	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   288
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   289
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   290
					Print (EError, "Drive obey file is missing\n"); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   291
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   292
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   293
			else if (argv[i][1] == '?') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   294
				reallyHelp = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   295
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   296
			else if (stricmp(argv[i], "-WSTDPATH") == 0)	{	// Warn if destination path provided for a executables are incorrect as per platsec.		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   297
				gEnableStdPathWarning = ETrue;						
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   298
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   299
			else if( stricmp(argv[i], "-LOGLEVEL") == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   300
				// next argument should a be loglevel
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   301
				if( (i+1) >= argc || argv[i+1][0] == '-') {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   302
					Print (EError, "Missing loglevel!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   303
					gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   304
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   305
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   306
					i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   307
					if (strcmp(argv[i], "2") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   308
						gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   309
					if (strcmp(argv[i], "1") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   310
						gLogLevel = LOG_LEVEL_FILE_DETAILS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   311
					else if (strcmp(argv[i], "0") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   312
						gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   313
					else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   314
						Print(EError, "Only loglevel 0, 1 or 2 is allowed!");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   315
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   316
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   317
			else if( stricmp(argv[i], "-LOGLEVEL2") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   318
				gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   319
			else if( stricmp(argv[i], "-LOGLEVEL1") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   320
				gLogLevel = LOG_LEVEL_FILE_DETAILS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   321
			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   322
				gLogLevel = DEFAULT_LOG_LEVEL;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   323
			else if (stricmp(argv[i], "-LOWMEM") == 0)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   324
				gLowMem = ETrue;
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   325
			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   326
				cmdlogfile = argv[i] + 9;
626
ac03b93ca9c4 ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents: 617
diff changeset
   327
			}
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   328
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   329
#ifdef WIN32
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   330
				Print (EWarning, "Unrecognised option %s\n",argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   331
#else
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   332
				if(0 == access(argv[i],R_OK)){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   333
					filename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   334
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   335
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   336
					Print (EWarning, "Unrecognised option %s\n",argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   337
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   338
#endif				
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   339
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   340
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   341
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   342
		else // Must be the obey filename
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   343
			filename.assign(argv[i]);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   344
		i++;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   345
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   346
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   347
	if (paramFileFlag)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   348
		return;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   349
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   350
	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   351
		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   352
			Print (EAlways, HelpText);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   353
			if (reallyHelp) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   354
				ObeyFileReader::KeywordHelp();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   355
				Print (EAlways, ReallyHelpText);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   356
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   357
			else if (filename.empty()){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   358
				Print(EAlways, "Obey filename is missing\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   359
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   360
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   361
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   362
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   363
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   364
Function to process parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   365
@param aFileName parameter-file name.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   366
*/
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   367
void processParamfile(const string& aFileName) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   368
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   369
	CParameterFileProcessor parameterFile(aFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   370
	// Invoke fuction "ParameterFileProcessor" to process parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   371
	if(parameterFile.ParameterFileProcessor()) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   372
		TUint noOfParameters = parameterFile.GetNoOfArguments();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   373
		char** parameters = parameterFile.GetParameters();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   374
		TBool paramFileFlag = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   375
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   376
		// Invoke function "processCommandLine" to process parameters read from parameter-file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   377
		processCommandLine(noOfParameters,parameters,paramFileFlag);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   378
	}	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   379
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   380
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   381
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   382
Main logic for data drive image creation. Called many types depending on no. of drive obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   383
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   384
@param aobeyFileName - Drive obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   385
@param alogfile      - log file name required for file system module.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   386
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   387
@return - returns the status, after processing the drive obey file.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   388
*/ 
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   389
TInt ProcessDataDriveMain(char* aobeyFileName, const char* alogfile) {
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   390
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   391
	ObeyFileReader *reader = new ObeyFileReader(aobeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   392
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   393
	if(!reader)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   394
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   395
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   396
	if(!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   397
		return KErrGeneral; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   398
		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   399
	CObeyFile* mainObeyFile = new CObeyFile(*reader);    
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   400
	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   401
	if(!mainObeyFile)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   402
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   403
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   404
	// Process data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   405
	// let's clear the TRomNode::sDefaultInitialAttr first, 'cause data drive is different from rom image
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   406
	TRomNode::sDefaultInitialAttr = 0; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   407
	TInt retstatus = mainObeyFile->ProcessDataDrive();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   408
	if (retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   409
		// Build a Data drive image using the description compiled into the CObeyFile object
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   410
		CDriveImage* userImage = new CDriveImage(mainObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   411
		if(userImage) {	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   412
			// Drive image creation.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   413
			retstatus = userImage->CreateImage(alogfile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   414
			if(retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   415
				Print (EAlways, "\nSuccessfully generated the Drive image : %s \n",mainObeyFile->iDriveFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   416
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   417
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   418
				Print (EError, "Failed to generate the Image : %s\n",mainObeyFile->iDriveFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   419
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   420
			delete userImage; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   421
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   422
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   423
			retstatus = KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   424
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   425
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   426
	// restore
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   427
	TRomNode::sDefaultInitialAttr = (TUint8)KEntryAttReadOnly;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   428
	cout << "\n-----------------------------------------------------------\n";
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   429
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   430
	delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   431
	delete reader;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   432
	return retstatus;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   433
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   434
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   435
TInt ProcessSmrImageMain(char* aObeyFileName, const char* /* alogfile */) {
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   436
	ObeyFileReader *reader = new ObeyFileReader(aObeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   437
	if(!reader)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   438
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   439
	if(!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   440
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   441
	TInt retstatus = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   442
	CObeyFile* mainObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   443
	CSmrImage* smrImage = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   444
	if(!mainObeyFile)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   445
		return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   446
	if(mainObeyFile->Process()) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   447
		smrImage = new CSmrImage(mainObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   448
		if(smrImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   449
			if((retstatus = smrImage->Initialise()) == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   450
				retstatus = smrImage->CreateImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   451
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   452
			if(retstatus == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   453
				Print (EAlways,  "\nSuccessfully generated the SMR image : %s\n" ,smrImage->GetImageName().c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   454
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   455
			else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   456
				Print (EError, "\nFailed to generate the Image : %s\n" ,smrImage->GetImageName().c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   457
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   458
			delete smrImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   459
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   460
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   461
			retstatus = KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   462
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   463
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   464
	delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   465
	delete reader;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   466
	return retstatus;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   467
}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   468
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   469
/**
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   470
Rofsbuild Main function, which creates both Rofs and Data drive image.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   471
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   472
@param argc    - No. of argument.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   473
@param *argv[] - Arguments value.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   474
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   475
@return - returns the status to caller.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   476
*/ 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   477
TInt main(int argc, char *argv[]){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   478
	TInt r =0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   479
#ifdef __LINUX__
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   480
	gCPUNum = sysconf(_SC_NPROCESSORS_CONF);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   481
#else	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   482
	char* pCPUNum = getenv ("NUMBER_OF_PROCESSORS");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   483
	if (pCPUNum != NULL)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   484
		gCPUNum = atoi(pCPUNum);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   485
#endif		
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   486
	if(gCPUNum > MAXIMUM_THREADS)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   487
		gCPUNum = MAXIMUM_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   488
	PrintVersion();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   489
	processCommandLine(argc, argv);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   490
	//if the user wants to clean up the cache, do it only.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   491
	if(gCleanCache){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   492
		try {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   493
			CacheManager::GetInstance()->CleanCache();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   494
			Print (EAlways, "Cache has been deleted successfully.\n");
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   495
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   496
		catch(CacheException& ce){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   497
			Print (EError, "%s\n", ce.GetErrorMessage());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   498
			return (TInt)1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   499
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   500
		return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   501
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   502
	//initialize cache if the user switches on.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   503
	if(gCache) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   504
		try {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   505
			CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   506
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   507
		catch(CacheException ce){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   508
			Print (EError, "%s\n", ce.GetErrorMessage());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   509
			return (TInt)1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   510
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   511
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   512
	const char *obeyFileName = 0;	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   513
	if(!filename.empty())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   514
		obeyFileName = filename.c_str(); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   515
	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   516
		return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   517
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   518
	if(gThreadNum == 0) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   519
		if(gCPUNum > 0) {
631
9435b9008a58 ROM Tools 13.1.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   520
			printf("WARNING: The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   521
			gThreadNum = gCPUNum;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   522
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   523
		else {
631
9435b9008a58 ROM Tools 13.1.0.1
Zheng Shen <zheng.shen@nokia.com>
parents: 626
diff changeset
   524
			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   525
			gThreadNum = DEFAULT_THREADS;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   526
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   527
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   528
	// Process drive obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   529
	if(gDriveImage) {  
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   530
		char temp = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   531
		char *driveobeyFileName = (char*)_alloca(gDriveFilename.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   532
		memcpy(driveobeyFileName,gDriveFilename.c_str(),gDriveFilename.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   533
		char* ptr = driveobeyFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   534
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   535
			while(((temp = *ptr++) != ',') && (temp != 0));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   536
			*(--ptr)++ = 0; 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   537
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   538
			if(*driveobeyFileName) {
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   539
				string logfile = Getlogfile(driveobeyFileName, cmdlogfile);
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   540
				if(logfile.size() > 0) {
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   541
					H.SetLogFile(logfile.c_str());
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   542
					GetLocalTime();
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   543
					r = ProcessDataDriveMain(driveobeyFileName,logfile.c_str());   
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   544
					H.CloseLogFile();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   545
					if(r == KErrNoMemory)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   546
						return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   547
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   548
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   549
					Print(EError,"Invalid obey file name : %s\n", driveobeyFileName);   
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   550
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   551
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   552
			driveobeyFileName = ptr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   553
		} while(temp != 0); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   554
		gDriveImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   555
	} 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   556
	if(gSmrImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   557
		char temp = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   558
		char *smrImageObeyFileName = (char*)_alloca(gSmrFileName.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   559
		memcpy(smrImageObeyFileName,gSmrFileName.c_str(),gSmrFileName.length() + 1);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   560
		char* ptr = smrImageObeyFileName;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   561
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   562
			while(((temp = *ptr++) != ',') && (temp != 0));
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   563
			*(--ptr)++ = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   564
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   565
			if(*smrImageObeyFileName){	
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   566
				string logfile = Getlogfile(smrImageObeyFileName, cmdlogfile);
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   567
				if(logfile.size() > 0) {
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   568
					H.SetLogFile(logfile.c_str());
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   569
					GetLocalTime();
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   570
					r = ProcessSmrImageMain(smrImageObeyFileName, logfile.c_str());
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   571
					H.CloseLogFile();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   572
					if(r == KErrNoMemory)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   573
						return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   574
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   575
				else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   576
					Print(EError,"Invalid obey file name: %s", smrImageObeyFileName);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   577
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   578
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   579
			smrImageObeyFileName = ptr;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   580
		} while(temp != 0);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   581
		gSmrImage = EFalse;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   582
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   583
	// Process Rofs Obey files.
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   584
	if(obeyFileName) {
647
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   585
		if (cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/')
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   586
			cmdlogfile += "ROFSBUILD.LOG";
53d1ab72f5bc ROM Tools 13.1.0.4
Zheng Shen <zheng.shen@nokia.com>
parents: 631
diff changeset
   587
	 	H.SetLogFile(cmdlogfile.c_str());
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   588
		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   589
		if (!reader->Open())
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   590
			return KErrGeneral;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   591
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   592
		E32Rofs* RofsImage = 0;		// for image from obey file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   593
		CCoreImage *core = 0;		// for image from core image file
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   594
		MRofsImage* imageInfo = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   595
		CObeyFile *mainObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   596
		// need check if obey file has coreimage keyword
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   597
		char *file = mainObeyFile->ProcessCoreImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   598
		if (file) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   599
			// hase coreimage keyword but only use if command line option
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   600
			// for coreimage not already selected
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   601
			if (!gUseCoreImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   602
				gUseCoreImage = ETrue;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   603
				gImageFilename = file;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   604
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   605
			delete []file ;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   606
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   607
		if (!gUseCoreImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   608
			r = mainObeyFile->ProcessRofs();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   609
			if (r == KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   610
				// Build a ROFS image using the description compiled into the CObeyFile object
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   611
				RofsImage = new E32Rofs( mainObeyFile );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   612
				if( !RofsImage ) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   613
					if(gCache || gCleanCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   614
						delete CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   615
					return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   616
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   617
				r = RofsImage->Create();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   618
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   619
				if( KErrNone == r )	{
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   620
					RofsImage->WriteImage( gHeaderType );
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   621
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   622
				imageInfo = RofsImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   623
				mainObeyFile->Release();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   624
				if(gCache || gCleanCache)
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   625
					delete CacheManager::GetInstance();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   626
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   627
			else if (r != KErrNotFound){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   628
				return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   629
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   630
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   631
		else {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   632
			// need to use core image
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   633
			RCoreImageReader *reader = new RCoreImageReader(gImageFilename.c_str());
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   634
			if (!reader) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   635
				return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   636
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   637
			core = new CCoreImage(reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   638
			if (!core) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   639
				return KErrNoMemory;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   640
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   641
			r = core->ProcessImage();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   642
			if (r != KErrNone) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   643
				return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   644
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   645
			imageInfo = core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   646
			mainObeyFile->SkipToExtension();
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   647
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   648
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   649
		do {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   650
			CObeyFile* extensionObeyFile = new CObeyFile(*reader);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   651
			r = extensionObeyFile->ProcessExtensionRofs(imageInfo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   652
			if (r == KErrEof){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   653
				if(RofsImage){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   654
					delete RofsImage;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   655
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   656
				if(core){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   657
					delete core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   658
				}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   659
				delete extensionObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   660
				return KErrNone;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   661
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   662
			if (r != KErrNone){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   663
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   664
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   665
			E32Rofs* extensionRofs = new E32Rofs(extensionObeyFile);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   666
			r = extensionRofs->CreateExtension(imageInfo);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   667
			if (r!= KErrNone){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   668
				delete extensionRofs;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   669
				delete extensionObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   670
				break;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   671
			}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   672
			r = extensionRofs->WriteImage(0);	
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   673
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   674
			delete extensionRofs;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   675
			extensionRofs = 0;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   676
		} while (r == KErrNone);
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   677
		if(RofsImage) {
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   678
			delete RofsImage;									
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   679
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   680
		if(core){
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   681
			delete core;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   682
		}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   683
		delete mainObeyFile;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   684
	}
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   685
	return r;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 0
diff changeset
   686
}//end of main.