51
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Class representing a module in project (sbs2)
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "../inc/CATModule2.h"
|
|
20 |
#include "../inc/CATProject.h"
|
|
21 |
#include "../inc/CATDatParser.h"
|
|
22 |
#include "../inc/CATMemoryAddress.h"
|
|
23 |
#include "../inc/catdbghelper.h"
|
|
24 |
#include "../inc/cataddr2line.h"
|
|
25 |
|
|
26 |
CATModule2::CATModule2(void)
|
|
27 |
{
|
|
28 |
LOG_FUNC_ENTRY("CATModule2::CATModule2");
|
|
29 |
m_bAddressToLineInitialized = false;
|
|
30 |
m_bS60FileNameResolved = false;
|
|
31 |
m_pAddressToLine = 0;
|
|
32 |
m_sErrors = "";
|
|
33 |
m_sMakeFile = "";
|
|
34 |
m_eBuildSystem = CATProject::SBS_V1;
|
|
35 |
m_sCompileInfoText = "";
|
|
36 |
}
|
|
37 |
|
|
38 |
CATModule2::~CATModule2(void)
|
|
39 |
{
|
|
40 |
LOG_FUNC_ENTRY("CATModule2::~CATModule2");
|
|
41 |
if ( m_pAddressToLine )
|
|
42 |
m_pAddressToLine->Close();
|
|
43 |
delete m_pAddressToLine;
|
|
44 |
}
|
|
45 |
|
|
46 |
bool CATModule2::AddressToLine( CATMemoryAddress* pMemoryAddress )
|
|
47 |
{
|
|
48 |
LOG_FUNC_ENTRY("CATModule2::AddressToLine");
|
|
49 |
if ( _stricmp( m_sVariantPlatform.c_str(), "winscw" ) == 0 )
|
|
50 |
{
|
|
51 |
return AddressToLineWinscw( pMemoryAddress );
|
|
52 |
}
|
|
53 |
else if ( _stricmp( m_sVariantPlatform.c_str(), "armv5" ) == 0 )
|
|
54 |
{
|
|
55 |
// addr2line exe.
|
|
56 |
#ifdef ADDR2LINE
|
|
57 |
return AddressToLineAddr2lineExe( pMemoryAddress );
|
|
58 |
#endif
|
|
59 |
// lst and map files.
|
|
60 |
#ifndef ADDR2LINE
|
|
61 |
return AddressToLineArmv5( pMemoryAddress );
|
|
62 |
#endif
|
|
63 |
}
|
|
64 |
else if ( _stricmp( m_sVariantPlatform.c_str(), "gcce" ) == 0 )
|
|
65 |
{
|
|
66 |
return AddressToLineAddr2lineExe( pMemoryAddress );
|
|
67 |
}
|
|
68 |
return false;
|
|
69 |
}
|
|
70 |
|
|
71 |
bool CATModule2::AddressToLineWinscw( CATMemoryAddress* pMemoryAddress )
|
|
72 |
{
|
|
73 |
LOG_FUNC_ENTRY("CATModule2::AddressToLineWinscw( CATMemoryAddress* pMemoryAddress )");
|
|
74 |
if ( m_pAddressToLine == 0 && ! m_bAddressToLineInitialized )
|
|
75 |
{
|
|
76 |
// Use debug helper to locate codelines on winscw platform.
|
|
77 |
m_pAddressToLine = new CATDbgHelper();
|
|
78 |
|
|
79 |
// Create full path to binary which we open using CATDbgHelper.
|
|
80 |
string sFullPathToBinary = GetBinaryFile();
|
|
81 |
|
|
82 |
// If opening of binary not succesfull set return value to false.
|
|
83 |
if ( ! m_pAddressToLine->Open( sFullPathToBinary, pMemoryAddress->GetModuleStartAddress() ) )
|
|
84 |
{
|
|
85 |
LOG_STRING("Error, m_pAddressToLine->Open()");
|
|
86 |
return false;
|
|
87 |
}
|
|
88 |
m_bAddressToLineInitialized = true;
|
|
89 |
}
|
|
90 |
// Check pointer before calling.
|
|
91 |
if ( m_pAddressToLine == 0 )
|
|
92 |
return false;
|
|
93 |
m_pAddressToLine->AddressToLine( pMemoryAddress );
|
|
94 |
return true;
|
|
95 |
}
|
|
96 |
|
|
97 |
bool CATModule2::AddressToLineArmv5( CATMemoryAddress* pMemoryAddress )
|
|
98 |
{
|
|
99 |
LOG_FUNC_ENTRY("CATModule2::AddressToLine( CATMemoryAddress* pMemoryAddress )");
|
|
100 |
if ( ! m_bAddressToLineInitialized )
|
|
101 |
return false;
|
|
102 |
// Find from map file
|
|
103 |
int iMapIndex = GetSymbolIndexUsingAddress( pMemoryAddress->GetOffSetFromModuleStart() );
|
|
104 |
if ( iMapIndex == -1 )
|
|
105 |
{
|
|
106 |
pMemoryAddress->SetAddressToLineState( CATMemoryAddress::OUT_OF_RANGE );
|
|
107 |
return true;
|
|
108 |
}
|
|
109 |
// Set symbol name
|
|
110 |
string sSymbolName = m_vMapFileFuncList.at( iMapIndex ).sFunctionName;
|
|
111 |
|
|
112 |
// Remove (... from symbol name
|
|
113 |
string sSymbolNameRefined( sSymbolName );
|
|
114 |
size_t iPos = sSymbolNameRefined.find( "(" );
|
|
115 |
if ( iPos != string::npos )
|
|
116 |
sSymbolNameRefined.resize( iPos );
|
|
117 |
|
|
118 |
// Set symbol name as function name for memory address
|
|
119 |
pMemoryAddress->SetFunctionName( sSymbolNameRefined );
|
|
120 |
|
|
121 |
// Set state to symbol
|
|
122 |
pMemoryAddress->SetAddressToLineState( CATMemoryAddress::SYMBOL );
|
|
123 |
|
|
124 |
// Offset from function start addr
|
|
125 |
int iOffSetFromFuncStart = pMemoryAddress->GetOffSetFromModuleStart()
|
|
126 |
- m_vMapFileFuncList.at( iMapIndex ).iAddress;
|
|
127 |
|
|
128 |
// Find from lst list
|
|
129 |
int iLstIndex = GetLineInFileIndexUsingSymbolName( sSymbolName );
|
|
130 |
if ( iLstIndex == -1 )
|
|
131 |
return true;
|
|
132 |
|
|
133 |
// Set pinpointing
|
|
134 |
int iFuncLineNumber = m_vLineInFile.at( iLstIndex ).iLine;
|
|
135 |
string sFileName = m_vLineInFile.at( iLstIndex ).sFileName;
|
|
136 |
string sLstFileName = m_vLineInFile.at( iLstIndex ).sLstName;
|
|
137 |
|
|
138 |
pMemoryAddress->SetFunctionLineNumber( iFuncLineNumber );
|
|
139 |
pMemoryAddress->SetFileName( sFileName );
|
|
140 |
|
|
141 |
pMemoryAddress->SetAddressToLineState( CATMemoryAddress::FUNCTION );
|
|
142 |
|
|
143 |
// In urel mode don't get exact code line
|
|
144 |
if ( ! IsUDEB() )
|
|
145 |
return true;
|
|
146 |
|
|
147 |
// Next calculate the code line inside function
|
|
148 |
int iExactLineNumber = FindLeakCodeLine( sLstFileName, iFuncLineNumber, iOffSetFromFuncStart );
|
|
149 |
pMemoryAddress->SetExactLineNumber( iExactLineNumber );
|
|
150 |
|
|
151 |
// State is now exact
|
|
152 |
pMemoryAddress->SetAddressToLineState( CATMemoryAddress::EXACT );
|
|
153 |
return true;
|
|
154 |
}
|
|
155 |
|
|
156 |
bool CATModule2::AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress )
|
|
157 |
{
|
|
158 |
LOG_FUNC_ENTRY("CATModule2::AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress )");
|
|
159 |
if ( m_pAddressToLine == 0 && ! m_bAddressToLineInitialized )
|
|
160 |
{
|
|
161 |
// Use addr2line.exe to locate codelines on armv5 and gcce platform.
|
|
162 |
m_pAddressToLine = new CATAddr2line();
|
|
163 |
|
|
164 |
// Create full path to binary .sym file which we open using addr2line.exe.
|
|
165 |
string sFullPathToBinary = GetBinaryFile();
|
|
166 |
|
|
167 |
// If opening of binary not succesfull set return value to false.
|
|
168 |
if ( ! m_pAddressToLine->Open( sFullPathToBinary, pMemoryAddress->GetModuleStartAddress() ) )
|
|
169 |
{
|
|
170 |
LOG_STRING("Error, m_pAddressToLine->Open()");
|
|
171 |
return false;
|
|
172 |
}
|
|
173 |
m_bAddressToLineInitialized = true;
|
|
174 |
}
|
|
175 |
// Check pointer before calling.
|
|
176 |
if ( m_pAddressToLine == 0 )
|
|
177 |
return false;
|
|
178 |
|
|
179 |
m_pAddressToLine->AddressToLine( pMemoryAddress );
|
|
180 |
return true;
|
|
181 |
}
|
|
182 |
|
|
183 |
// Find symbol of given address
|
|
184 |
int CATModule2::GetSymbolIndexUsingAddress( unsigned long iAddress ) const
|
|
185 |
{
|
|
186 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetSymbolIndexUsingAddress");
|
|
187 |
for( size_t i = 0; i < m_vMapFileFuncList.size(); i++ )
|
|
188 |
{
|
|
189 |
unsigned long iStart = m_vMapFileFuncList.at( i ).iAddress;
|
|
190 |
unsigned long iEnd = ( m_vMapFileFuncList.at( i ).iAddress
|
|
191 |
+ m_vMapFileFuncList.at( i ).iFuncLength );
|
|
192 |
|
|
193 |
if ( iAddress >= iStart && iAddress < iEnd )
|
|
194 |
return (int) i;
|
|
195 |
}
|
|
196 |
return -1;
|
|
197 |
}
|
|
198 |
|
|
199 |
// Find index of function line in file vector of given symbolname
|
|
200 |
int CATModule2::GetLineInFileIndexUsingSymbolName( const string& sSymbolName ) const
|
|
201 |
{
|
|
202 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetLineInFileIndexUsingSymbolName");
|
|
203 |
for( size_t i = 0; i < m_vLineInFile.size(); i++ )
|
|
204 |
{
|
|
205 |
string sLineInFileName = m_vLineInFile.at( i ).sFunction;
|
|
206 |
if( sLineInFileName.find( sSymbolName ) != string::npos )
|
|
207 |
{
|
|
208 |
return (int) i;
|
|
209 |
}
|
|
210 |
}
|
|
211 |
return -1;
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
// Check does modules symbol file(s) exist.
|
|
216 |
bool CATModule2::SymbolFileExist( void )
|
|
217 |
{
|
|
218 |
LOG_FUNC_ENTRY("CATModule2::SymbolFileExist");
|
|
219 |
string sFullPathToSym = GetSymbolFile();
|
|
220 |
if ( !FileExists( sFullPathToSym.c_str() ) )
|
|
221 |
{
|
|
222 |
// Add missing symbol file to error string.
|
|
223 |
m_sErrors.append( "Missing symbol file: " );
|
|
224 |
m_sErrors.append( sFullPathToSym );
|
|
225 |
m_sErrors.append( "\n" );
|
|
226 |
return false;
|
|
227 |
}
|
|
228 |
return true;
|
|
229 |
}
|
|
230 |
|
|
231 |
// Check does modules map file(s) exists.
|
|
232 |
bool CATModule2::MapFileExist( void )
|
|
233 |
{
|
|
234 |
LOG_FUNC_ENTRY("CATModule2::MapFileExist");
|
|
235 |
string sFullPathToMap = GetMapFile();
|
|
236 |
if ( !FileExists( sFullPathToMap.c_str() ) )
|
|
237 |
{
|
|
238 |
// Add missing symbol file to error string.
|
|
239 |
m_sErrors.append( "Missing map file: " );
|
|
240 |
m_sErrors.append( sFullPathToMap );
|
|
241 |
m_sErrors.append( "\n" );
|
|
242 |
return false;
|
|
243 |
}
|
|
244 |
return true;
|
|
245 |
}
|
|
246 |
|
|
247 |
//Check does modules binary file(s) exist.
|
|
248 |
bool CATModule2::BinaryFileExist( void )
|
|
249 |
{
|
|
250 |
LOG_FUNC_ENTRY("CATModule2::BinaryFileExist");
|
|
251 |
string sFullPathToBinary = GetBinaryFile();
|
|
252 |
if ( ! FileExists( sFullPathToBinary.c_str() ) )
|
|
253 |
{
|
|
254 |
// Add missing binary to error string.
|
|
255 |
m_sErrors.append( "Missing binary file: " );
|
|
256 |
m_sErrors.append( sFullPathToBinary );
|
|
257 |
m_sErrors.append( "\n" );
|
|
258 |
return false;
|
|
259 |
}
|
|
260 |
return true;
|
|
261 |
}
|
|
262 |
|
|
263 |
void CATModule2::AddSource(const string &sSourceFile, const string& sLstFile)
|
|
264 |
{
|
|
265 |
LOG_LOW_FUNC_ENTRY("CATModule2::AddSource");
|
|
266 |
// Parse sources which are separated by spaces
|
|
267 |
if( sSourceFile.length() < 1 || sLstFile.length() < 1 )
|
|
268 |
return;
|
|
269 |
|
|
270 |
// Skip if its temporary cpp.
|
|
271 |
if ( sSourceFile.find( AT_TEMP_CPP_LOWER_START) != string::npos )
|
|
272 |
return;
|
|
273 |
|
|
274 |
// Source structure
|
|
275 |
SOURCE sNew;
|
|
276 |
sNew.sCpp = sSourceFile;
|
|
277 |
sNew.sLst = sLstFile;
|
|
278 |
|
|
279 |
// Verify paths.
|
|
280 |
ConvertUnixPathToWin( sNew.sCpp );
|
|
281 |
ConvertUnixPathToWin( sNew.sLst );
|
|
282 |
|
|
283 |
// Lower case them.
|
|
284 |
ChangeToLower( sNew.sCpp );
|
|
285 |
ChangeToLower( sNew.sLst );
|
|
286 |
|
|
287 |
// Add it
|
|
288 |
m_vSources.push_back( sNew );
|
|
289 |
}
|
|
290 |
|
|
291 |
void CATModule2::AddSources(string& sSource)
|
|
292 |
{
|
|
293 |
LOG_LOW_FUNC_ENTRY("CATModule2::AddSources");
|
|
294 |
// Parse sources which are separated by spaces
|
|
295 |
if( sSource.length() < 1 )
|
|
296 |
return;
|
|
297 |
// Source structure
|
|
298 |
SOURCE sNew;
|
|
299 |
size_t iSpot = string::npos;
|
|
300 |
iSpot = sSource.find( " " );
|
|
301 |
while( iSpot != string::npos )
|
|
302 |
{
|
|
303 |
// Pickup source
|
|
304 |
sNew.sCpp = sSource.substr(0, iSpot);
|
|
305 |
// Convert path from Unix to Win
|
|
306 |
ConvertUnixPathToWin( sNew.sCpp );
|
|
307 |
// Lowercase it
|
|
308 |
ChangeToLower( sNew.sCpp );
|
|
309 |
// If its temp skip this
|
|
310 |
if ( sNew.sCpp.find( AT_TEMP_CPP_LOWER_START ) == string::npos )
|
|
311 |
{
|
|
312 |
// Get corresponding lst file for source
|
|
313 |
sNew.sLst = GetLstNameOfSource( sNew.sCpp );
|
|
314 |
m_vSources.push_back( sNew );
|
|
315 |
// Remove it from sSource
|
|
316 |
sSource.erase(0,iSpot+1);
|
|
317 |
// Find new one
|
|
318 |
}
|
|
319 |
iSpot = sSource.find( " " );
|
|
320 |
}
|
|
321 |
// Pickup last or only one source
|
|
322 |
sNew.sCpp = sSource;
|
|
323 |
// Convert path from unix to win
|
|
324 |
ConvertUnixPathToWin( sNew.sCpp );
|
|
325 |
// Lowercase it
|
|
326 |
ChangeToLower( sNew.sCpp );
|
|
327 |
// Lst name
|
|
328 |
sNew.sLst = GetLstNameOfSource( sNew.sCpp );
|
|
329 |
if ( sNew.sCpp.find( AT_TEMP_CPP_LOWER_START ) == string::npos )
|
|
330 |
{
|
|
331 |
// Get corresponding lst file for source
|
|
332 |
sNew.sLst = GetLstNameOfSource( sNew.sCpp );
|
|
333 |
m_vSources.push_back( sNew );
|
|
334 |
}
|
|
335 |
}
|
|
336 |
bool CATModule2::CreateTempCpp(const string& sS60FileName
|
|
337 |
, const string& sS60FilePath
|
|
338 |
, int eLoggingMode
|
|
339 |
, int eBuildType
|
|
340 |
, int iAllocCallStackSize
|
|
341 |
, int iFreeCallStackSize )
|
|
342 |
{
|
|
343 |
LOG_FUNC_ENTRY("CATModule2::CreateTemporaryCpp");
|
|
344 |
|
|
345 |
// Make s60 filename target.type.dat if its empty and logging mode is file
|
|
346 |
if ( eLoggingMode == CATProject::FILE )
|
|
347 |
{
|
|
348 |
// S60 filename
|
|
349 |
SetS60FileName( sS60FileName );
|
|
350 |
|
|
351 |
// S60 filepath
|
|
352 |
// use double slashes in temp cpp file
|
|
353 |
m_sS60FilePath = sS60FilePath;
|
|
354 |
int iIgnore(0);
|
|
355 |
size_t iPos = m_sS60FilePath.find("\\", iIgnore );
|
|
356 |
while( iPos != string::npos )
|
|
357 |
{
|
|
358 |
m_sS60FilePath.replace( iPos, 1, "\\\\" );
|
|
359 |
// dont replace previously replaced slashes
|
|
360 |
iIgnore = iPos + 2;
|
|
361 |
iPos = m_sS60FilePath.find("\\", iIgnore );
|
|
362 |
}
|
|
363 |
|
|
364 |
|
|
365 |
}
|
|
366 |
return CreateTemporaryCpp( GetUniqueId(), m_sTempPath,
|
|
367 |
m_sS60FileName, m_sS60FilePath, eLoggingMode, eBuildType, iAllocCallStackSize, iFreeCallStackSize );
|
|
368 |
}
|
|
369 |
|
|
370 |
bool CATModule2::ModifyMmp()
|
|
371 |
{
|
|
372 |
LOG_FUNC_ENTRY("CATModule2::ModifyMmp");
|
|
373 |
// Create backup
|
|
374 |
if ( ! m_Mmp.BackupMmpFile() )
|
|
375 |
return false;
|
|
376 |
// Hook
|
|
377 |
return m_Mmp.EditMmpFile( m_sTargetType, GetUniqueId() );
|
|
378 |
}
|
|
379 |
|
|
380 |
bool CATModule2::RestoreMmp()
|
|
381 |
{
|
|
382 |
LOG_FUNC_ENTRY("CATModule2::RestoreMmp");
|
|
383 |
// Restore mmp from backup
|
|
384 |
return m_Mmp.RestoreMmpFile();
|
|
385 |
}
|
|
386 |
|
|
387 |
bool CATModule2::VerifyAndRecoverMmp()
|
|
388 |
{
|
|
389 |
LOG_FUNC_ENTRY("CATModule2::VerifyAndRecoverMmp");
|
|
390 |
// Verify mmp
|
|
391 |
return m_Mmp.VerifyAndRecover();
|
|
392 |
}
|
|
393 |
|
|
394 |
// ----------------------------------------------------------------------------
|
|
395 |
// Releasables Handling methos
|
|
396 |
// ----------------------------------------------------------------------------
|
|
397 |
bool CATModule2::CopyReleasables()
|
|
398 |
{
|
|
399 |
LOG_FUNC_ENTRY("CATModule2::CopyReleasables");
|
|
400 |
bool bRet = true;
|
|
401 |
if ( ! CopyLstFilesToTemp() )
|
|
402 |
bRet = false;
|
|
403 |
if ( ! CopyMapFileToTemp() )
|
|
404 |
bRet = false;
|
|
405 |
return bRet;
|
|
406 |
}
|
|
407 |
|
|
408 |
bool CATModule2::CopyLstFilesToDir( const string& sDir )
|
|
409 |
{
|
|
410 |
LOG_FUNC_ENTRY("CATModule2::CopyLstFilesToDir");
|
|
411 |
bool bRet = true;
|
|
412 |
// Copy lst files to given directory.
|
|
413 |
vector<SOURCE>::const_iterator source;
|
|
414 |
for( source = m_vSources.begin(); source != m_vSources.end() ; source++ )
|
|
415 |
{
|
|
416 |
if ( ! FileCopyToPath( source->sLst, sDir ) )
|
|
417 |
{
|
|
418 |
if ( !FileExists( source->sLst.c_str() ) )
|
|
419 |
{
|
|
420 |
m_sErrors.append( "Missing listing file: " );
|
|
421 |
m_sErrors.append( source->sLst );
|
|
422 |
m_sErrors.append( "\n" );
|
|
423 |
}
|
|
424 |
if ( !DirectoryExists( sDir.c_str() ) )
|
|
425 |
{
|
|
426 |
m_sErrors.append( "Missing folder: " );
|
|
427 |
m_sErrors.append( sDir );
|
|
428 |
m_sErrors.append( "\n" );
|
|
429 |
}
|
|
430 |
bRet = false;
|
|
431 |
}
|
|
432 |
}
|
|
433 |
// Return.
|
|
434 |
return bRet;
|
|
435 |
}
|
|
436 |
|
|
437 |
bool CATModule2::CopyLstFilesToTemp()
|
|
438 |
{
|
|
439 |
LOG_FUNC_ENTRY("CATModule2::CopyLstFilesToTemp");
|
|
440 |
// Return boolean
|
|
441 |
bool bRet = true;
|
|
442 |
// Move all lst files except tmp cpp
|
|
443 |
vector<SOURCE>::iterator it = m_vSources.begin();
|
|
444 |
while ( it != m_vSources.end() )
|
|
445 |
{
|
|
446 |
if ( !FileCopyToPath( it->sLst, m_sTempPath ) )
|
|
447 |
{
|
|
448 |
if ( !FileExists( it->sLst.c_str() ) )
|
|
449 |
{
|
|
450 |
m_sErrors.append( "Missing listing file: " );
|
|
451 |
m_sErrors.append( it->sLst );
|
|
452 |
m_sErrors.append( "\n" );
|
|
453 |
}
|
|
454 |
if ( !DirectoryExists( m_sTempPath.c_str() ) )
|
|
455 |
{
|
|
456 |
m_sErrors.append( "Missing folder: " );
|
|
457 |
m_sErrors.append( m_sTempPath );
|
|
458 |
m_sErrors.append( "\n" );
|
|
459 |
}
|
|
460 |
bRet = false;
|
|
461 |
}
|
|
462 |
it++;
|
|
463 |
}
|
|
464 |
return bRet;
|
|
465 |
}
|
|
466 |
|
|
467 |
bool CATModule2::DeleteLstFilesFromSrc( void )
|
|
468 |
{
|
|
469 |
LOG_FUNC_ENTRY("CATModule2::DeleteLstFilesFromSrc");
|
|
470 |
vector<SOURCE>::iterator it = m_vSources.begin();
|
|
471 |
bool bRet = true;
|
|
472 |
// Delete lst files
|
|
473 |
while ( it != m_vSources.end() )
|
|
474 |
{
|
|
475 |
if ( ! FileDelete( it->sLst, true ) )
|
|
476 |
bRet = false;
|
|
477 |
it++;
|
|
478 |
}
|
|
479 |
return bRet;
|
|
480 |
}
|
|
481 |
|
|
482 |
bool CATModule2::CopyMapFileToTemp()
|
|
483 |
{
|
|
484 |
LOG_FUNC_ENTRY("CATModule2::CopyMapFileToTemp");
|
|
485 |
// Return boolean
|
|
486 |
bool bRet = true;
|
|
487 |
// Map File to copy
|
|
488 |
string sMapFile = GetMapFile();
|
|
489 |
if ( !FileCopyToPath( sMapFile, m_sTempPath ) )
|
|
490 |
{
|
|
491 |
bRet = false;
|
|
492 |
if ( !FileExists( sMapFile.c_str() ) )
|
|
493 |
{
|
|
494 |
// Add missing map file to error string.
|
|
495 |
m_sErrors.append( "Missing map file: " );
|
|
496 |
m_sErrors.append( sMapFile );
|
|
497 |
m_sErrors.append( "\n" );
|
|
498 |
}
|
|
499 |
if ( !DirectoryExists( m_sTempPath.c_str() ) )
|
|
500 |
{
|
|
501 |
// Add missing temporary folder
|
|
502 |
m_sErrors.append( "Missing folder: " );
|
|
503 |
m_sErrors.append( m_sTempPath );
|
|
504 |
m_sErrors.append( "\n" );
|
|
505 |
}
|
|
506 |
}
|
|
507 |
return bRet;
|
|
508 |
}
|
|
509 |
|
|
510 |
bool CATModule2::CleanTemporaryDir()
|
|
511 |
{
|
|
512 |
LOG_FUNC_ENTRY("CATModule2::CleanTemporaryDir");
|
|
513 |
bool bRet = true;
|
|
514 |
// Verify mmp
|
|
515 |
if ( ! m_Mmp.VerifyAndRecover() )
|
|
516 |
bRet = false;
|
|
517 |
// Clean temporary dir
|
|
518 |
vector<string> vFileList = DirList( m_sTempPath, false , true );
|
|
519 |
vector<string>::iterator it = vFileList.begin();
|
|
520 |
// Size of constant table
|
|
521 |
int iCount = sizeof( TEMP_EXTENSION_NO_DELETE ) / sizeof( string );
|
|
522 |
while ( it != vFileList.end() )
|
|
523 |
{
|
|
524 |
// Get extension and compare it to list
|
|
525 |
bool bDelete = true;
|
|
526 |
string sExtension = GetExtension( *it );
|
|
527 |
ChangeToLower( sExtension );
|
|
528 |
for ( int i = 0 ; i < iCount ; i++ )
|
|
529 |
{
|
|
530 |
if( sExtension.compare( TEMP_EXTENSION_NO_DELETE[i] ) == 0 )
|
|
531 |
{
|
|
532 |
bDelete = false;
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
}
|
|
536 |
if ( bDelete )
|
|
537 |
{
|
|
538 |
// Delete file
|
|
539 |
if ( ! FileDelete( *it, true ) )
|
|
540 |
bRet = false;
|
|
541 |
}
|
|
542 |
// Increment
|
|
543 |
it++;
|
|
544 |
}
|
|
545 |
return bRet;
|
|
546 |
}
|
|
547 |
|
|
548 |
bool CATModule2::DeleteTemporaryDir()
|
|
549 |
{
|
|
550 |
LOG_FUNC_ENTRY("CATModule2::DeleteTemporaryDir");
|
|
551 |
bool bRet = true;
|
|
552 |
// Verify mmp
|
|
553 |
if ( ! m_Mmp.VerifyAndRecover() )
|
|
554 |
bRet = false;
|
|
555 |
// Delete temp dir
|
|
556 |
if ( !DirDelete( m_sTempPath, true ) )
|
|
557 |
bRet = false;
|
|
558 |
return bRet;
|
|
559 |
}
|
|
560 |
|
|
561 |
bool CATModule2::IsUDEB() const
|
|
562 |
{
|
|
563 |
LOG_LOW_FUNC_ENTRY("CATModule2::IsUDEB");
|
|
564 |
// Determine from variant is this udeb
|
|
565 |
if ( m_sVariantType.find( "udeb" ) != string::npos )
|
|
566 |
return true;
|
|
567 |
return false;
|
|
568 |
}
|
|
569 |
// ----------------------------------------------------------------------------
|
|
570 |
// Private AddressToLine related methods
|
|
571 |
// ----------------------------------------------------------------------------
|
|
572 |
bool CATModule2::InitializeAddressToLine()
|
|
573 |
{
|
|
574 |
LOG_FUNC_ENTRY("CATModule2::InitializeAddressToLine");
|
|
575 |
bool bRet = true;
|
|
576 |
// Read in different way depending on platform
|
|
577 |
if ( m_sVariantPlatform.compare("armv5") == 0 )
|
|
578 |
{
|
|
579 |
// Add static library lst files to source vector,
|
|
580 |
// before reading them.
|
|
581 |
vector<string> vFiles = DirList( AT_TEMP_LST_DIR, false, true );
|
|
582 |
for(vector<string>::iterator it = vFiles.begin() ; it != vFiles.end() ; it ++ )
|
|
583 |
{
|
|
584 |
SOURCE source;
|
|
585 |
source.bStatic = true;
|
|
586 |
source.sLst = *it;
|
|
587 |
source.sCpp = *it;
|
|
588 |
source.sCpp = CATBase::RemovePathAndExt( source.sCpp, false );
|
|
589 |
source.sCpp.append( ".cpp" );
|
|
590 |
m_vSources.push_back( source );
|
|
591 |
}
|
|
592 |
|
|
593 |
if ( ! ReadListingFilesArmv5() )
|
|
594 |
bRet = false;
|
|
595 |
if ( ! ReadMapFileArmv5() )
|
|
596 |
bRet = false;
|
|
597 |
|
|
598 |
if ( bRet )
|
|
599 |
m_bAddressToLineInitialized = true;
|
|
600 |
}
|
|
601 |
return bRet;
|
|
602 |
}
|
|
603 |
|
|
604 |
|
|
605 |
bool CATModule2::ReadListingFilesArmv5()
|
|
606 |
{
|
|
607 |
LOG_FUNC_ENTRY("CATModule2::ReadListingFilesArmv5");
|
|
608 |
char cTemp[MAX_LINE_LENGTH];
|
|
609 |
vector<SOURCE>::iterator viFileIter = m_vSources.begin();
|
|
610 |
int iNumberOfLstFiles = (int)m_vSources.size();
|
|
611 |
vector<string> vTempLines;
|
|
612 |
string sFileName;
|
|
613 |
|
|
614 |
// Open all .lst files
|
|
615 |
while( iNumberOfLstFiles > 0 )
|
|
616 |
{
|
|
617 |
// Make .lst file name
|
|
618 |
sFileName.clear();
|
|
619 |
|
|
620 |
// If lst file is not from static library make path to modules temporary directory.
|
|
621 |
if ( viFileIter->bStatic != true )
|
|
622 |
{
|
|
623 |
// Remove path
|
|
624 |
if( viFileIter->sLst.find("\\") != string::npos )
|
|
625 |
sFileName.append(
|
|
626 |
viFileIter->sLst.substr( viFileIter->sLst.find_last_of( "\\" ) + 1
|
|
627 |
, viFileIter->sLst.size() ) );
|
|
628 |
else
|
|
629 |
sFileName.append( viFileIter->sLst );
|
|
630 |
|
|
631 |
// Add temporary dir
|
|
632 |
sFileName.insert( 0, m_sTempPath );
|
|
633 |
}
|
|
634 |
else
|
|
635 |
{
|
|
636 |
// Lst from static library don't change path.
|
|
637 |
sFileName = viFileIter->sLst;
|
|
638 |
}
|
|
639 |
// Open lst file
|
|
640 |
ifstream in( sFileName.c_str() );
|
|
641 |
|
|
642 |
// If file can not be opened, try to open next file
|
|
643 |
if( !in.good() )
|
|
644 |
{
|
|
645 |
viFileIter++;
|
|
646 |
iNumberOfLstFiles--;
|
|
647 |
continue;
|
|
648 |
}
|
|
649 |
|
|
650 |
string sTemp;
|
|
651 |
// Clear temporary lines
|
|
652 |
vTempLines.clear();
|
|
653 |
// Add all lines to temp list
|
|
654 |
do
|
|
655 |
{
|
|
656 |
in.getline( cTemp, MAX_LINE_LENGTH );
|
|
657 |
sTemp.clear();
|
|
658 |
sTemp.append( cTemp );
|
|
659 |
vTempLines.push_back( sTemp );
|
|
660 |
}
|
|
661 |
while( in.good() );
|
|
662 |
|
|
663 |
LINE_IN_FILE structLineInFile;
|
|
664 |
|
|
665 |
bool bFindENDP = false;
|
|
666 |
vector<string>::iterator viLinesIter = vTempLines.begin();
|
|
667 |
|
|
668 |
// Loop throw all lines in .lst file
|
|
669 |
while( viLinesIter != vTempLines.end() )
|
|
670 |
{
|
|
671 |
// Find ";;;"
|
|
672 |
if( !bFindENDP && strstr(viLinesIter->c_str(), ";;;") != NULL )
|
|
673 |
{
|
|
674 |
bFindENDP = true;
|
|
675 |
|
|
676 |
vector<string>::iterator viLineTempIter = viLinesIter;
|
|
677 |
|
|
678 |
// Find top line of function definition
|
|
679 |
while( viLineTempIter->size() > 0 )
|
|
680 |
{
|
|
681 |
viLineTempIter--;
|
|
682 |
}
|
|
683 |
viLineTempIter++;
|
|
684 |
structLineInFile.sFunction.clear();
|
|
685 |
structLineInFile.sFunction.append( viLineTempIter->c_str() );
|
|
686 |
|
|
687 |
viLinesIter++;
|
|
688 |
// Get Line
|
|
689 |
sTemp.clear();
|
|
690 |
sTemp.append( viLinesIter->c_str() );
|
|
691 |
sTemp.erase(0,3);
|
|
692 |
size_t iSize = sTemp.find_first_of(' ');
|
|
693 |
if( iSize != string::npos )
|
|
694 |
sTemp.resize(iSize);
|
|
695 |
structLineInFile.iLine = atoi( sTemp.c_str() );
|
|
696 |
|
|
697 |
structLineInFile.sFileName.clear();
|
|
698 |
structLineInFile.sFileName.append( viFileIter->sCpp.c_str() );
|
|
699 |
structLineInFile.sLstName = sFileName;
|
|
700 |
m_vLineInFile.push_back( structLineInFile );
|
|
701 |
}
|
|
702 |
else if( strstr(viLinesIter->c_str(), "ENDP") != NULL )
|
|
703 |
bFindENDP = false;
|
|
704 |
viLinesIter++;
|
|
705 |
}
|
|
706 |
viFileIter++;
|
|
707 |
iNumberOfLstFiles--;
|
|
708 |
}
|
|
709 |
if( m_vLineInFile.size() > 0 )
|
|
710 |
return true;
|
|
711 |
return false;
|
|
712 |
}
|
|
713 |
|
|
714 |
bool CATModule2::ReadMapFileArmv5()
|
|
715 |
{
|
|
716 |
LOG_FUNC_ENTRY("CATModule2::ReadMapFileArmv5");
|
|
717 |
// Map file name
|
|
718 |
string sMapFileName = GetMapFile();
|
|
719 |
// Remove path
|
|
720 |
if ( sMapFileName.find("\\") != string::npos )
|
|
721 |
sMapFileName.erase(0, sMapFileName.find_last_of('\\')+1 );
|
|
722 |
// Add temp path
|
|
723 |
sMapFileName.insert(0, m_sTempPath );
|
|
724 |
|
|
725 |
// Open .map file
|
|
726 |
ifstream in( sMapFileName.c_str() );
|
|
727 |
|
|
728 |
// File open ok?
|
|
729 |
if( ! in.good() )
|
|
730 |
{
|
|
731 |
in.close();
|
|
732 |
return false;
|
|
733 |
}
|
|
734 |
char cTemp[MAX_LINE_LENGTH];
|
|
735 |
bool bFirstFuncFound = false;
|
|
736 |
// Get all lines where is "Thumb"
|
|
737 |
do
|
|
738 |
{
|
|
739 |
// Load one line from .map file
|
|
740 |
in.getline( cTemp, MAX_LINE_LENGTH );
|
|
741 |
// Find _E32Startup
|
|
742 |
if( !bFirstFuncFound && ( strstr( cTemp, "_E32Startup" ) != NULL) )
|
|
743 |
{
|
|
744 |
bFirstFuncFound = true;
|
|
745 |
}
|
|
746 |
else if( !bFirstFuncFound && ( strstr( cTemp, "_E32Dll" ) != NULL) )
|
|
747 |
{
|
|
748 |
bFirstFuncFound = true;
|
|
749 |
}
|
|
750 |
else if( !bFirstFuncFound )
|
|
751 |
// Skip if _E32Startup not found
|
|
752 |
continue;
|
|
753 |
|
|
754 |
if( strstr( cTemp, "Thumb Code" ) != NULL || strstr( cTemp, "ARM Code" ) != NULL)
|
|
755 |
{
|
|
756 |
MAP_FUNC_INFO structMapFileLineInfo;
|
|
757 |
structMapFileLineInfo.sWholeLine.append( cTemp );
|
|
758 |
|
|
759 |
// Get memory string address from line
|
|
760 |
char* pStart = strstr( cTemp, "0x" );
|
|
761 |
// Check did strstr return null.
|
|
762 |
if( pStart == NULL )
|
|
763 |
continue;
|
|
764 |
char* pTemp = pStart;
|
|
765 |
char TempString[MAX_LINE_LENGTH];
|
|
766 |
TempString[0] = 0;
|
|
767 |
size_t iLength = 0;
|
|
768 |
while( *pTemp != ' ' )
|
|
769 |
{
|
|
770 |
TempString[iLength] = *pTemp;
|
|
771 |
pTemp++;
|
|
772 |
iLength++;
|
|
773 |
}
|
|
774 |
TempString[iLength] = 0;
|
|
775 |
|
|
776 |
structMapFileLineInfo.iAddress = CATDatParser::_httoi( TempString );
|
|
777 |
|
|
778 |
pTemp = cTemp;
|
|
779 |
TempString[0] = 0;
|
|
780 |
|
|
781 |
// Get function name
|
|
782 |
|
|
783 |
// Skip spaces
|
|
784 |
while( *pTemp == ' ' )
|
|
785 |
{
|
|
786 |
pTemp++;
|
|
787 |
}
|
|
788 |
iLength = 0;
|
|
789 |
// Find end of function name
|
|
790 |
string sTemp( pTemp );
|
|
791 |
|
|
792 |
// Location of character ')'
|
|
793 |
iLength = sTemp.find_first_of(')');
|
|
794 |
|
|
795 |
// Location of character ' '
|
|
796 |
size_t iLength2 = sTemp.find_first_of(' ');
|
|
797 |
|
|
798 |
// If ')' character is the last char and
|
|
799 |
// character ' ' is closer than ')' use location of ' '
|
|
800 |
if( ( iLength + 1 ) == sTemp.length() && iLength2 < iLength )
|
|
801 |
iLength = iLength2 - 1;
|
|
802 |
|
|
803 |
if( iLength != string::npos )
|
|
804 |
sTemp.resize( (iLength + 1) );
|
|
805 |
|
|
806 |
structMapFileLineInfo.sFunctionName.append( sTemp.c_str() );
|
|
807 |
|
|
808 |
bool bARM = false;
|
|
809 |
// Find function length
|
|
810 |
pStart = strstr( cTemp, "Thumb Code" );
|
|
811 |
if( pStart == NULL )
|
|
812 |
{
|
|
813 |
pStart = strstr( cTemp, "ARM Code" );
|
|
814 |
bARM = true;
|
|
815 |
}
|
|
816 |
if( pStart != NULL )
|
|
817 |
{
|
|
818 |
if( bARM )
|
|
819 |
pStart += 8;
|
|
820 |
else
|
|
821 |
pStart += 10;
|
|
822 |
while(*pStart == ' ')
|
|
823 |
{
|
|
824 |
pStart++;
|
|
825 |
}
|
|
826 |
sTemp.clear();
|
|
827 |
sTemp.append( pStart );
|
|
828 |
size_t iSize = sTemp.find_first_of(' ');
|
|
829 |
if( iSize != string::npos )
|
|
830 |
sTemp.resize( iSize );
|
|
831 |
}
|
|
832 |
|
|
833 |
structMapFileLineInfo.iFuncLength = atoi( sTemp.c_str() );
|
|
834 |
if( bFirstFuncFound && structMapFileLineInfo.iFuncLength > 0 )
|
|
835 |
// Save to list
|
|
836 |
m_vMapFileFuncList.push_back( structMapFileLineInfo );
|
|
837 |
}
|
|
838 |
}
|
|
839 |
while( in.good() );
|
|
840 |
in.close();
|
|
841 |
return true;
|
|
842 |
}
|
|
843 |
|
|
844 |
int CATModule2::FindLeakCodeLine( string& sFileName, int iLine, unsigned long iFromFuncAddress ) const
|
|
845 |
{
|
|
846 |
LOG_LOW_FUNC_ENTRY("CATModule2::FindLeakCodeLine");
|
|
847 |
if ( sFileName.empty() )
|
|
848 |
return -1;
|
|
849 |
char cLineFromFile[MAX_LINE_LENGTH];
|
|
850 |
vector<string> vTempLines;
|
|
851 |
string sTemp;
|
|
852 |
char* pTemp = NULL;
|
|
853 |
char* pTempEnd = NULL;
|
|
854 |
int iFoundLine = -1;
|
|
855 |
int iRet = -1;
|
|
856 |
|
|
857 |
// Open lst file
|
|
858 |
ifstream in( sFileName.c_str() );
|
|
859 |
|
|
860 |
bool bLineFound = false;
|
|
861 |
bool bFirstAddressInFuncFound = false;
|
|
862 |
unsigned long iFirstAddressInFunc = 0;
|
|
863 |
while( in.good() )
|
|
864 |
{
|
|
865 |
in.getline( cLineFromFile, MAX_LINE_LENGTH );
|
|
866 |
|
|
867 |
if( bLineFound )
|
|
868 |
{
|
|
869 |
vTempLines.push_back( cLineFromFile );
|
|
870 |
// Is first character digit
|
|
871 |
if( isdigit( cLineFromFile[0] ) )
|
|
872 |
{
|
|
873 |
if( !bFirstAddressInFuncFound )
|
|
874 |
{
|
|
875 |
bFirstAddressInFuncFound = true;
|
|
876 |
sTemp.clear();
|
|
877 |
sTemp.append( cLineFromFile );
|
|
878 |
// Get value until next space
|
|
879 |
sTemp.resize( sTemp.find_first_of(' ') );
|
|
880 |
|
|
881 |
iFirstAddressInFunc = CATDatParser::_httoi( sTemp.c_str() );
|
|
882 |
|
|
883 |
// Return function start line if margin 0
|
|
884 |
if( iFromFuncAddress == 0 )
|
|
885 |
{
|
|
886 |
iRet = iLine;
|
|
887 |
return iRet;
|
|
888 |
}
|
|
889 |
}
|
|
890 |
else
|
|
891 |
{
|
|
892 |
// Find correct line using iFromFuncAddress variable
|
|
893 |
sTemp.clear();
|
|
894 |
sTemp.append( cLineFromFile );
|
|
895 |
// Get value until next space
|
|
896 |
sTemp.resize( sTemp.find_first_of(' ') );
|
|
897 |
|
|
898 |
unsigned long iValue = CATDatParser::_httoi( sTemp.c_str() );
|
|
899 |
|
|
900 |
if( ( iValue - iFirstAddressInFunc ) >= iFromFuncAddress )
|
|
901 |
{
|
|
902 |
// If there is data in function, code line can not be found
|
|
903 |
if( strstr( cLineFromFile , "DCB" ) != NULL )
|
|
904 |
{
|
|
905 |
iRet = -1;
|
|
906 |
return iRet;
|
|
907 |
}
|
|
908 |
pTemp = strstr( cLineFromFile, ";" );
|
|
909 |
// Get line number
|
|
910 |
bool bStringNumber = true;
|
|
911 |
if( pTemp != NULL )
|
|
912 |
{
|
|
913 |
string sTempLine( pTemp + 1 );
|
|
914 |
// Are all characters numbers?
|
|
915 |
for( unsigned int i = 0 ; i < sTempLine .size() ; i++ )
|
|
916 |
{
|
|
917 |
if( !isdigit(sTempLine[i]) )
|
|
918 |
{
|
|
919 |
bStringNumber = false;
|
|
920 |
break;
|
|
921 |
}
|
|
922 |
}
|
|
923 |
}
|
|
924 |
else
|
|
925 |
bStringNumber = false;
|
|
926 |
if( bStringNumber )
|
|
927 |
{
|
|
928 |
pTemp++;
|
|
929 |
// Get line number
|
|
930 |
iRet = atoi( pTemp );
|
|
931 |
}
|
|
932 |
else
|
|
933 |
{
|
|
934 |
vector<string>::iterator sTempIter = vTempLines.end();
|
|
935 |
|
|
936 |
sTempIter--;
|
|
937 |
|
|
938 |
// Find last code line
|
|
939 |
while( sTempIter != vTempLines.begin() )
|
|
940 |
{
|
|
941 |
if( strstr( sTempIter->c_str() , "DCB" ) != NULL )
|
|
942 |
{
|
|
943 |
iRet = -1;
|
|
944 |
return iRet;
|
|
945 |
}
|
|
946 |
if( strstr( sTempIter->c_str() , ";;;" ) == NULL )
|
|
947 |
sTempIter--;
|
|
948 |
else
|
|
949 |
break;
|
|
950 |
}
|
|
951 |
if(sTempIter == vTempLines.begin() && strstr( sTempIter->c_str() , ";;;" ) == NULL)
|
|
952 |
{
|
|
953 |
iRet = -1;
|
|
954 |
return iRet;
|
|
955 |
}
|
|
956 |
sTempIter->erase( 0, 3 );
|
|
957 |
sTempIter->resize( sTempIter->find(' ') );
|
|
958 |
|
|
959 |
// Leak line
|
|
960 |
iRet = atoi( sTempIter->c_str() );
|
|
961 |
}
|
|
962 |
return iRet;
|
|
963 |
}
|
|
964 |
}
|
|
965 |
}
|
|
966 |
}
|
|
967 |
else // Line in file not found
|
|
968 |
{
|
|
969 |
// Find line of function
|
|
970 |
if( strstr( cLineFromFile, ";;;" ) != NULL )
|
|
971 |
{
|
|
972 |
pTemp = &cLineFromFile[0];
|
|
973 |
// Skip characters ";;;"
|
|
974 |
pTemp += 3;
|
|
975 |
pTempEnd = pTemp;
|
|
976 |
// Find end of line number
|
|
977 |
while( *pTempEnd != ' ' )
|
|
978 |
{
|
|
979 |
pTempEnd++;
|
|
980 |
}
|
|
981 |
*pTempEnd = 0;
|
|
982 |
iFoundLine = atoi( pTemp );
|
|
983 |
*pTempEnd = ' ';
|
|
984 |
if( iLine == iFoundLine )
|
|
985 |
{
|
|
986 |
bLineFound = true;
|
|
987 |
}
|
|
988 |
}
|
|
989 |
}
|
|
990 |
}
|
|
991 |
return iRet;
|
|
992 |
}
|
|
993 |
|
|
994 |
bool CATModule2::IsMakeSuccessfull()
|
|
995 |
{
|
|
996 |
LOG_FUNC_ENTRY("CATModule2::IsMakeSuccessfull");
|
|
997 |
m_sErrors.clear();
|
|
998 |
|
|
999 |
string sSearch;
|
|
1000 |
bool bMakeSuccess = true;
|
|
1001 |
|
|
1002 |
// Lst files checked only with armv5 platform.
|
|
1003 |
if ( IsPlatformArmv5() )
|
|
1004 |
{
|
|
1005 |
sSearch.append( m_sTempPath );
|
|
1006 |
sSearch.append( "*.lst" );
|
|
1007 |
if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
|
|
1008 |
bMakeSuccess = false;
|
|
1009 |
|
|
1010 |
// Map
|
|
1011 |
sSearch.clear();
|
|
1012 |
sSearch.append( m_sTempPath );
|
|
1013 |
sSearch.append( "*.map" );
|
|
1014 |
if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
|
|
1015 |
bMakeSuccess = false;
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
// .tmp
|
|
1019 |
sSearch.clear();
|
|
1020 |
sSearch.append( m_sTempPath );
|
|
1021 |
sSearch.append( "*.tmp" );
|
|
1022 |
if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
|
|
1023 |
bMakeSuccess = false;
|
|
1024 |
|
|
1025 |
return bMakeSuccess;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
bool CATModule2::CreateBuildCompleteFile()
|
|
1029 |
{
|
|
1030 |
LOG_FUNC_ENTRY("CATModule2::CreateBuildCompleteFile");
|
|
1031 |
// Don't create file if temp path not set cause might be anywhere
|
|
1032 |
if ( m_sTempPath.empty() )
|
|
1033 |
return false;
|
|
1034 |
// Create empty file indicating this module is build
|
|
1035 |
string sFile = m_sTempPath;
|
|
1036 |
if( sFile.at( sFile.length() - 1 ) != '\\' )
|
|
1037 |
sFile.append("\\");
|
|
1038 |
sFile.append( "BuildComplete" );
|
|
1039 |
ofstream out( sFile.c_str() );
|
|
1040 |
out << m_sVariantPlatform << endl;
|
|
1041 |
out << m_sVariantType << endl;
|
|
1042 |
out.close();
|
|
1043 |
return true;
|
|
1044 |
}
|
|
1045 |
|
|
1046 |
bool CATModule2::ReadMakeFileFromTemp()
|
|
1047 |
{
|
|
1048 |
LOG_FUNC_ENTRY("CATModule2::ReadMakeFileFromTemp");
|
|
1049 |
// Set makefile to point to temporary directory.
|
|
1050 |
string sMakeFile = m_sTempPath;
|
|
1051 |
sMakeFile.append( RemovePathAndExt( m_Mmp.m_sMmpFile, true ) );
|
|
1052 |
sMakeFile.append( "." );
|
|
1053 |
sMakeFile.append( AT_LEVEL_2_MAKEFILE_EXT );
|
|
1054 |
m_sMakeFile = sMakeFile;
|
|
1055 |
return ReadMakeFilePrivate();
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
bool CATModule2::ReadMakeFile()
|
|
1059 |
{
|
|
1060 |
LOG_FUNC_ENTRY("CATModule2::ReadMakeFile");
|
|
1061 |
// Read makefile
|
|
1062 |
if ( ReadMakeFilePrivate() )
|
|
1063 |
{
|
|
1064 |
// Copy makefile to temporary directory.
|
|
1065 |
string sMakeFile = m_sTempPath;
|
|
1066 |
sMakeFile.append( RemovePathAndExt( m_Mmp.m_sMmpFile, true ) );
|
|
1067 |
sMakeFile.append( "." );
|
|
1068 |
sMakeFile.append( AT_LEVEL_2_MAKEFILE_EXT );
|
|
1069 |
FileCopyToPath( m_sMakeFile, sMakeFile );
|
|
1070 |
return true;
|
|
1071 |
}
|
|
1072 |
return false;
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
bool CATModule2::ReadMakeFilePrivate()
|
|
1076 |
{
|
|
1077 |
LOG_FUNC_ENTRY("CATModule2::ReadMakeFilePrivate");
|
|
1078 |
|
|
1079 |
if ( m_sMakeFile.empty() )
|
|
1080 |
return false;
|
|
1081 |
|
|
1082 |
LOG_STRING( "using makefile :" << m_sMakeFile );
|
|
1083 |
|
|
1084 |
// Stream object to read files
|
|
1085 |
ifstream in;
|
|
1086 |
// Char array to read line from file
|
|
1087 |
char cLine[MAX_LINE_LENGTH];
|
|
1088 |
// String to use as buffer from file
|
|
1089 |
string sLine;
|
|
1090 |
// Open file
|
|
1091 |
in.open( m_sMakeFile.c_str(), ios_base::in );
|
|
1092 |
// Check that its open
|
|
1093 |
if ( ! in.good() )
|
|
1094 |
{
|
|
1095 |
// Cannot open file
|
|
1096 |
cout << AT_MSG << "Error, can not open file: " << m_sMakeFile << endl;
|
|
1097 |
return false;
|
|
1098 |
}
|
|
1099 |
// Check is it wrapper makefile (starts with "%:")
|
|
1100 |
in.getline( cLine, MAX_LINE_LENGTH );
|
|
1101 |
if ( cLine[0] == '%' && cLine[1] == ':' )
|
|
1102 |
{
|
|
1103 |
LOG_STRING("Found wrapper makefile");
|
|
1104 |
in.close();
|
|
1105 |
// Use ".default" makefile
|
|
1106 |
string sDefaultMakeFile = m_sMakeFile.substr( 0, m_sMakeFile.find_last_of( "." ) );
|
|
1107 |
sDefaultMakeFile.append( ".DEFAULT" );
|
|
1108 |
LOG_STRING( "using makefile :" << m_sMakeFile );
|
|
1109 |
// Does default exists. If not we need to run "wrapper make"
|
|
1110 |
if ( ! FileExists( sDefaultMakeFile.c_str() ) )
|
|
1111 |
{
|
|
1112 |
// Run the wrapper make to create "real" makefile
|
|
1113 |
string sMakeFileCmd;
|
|
1114 |
sMakeFileCmd.append("make -f \"");
|
|
1115 |
sMakeFileCmd.append( m_sMakeFile );
|
|
1116 |
sMakeFileCmd.append( "\"" );
|
|
1117 |
LOG_STRING( "using makefile :" << m_sMakeFile );
|
|
1118 |
cout << AT_MSG_SYSTEM_CALL << sMakeFileCmd << endl;
|
|
1119 |
int iRet = (int)system( sMakeFileCmd.c_str() );
|
|
1120 |
if ( iRet )
|
|
1121 |
{
|
|
1122 |
cout << MAKE_ERROR;
|
|
1123 |
return false;
|
|
1124 |
}
|
|
1125 |
}
|
|
1126 |
m_sMakeFile = sDefaultMakeFile;
|
|
1127 |
// Open new file
|
|
1128 |
in.open( m_sMakeFile.c_str(), ios_base::in );
|
|
1129 |
// Check that it's open
|
|
1130 |
if ( ! in.good() )
|
|
1131 |
{
|
|
1132 |
// Cannot open file
|
|
1133 |
cout << AT_MSG << "Error, can not open makefile: " << m_sMakeFile << endl;
|
|
1134 |
return false;
|
|
1135 |
}
|
|
1136 |
}
|
|
1137 |
in.seekg( ios_base::beg );
|
|
1138 |
|
|
1139 |
// Number of lines to read at max for basic module information.
|
|
1140 |
int iReadLineCount = 20;
|
|
1141 |
// Extension from target line. to be compared with targettype.
|
|
1142 |
string sTargetExtension;
|
|
1143 |
// Read line at a time. Loop until we find it or eof
|
|
1144 |
do {
|
|
1145 |
// Read line from file to array
|
|
1146 |
in.getline( cLine, MAX_LINE_LENGTH );
|
|
1147 |
iReadLineCount--;
|
|
1148 |
|
|
1149 |
sLine.clear();
|
|
1150 |
// Put that to string
|
|
1151 |
sLine.append( cLine );
|
|
1152 |
// Search target
|
|
1153 |
if ( sLine.find( MAKEFILE_TARGET_STRING ) != string::npos )
|
|
1154 |
{
|
|
1155 |
// Found it. Now remove other than type from line
|
|
1156 |
sLine.erase( 0, strlen( MAKEFILE_TARGET_STRING ) );
|
|
1157 |
ChangeToLower( sLine );
|
|
1158 |
sTargetExtension.clear();
|
|
1159 |
sTargetExtension = GetExtension( sLine );
|
|
1160 |
m_sTarget = RemovePathAndExt( sLine, true);
|
|
1161 |
LOG_STRING("found target: " << sLine );
|
|
1162 |
}
|
|
1163 |
// Search targettype
|
|
1164 |
else if ( sLine.find( MAKEFILE_TARGETTYPE_STRING ) != string::npos )
|
|
1165 |
{
|
|
1166 |
// Found it. Now remove other than type from line
|
|
1167 |
sLine.erase( 0, strlen( MAKEFILE_TARGETTYPE_STRING ) );
|
|
1168 |
ChangeToLower( sLine );
|
|
1169 |
m_sTargetType = sLine;
|
|
1170 |
LOG_STRING("found target type: " << m_sTargetType );
|
|
1171 |
}
|
|
1172 |
else if ( sLine.find( MAKEFILE_BASIC_TARGETTYPE_STRING ) != string::npos )
|
|
1173 |
{
|
|
1174 |
sLine.erase( 0, strlen( MAKEFILE_BASIC_TARGETTYPE_STRING ) );
|
|
1175 |
ChangeToLower( sLine );
|
|
1176 |
m_sRequestedTargetExt = sLine;
|
|
1177 |
// Compare with the extension in target line if not same use target lines if its "valid".
|
|
1178 |
if ( m_sRequestedTargetExt.compare( sTargetExtension ) != 0 && sTargetExtension.size() > 0 )
|
|
1179 |
m_sRequestedTargetExt = sTargetExtension;
|
|
1180 |
LOG_STRING("found requested target extension: " << m_sTargetType );
|
|
1181 |
}
|
|
1182 |
// Feature variant details
|
|
1183 |
else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_NAME ) != string::npos )
|
|
1184 |
{
|
|
1185 |
sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_NAME ) );
|
|
1186 |
m_sFeatureVariantName = sLine;
|
|
1187 |
LOG_STRING("found feature variant name: " << sLine );
|
|
1188 |
}
|
|
1189 |
else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_UREL_LABEL ) != string::npos )
|
|
1190 |
{
|
|
1191 |
sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_UREL_LABEL ) );
|
|
1192 |
LOG_STRING("found feature variant urel label: " << sLine );
|
|
1193 |
if ( sLine.compare("INVARIANT") != 0 )
|
|
1194 |
m_sFeatureVariantURELLabel = sLine;
|
|
1195 |
}
|
|
1196 |
else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_UDEB_LABEL ) != string::npos )
|
|
1197 |
{
|
|
1198 |
sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_UDEB_LABEL ) );
|
|
1199 |
LOG_STRING("found feature variant udeb label: " << sLine );
|
|
1200 |
if ( sLine.compare("INVARIANT") != 0 )
|
|
1201 |
m_sFeatureVariantUDEBLabel = sLine;
|
|
1202 |
}
|
|
1203 |
} while( in.good() && iReadLineCount > 0 );
|
|
1204 |
|
|
1205 |
// Search compile definitions
|
|
1206 |
// CWDEFS CCDEFS ARMCCDEFS
|
|
1207 |
do
|
|
1208 |
{
|
|
1209 |
in.getline( cLine, MAX_LINE_LENGTH );
|
|
1210 |
sLine.clear();
|
|
1211 |
sLine.append( cLine );
|
|
1212 |
if ( sLine.substr( 0 , 6 ).compare( string("CWDEFS") ) == 0
|
|
1213 |
|| sLine.substr( 0 , 6 ).compare( string("CCDEFS") ) == 0 )
|
|
1214 |
{
|
|
1215 |
sLine.erase( 0, 8 );
|
|
1216 |
m_sCompileDefinitions = sLine;
|
|
1217 |
break;
|
|
1218 |
}
|
|
1219 |
else if( sLine.substr( 0 , 9 ).compare( string("ARMCCDEFS") ) == 0 )
|
|
1220 |
{
|
|
1221 |
sLine.erase( 0, 11 );
|
|
1222 |
m_sCompileDefinitions = sLine;
|
|
1223 |
break;
|
|
1224 |
}
|
|
1225 |
} while( in.good() );
|
|
1226 |
// Move reading back to start if we could not find compile flags.
|
|
1227 |
in.seekg( ios_base::beg );
|
|
1228 |
|
|
1229 |
// Search listing information (modules source files).
|
|
1230 |
int iFindItem = 1; //1 = Source, 2 = LISTINGUDEB/UREL, 3 = lst file
|
|
1231 |
string sCdefs;
|
|
1232 |
string sSource;
|
|
1233 |
string sLst;
|
|
1234 |
do
|
|
1235 |
{
|
|
1236 |
in.getline( cLine, MAX_LINE_LENGTH );
|
|
1237 |
sLine.clear();
|
|
1238 |
sLine.append( cLine );
|
|
1239 |
|
|
1240 |
switch( iFindItem )
|
|
1241 |
{
|
|
1242 |
case 1:
|
|
1243 |
if( sLine.find( "# Source " ) != string::npos )
|
|
1244 |
{
|
|
1245 |
iFindItem = 2;
|
|
1246 |
// Remove text "# Source "
|
|
1247 |
sLine.erase( 0, 9 );
|
|
1248 |
sSource = sLine;
|
|
1249 |
}
|
|
1250 |
break;
|
|
1251 |
case 2:
|
|
1252 |
if( IsUDEB() )
|
|
1253 |
{
|
|
1254 |
if( sLine.find( "LISTINGUDEB" ) != string::npos )
|
|
1255 |
{
|
|
1256 |
iFindItem = 3;
|
|
1257 |
}
|
|
1258 |
}
|
|
1259 |
else
|
|
1260 |
{
|
|
1261 |
if( sLine.find( "LISTINGUREL" ) != string::npos )
|
|
1262 |
{
|
|
1263 |
iFindItem = 3;
|
|
1264 |
}
|
|
1265 |
}
|
|
1266 |
break;
|
|
1267 |
case 3:
|
|
1268 |
if( sLine.find( "perl -S ecopyfile.pl" ) != string::npos )
|
|
1269 |
{
|
|
1270 |
// Save lst file to list
|
|
1271 |
sLine.erase( 0, ( sLine.find_first_of( "\\" ) ) );
|
|
1272 |
// remove last char if '"'
|
|
1273 |
if ( sLine.at( sLine.size()-1 ) == '"' )
|
|
1274 |
sLine.erase( sLine.size()-1, sLine.size() );
|
|
1275 |
sLst = sLine;
|
|
1276 |
AddSource( sSource, sLst );
|
|
1277 |
iFindItem = 1;
|
|
1278 |
sSource.clear(); sLst.clear();
|
|
1279 |
|
|
1280 |
}
|
|
1281 |
break;
|
|
1282 |
}
|
|
1283 |
}
|
|
1284 |
while( in.good() );
|
|
1285 |
// close and return
|
|
1286 |
in.close();
|
|
1287 |
return true;
|
|
1288 |
}
|
|
1289 |
|
|
1290 |
// ----------------------------------------------------------------------------
|
|
1291 |
// Get & Sets
|
|
1292 |
// ----------------------------------------------------------------------------
|
|
1293 |
string CATModule2::GetErrors() const
|
|
1294 |
{
|
|
1295 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetErrors");
|
|
1296 |
return m_sErrors;
|
|
1297 |
}
|
|
1298 |
|
|
1299 |
string CATModule2::GetS60FileName() const
|
|
1300 |
{
|
|
1301 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetS60FileName");
|
|
1302 |
return m_sS60FileName;
|
|
1303 |
}
|
|
1304 |
|
|
1305 |
void CATModule2::SetS60FileName( const string& aFileName )
|
|
1306 |
{
|
|
1307 |
LOG_LOW_FUNC_ENTRY("CATModule2::SetS60FileName");
|
|
1308 |
|
|
1309 |
m_sS60FileName = aFileName;
|
|
1310 |
|
|
1311 |
//check new m_sS60FileName and change it if needed
|
|
1312 |
string sProcessName = "";
|
|
1313 |
sProcessName.append( m_sTarget );
|
|
1314 |
sProcessName.append(".");
|
|
1315 |
sProcessName.append( m_sTargetType );
|
|
1316 |
|
|
1317 |
if ( m_sS60FileName.empty() )
|
|
1318 |
{
|
|
1319 |
m_sS60FileName = sProcessName;
|
|
1320 |
m_sS60FileName.append(".dat");
|
|
1321 |
}
|
|
1322 |
else
|
|
1323 |
{
|
|
1324 |
// if data file name contains %processname% string, replace it with process name
|
|
1325 |
string sProcessnameTemp = "[";
|
|
1326 |
sProcessnameTemp.append( sProcessName );
|
|
1327 |
sProcessnameTemp.append( "]" );
|
|
1328 |
size_t iSpot;
|
|
1329 |
|
|
1330 |
//create temp name in lowercase
|
|
1331 |
string sS60FileNameLower = m_sS60FileName;
|
|
1332 |
ChangeToLower( sS60FileNameLower );
|
|
1333 |
|
|
1334 |
// find %processname% string in lowercase name, replace it with process name in in m_sS60FileName
|
|
1335 |
// replace it also in temp string (matching indexes)
|
|
1336 |
while( ( iSpot = sS60FileNameLower.find( AT_PROCESSNAME_TAG ) ) != string::npos )
|
|
1337 |
{
|
|
1338 |
m_sS60FileName.replace( iSpot, AT_PROCESSNAME_TAG.length(), sProcessnameTemp );
|
|
1339 |
sS60FileNameLower.replace( iSpot, AT_PROCESSNAME_TAG.length(), sProcessnameTemp );
|
|
1340 |
}
|
|
1341 |
}
|
|
1342 |
}
|
|
1343 |
|
|
1344 |
string CATModule2::GetLstNameOfSource(string sSource) const
|
|
1345 |
{
|
|
1346 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetLstNameOfSource");
|
|
1347 |
// Find . before xtension
|
|
1348 |
size_t iSpot = sSource.find_last_of( "." );
|
|
1349 |
// Get sub string to there
|
|
1350 |
string sLst = sSource.substr(0, iSpot+1);
|
|
1351 |
if ( m_sVariantPlatform.compare( "winscw" ) != 0 )
|
|
1352 |
{
|
|
1353 |
// Add variant platform (i.e. armv5)
|
|
1354 |
sLst.append( m_sVariantPlatform );
|
|
1355 |
sLst.append( "." );
|
|
1356 |
// Add variant type (i.e. build type liek urel)
|
|
1357 |
sLst.append( m_sVariantType );
|
|
1358 |
sLst.append( "." );
|
|
1359 |
// Add target binary name
|
|
1360 |
sLst.append( m_sTarget );
|
|
1361 |
sLst.append( "." );
|
|
1362 |
// Add target requested binary extension
|
|
1363 |
sLst.append( m_sRequestedTargetExt );
|
|
1364 |
sLst.append( "." );
|
|
1365 |
// Add lst extension
|
|
1366 |
sLst.append( "lst" );
|
|
1367 |
}
|
|
1368 |
else
|
|
1369 |
{
|
|
1370 |
sLst.append( "WINSCW.lst" );
|
|
1371 |
}
|
|
1372 |
return sLst;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
bool CATModule2::IsPlatformArmv5() const
|
|
1376 |
{
|
|
1377 |
LOG_LOW_FUNC_ENTRY("CATModule2::IsPlatformArmv5");
|
|
1378 |
if ( _stricmp( m_sVariantPlatform.c_str(), "armv5" ) == 0 )
|
|
1379 |
return true;
|
|
1380 |
return false;
|
|
1381 |
}
|
|
1382 |
|
|
1383 |
string CATModule2::GetMapFile() const
|
|
1384 |
{
|
|
1385 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetMapFile");
|
|
1386 |
// Map file with path using variables
|
|
1387 |
string sMapFile( m_sReleasePath );
|
|
1388 |
if ( ! sMapFile.empty() )
|
|
1389 |
sMapFile.append( "\\" );
|
|
1390 |
sMapFile.append( m_sFullVariantPath );
|
|
1391 |
if ( ! m_sFullVariantPath.empty() )
|
|
1392 |
sMapFile.append( "\\" );
|
|
1393 |
sMapFile.append( m_sTarget );
|
|
1394 |
sMapFile.append( "." );
|
|
1395 |
// Possible feature variant. Note debug might not be defined
|
|
1396 |
// when release has got one.
|
|
1397 |
if ( IsUDEB() && !m_sFeatureVariantUDEBLabel.empty() )
|
|
1398 |
{
|
|
1399 |
sMapFile.append( m_sFeatureVariantUDEBLabel );
|
|
1400 |
sMapFile.append( "." );
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
if ( !IsUDEB() && !m_sFeatureVariantURELLabel.empty() )
|
|
1404 |
{
|
|
1405 |
sMapFile.append( m_sFeatureVariantURELLabel );
|
|
1406 |
sMapFile.append( "." );
|
|
1407 |
}
|
|
1408 |
sMapFile.append( m_sRequestedTargetExt );
|
|
1409 |
sMapFile.append( ".map" );
|
|
1410 |
return sMapFile;
|
|
1411 |
}
|
|
1412 |
|
|
1413 |
string CATModule2::GetSymbolFile() const
|
|
1414 |
{
|
|
1415 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetSymbolFile");
|
|
1416 |
// Symbol file with path using variables
|
|
1417 |
string sSymbolFile( m_sReleasePath );
|
|
1418 |
sSymbolFile.append( "\\" );
|
|
1419 |
sSymbolFile.append( m_sFullVariantPath );
|
|
1420 |
sSymbolFile.append( "\\" );
|
|
1421 |
sSymbolFile.append( m_sTarget );
|
|
1422 |
sSymbolFile.append( "." );
|
|
1423 |
// Possible feature variant.
|
|
1424 |
if ( ! m_sFeatureVariantUDEBLabel.empty() || ! m_sFeatureVariantURELLabel.empty() )
|
|
1425 |
{
|
|
1426 |
if ( IsUDEB() )
|
|
1427 |
sSymbolFile.append( m_sFeatureVariantUDEBLabel );
|
|
1428 |
else
|
|
1429 |
sSymbolFile.append( m_sFeatureVariantURELLabel );
|
|
1430 |
sSymbolFile.append( "." );
|
|
1431 |
}
|
|
1432 |
|
|
1433 |
if ( m_eBuildSystem == CATProject::SBS_V1 )
|
|
1434 |
{
|
|
1435 |
sSymbolFile.append( "sym" );
|
|
1436 |
return sSymbolFile;
|
|
1437 |
}
|
|
1438 |
sSymbolFile.append( m_sRequestedTargetExt );
|
|
1439 |
sSymbolFile.append( ".sym" );
|
|
1440 |
return sSymbolFile;
|
|
1441 |
}
|
|
1442 |
|
|
1443 |
string CATModule2::GetBinaryFile() const
|
|
1444 |
{
|
|
1445 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetBinaryFile");
|
|
1446 |
// Binary file with path using variables
|
|
1447 |
string sBinaryFile( m_sReleasePath );
|
|
1448 |
if ( ! sBinaryFile.empty() )
|
|
1449 |
sBinaryFile.append( "\\" );
|
|
1450 |
sBinaryFile.append( m_sFullVariantPath );
|
|
1451 |
if ( ! m_sFullVariantPath.empty() )
|
|
1452 |
sBinaryFile.append( "\\" );
|
|
1453 |
sBinaryFile.append( m_sTarget );
|
|
1454 |
sBinaryFile.append( "." );
|
|
1455 |
// Possible feature variant.
|
|
1456 |
if ( ! m_sFeatureVariantUDEBLabel.empty() || ! m_sFeatureVariantURELLabel.empty() )
|
|
1457 |
{
|
|
1458 |
if ( IsUDEB() )
|
|
1459 |
sBinaryFile.append( m_sFeatureVariantUDEBLabel );
|
|
1460 |
else
|
|
1461 |
sBinaryFile.append( m_sFeatureVariantURELLabel );
|
|
1462 |
sBinaryFile.append( "." );
|
|
1463 |
}
|
|
1464 |
sBinaryFile.append( m_sRequestedTargetExt );
|
|
1465 |
return sBinaryFile;
|
|
1466 |
}
|
|
1467 |
|
|
1468 |
bool CATModule2::SetMmpFile(const string& sMmpFile)
|
|
1469 |
{
|
|
1470 |
LOG_FUNC_ENTRY("CATModule2::SetMmpFile");
|
|
1471 |
// Set mmp file
|
|
1472 |
m_Mmp.m_sMmpFile = sMmpFile;
|
|
1473 |
// Change to lower
|
|
1474 |
ChangeToLower( m_Mmp.m_sMmpFile );
|
|
1475 |
// Convert
|
|
1476 |
ConvertUnixPathToWin( m_Mmp.m_sMmpFile );
|
|
1477 |
// Set the temporary path.
|
|
1478 |
m_sTempPath.clear();
|
|
1479 |
m_sTempPath = CreateTempPath( m_Mmp.m_sMmpFile );
|
|
1480 |
return true;
|
|
1481 |
}
|
|
1482 |
|
|
1483 |
bool CATModule2::CreateTemporaryDirectory()
|
|
1484 |
{
|
|
1485 |
LOG_FUNC_ENTRY("CATModule2::CreateTemporaryDirectory");
|
|
1486 |
if ( m_sTempPath.empty() )
|
|
1487 |
{
|
|
1488 |
LOG_STRING("Temporary path is not set.");
|
|
1489 |
return false;
|
|
1490 |
}
|
|
1491 |
// Create temp dir if not exists
|
|
1492 |
if ( ! DirectoryExists( m_sTempPath.c_str() ) )
|
|
1493 |
{
|
|
1494 |
if ( !CreateDirectory( m_sTempPath.c_str(), NULL ) )
|
|
1495 |
{
|
|
1496 |
cout << AT_MSG << "Error, can not create directory: "
|
|
1497 |
<< m_sTempPath << endl;
|
|
1498 |
return false;
|
|
1499 |
}
|
|
1500 |
cout << AT_MSG << "Directory created: " << m_sTempPath << endl;
|
|
1501 |
}
|
|
1502 |
return true;
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
void CATModule2::SetMakeFile( const string& sMakeFile )
|
|
1506 |
{
|
|
1507 |
LOG_FUNC_ENTRY("CATModule2::SetMakeFile");
|
|
1508 |
m_sMakeFile = sMakeFile;
|
|
1509 |
}
|
|
1510 |
string CATModule2::GetMakeFile() const
|
|
1511 |
{
|
|
1512 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetMakeFile");
|
|
1513 |
return m_sMakeFile;
|
|
1514 |
}
|
|
1515 |
string CATModule2::GetMmpFile() const
|
|
1516 |
{
|
|
1517 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetMmpFile");
|
|
1518 |
return m_Mmp.m_sMmpFile;
|
|
1519 |
}
|
|
1520 |
string CATModule2::GetTempPath() const
|
|
1521 |
{
|
|
1522 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetTempPath");
|
|
1523 |
return m_sTempPath;
|
|
1524 |
}
|
|
1525 |
void CATModule2::SetTarget(const string& sTarget)
|
|
1526 |
{
|
|
1527 |
LOG_FUNC_ENTRY("CATModule2::SetTarget");
|
|
1528 |
m_sTarget = sTarget;
|
|
1529 |
ChangeToLower( m_sTarget );
|
|
1530 |
}
|
|
1531 |
string CATModule2::GetTarget() const
|
|
1532 |
{
|
|
1533 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetTarget");
|
|
1534 |
return m_sTarget;
|
|
1535 |
}
|
|
1536 |
string CATModule2::GetBinaryName() const
|
|
1537 |
{
|
|
1538 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetBinaryName");
|
|
1539 |
string sBinaryName;
|
|
1540 |
sBinaryName.append( m_sTarget );
|
|
1541 |
sBinaryName.append( "." );
|
|
1542 |
sBinaryName.append( m_sRequestedTargetExt );
|
|
1543 |
return sBinaryName;
|
|
1544 |
}
|
|
1545 |
|
|
1546 |
void CATModule2::SetTargetType(const string& sTargetType)
|
|
1547 |
{
|
|
1548 |
LOG_FUNC_ENTRY("CATModule2::SetTargetType");
|
|
1549 |
m_sTargetType = sTargetType;
|
|
1550 |
ChangeToLower( m_sTargetType );
|
|
1551 |
}
|
|
1552 |
string CATModule2::GetTargetType() const
|
|
1553 |
{
|
|
1554 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetTargetType");
|
|
1555 |
return m_sTargetType;
|
|
1556 |
}
|
|
1557 |
void CATModule2::SetRequestedTargetExt( const string& sRequestedTargetExt )
|
|
1558 |
{
|
|
1559 |
LOG_FUNC_ENTRY("CATModule2::SetRequestedTargetExt");
|
|
1560 |
m_sRequestedTargetExt = sRequestedTargetExt;
|
|
1561 |
ChangeToLower( m_sRequestedTargetExt );
|
|
1562 |
}
|
|
1563 |
|
|
1564 |
string CATModule2::GetRequestedTargetExt() const
|
|
1565 |
{
|
|
1566 |
LOG_LOW_FUNC_ENTRY("CATmodule2::GetRequestedTargetExt");
|
|
1567 |
return m_sRequestedTargetExt;
|
|
1568 |
}
|
|
1569 |
|
|
1570 |
void CATModule2::SetVariantPlatform(const string& sVariantPlatform)
|
|
1571 |
{
|
|
1572 |
LOG_FUNC_ENTRY("CATModule2::SetVariantPlatform");
|
|
1573 |
m_sVariantPlatform = sVariantPlatform;
|
|
1574 |
ChangeToLower( m_sVariantPlatform );
|
|
1575 |
}
|
|
1576 |
string CATModule2::GetVariantPlatform() const
|
|
1577 |
{
|
|
1578 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetVariantPlatform");
|
|
1579 |
return m_sVariantPlatform;
|
|
1580 |
}
|
|
1581 |
void CATModule2::SetVariantType(const string& sVariantType)
|
|
1582 |
{
|
|
1583 |
LOG_FUNC_ENTRY("CATModule2::SetVariantType");
|
|
1584 |
m_sVariantType = sVariantType;
|
|
1585 |
ChangeToLower( m_sVariantType );
|
|
1586 |
}
|
|
1587 |
string CATModule2::GetVariantType() const
|
|
1588 |
{
|
|
1589 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetVariantType");
|
|
1590 |
return m_sVariantType;
|
|
1591 |
}
|
|
1592 |
void CATModule2::SetFeatureVariant(const string& sFeatureVariant)
|
|
1593 |
{
|
|
1594 |
LOG_FUNC_ENTRY("CATModule2::SetFeatureVariant");
|
|
1595 |
m_sFeatureVariant = sFeatureVariant;
|
|
1596 |
ChangeToLower( m_sFeatureVariant );
|
|
1597 |
}
|
|
1598 |
string CATModule2::GetFeatureVariant() const
|
|
1599 |
{
|
|
1600 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetFeatureVariant");
|
|
1601 |
return m_sFeatureVariant;
|
|
1602 |
}
|
|
1603 |
void CATModule2::SetFeatureVariantName(const string& sFeatureVariantName)
|
|
1604 |
{
|
|
1605 |
LOG_FUNC_ENTRY("CATModule2::SetFeatureVariantName");
|
|
1606 |
m_sFeatureVariantName = sFeatureVariantName;
|
|
1607 |
ChangeToLower( m_sFeatureVariantName );
|
|
1608 |
}
|
|
1609 |
string CATModule2::GetFeatureVariantName() const
|
|
1610 |
{
|
|
1611 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetFeatureVariantName");
|
|
1612 |
return m_sFeatureVariantName;
|
|
1613 |
}
|
|
1614 |
void CATModule2::SetReleasePath(const string& sReleasePath)
|
|
1615 |
{
|
|
1616 |
LOG_FUNC_ENTRY("CATModule2::SetReleasePath");
|
|
1617 |
m_sReleasePath = sReleasePath;
|
|
1618 |
ChangeToLower( m_sReleasePath );
|
|
1619 |
ConvertUnixPathToWin( m_sReleasePath );
|
|
1620 |
|
|
1621 |
}
|
|
1622 |
string CATModule2::GetReleasePath() const
|
|
1623 |
{
|
|
1624 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetReleasePath");
|
|
1625 |
return m_sReleasePath;
|
|
1626 |
}
|
|
1627 |
void CATModule2::SetFullVariantPath(const string& sFullVariantPath)
|
|
1628 |
{
|
|
1629 |
LOG_FUNC_ENTRY("CATModule2::SetFullVariantPath");
|
|
1630 |
m_sFullVariantPath = sFullVariantPath;
|
|
1631 |
ChangeToLower( m_sFullVariantPath );
|
|
1632 |
ConvertUnixPathToWin( m_sFullVariantPath );
|
|
1633 |
}
|
|
1634 |
string CATModule2::GetFullVariantPath() const
|
|
1635 |
{
|
|
1636 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetFullVariantPath");
|
|
1637 |
return m_sFullVariantPath;
|
|
1638 |
}
|
|
1639 |
string CATModule2::GetUniqueId() const
|
|
1640 |
{
|
|
1641 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetUniqueId");
|
|
1642 |
return FilterString( m_sTarget );
|
|
1643 |
}
|
|
1644 |
void CATModule2::SetBuildSystem( int eBuildSystem )
|
|
1645 |
{
|
|
1646 |
LOG_FUNC_ENTRY("CATModule2::SetBuildSystem");
|
|
1647 |
m_eBuildSystem = eBuildSystem;
|
|
1648 |
}
|
|
1649 |
|
|
1650 |
int CATModule2::GetBuildSystem() const
|
|
1651 |
{
|
|
1652 |
LOG_LOW_FUNC_ENTRY("CATModule2::GetBuildSystem");
|
|
1653 |
return m_eBuildSystem;
|
|
1654 |
}
|
|
1655 |
|
|
1656 |
void CATModule2::SetCompileDefinitions( const string& sCompileDefinitions )
|
|
1657 |
{
|
|
1658 |
LOG_LOW_FUNC_ENTRY( "CATModule2::SetCompileDefinitions" );
|
|
1659 |
m_sCompileDefinitions = sCompileDefinitions;
|
|
1660 |
}
|
|
1661 |
|
|
1662 |
string CATModule2::GetCompileDefinitions() const
|
|
1663 |
{
|
|
1664 |
LOG_LOW_FUNC_ENTRY( "CATModule2::GetCompileDefinitions" );
|
|
1665 |
return m_sCompileDefinitions;
|
|
1666 |
}
|
|
1667 |
|
|
1668 |
void CATModule2::SetCompileInfoText( string sCompileInfoText )
|
|
1669 |
{
|
|
1670 |
LOG_LOW_FUNC_ENTRY( "CATModule2::SetCompileInfoText" );
|
|
1671 |
m_sCompileInfoText = sCompileInfoText;
|
|
1672 |
}
|
|
1673 |
string CATModule2::GetCompileInfoText() const
|
|
1674 |
{
|
|
1675 |
LOG_LOW_FUNC_ENTRY( "CATModule2::GetCompileInfoText" );
|
|
1676 |
return m_sCompileInfoText;
|
|
1677 |
}
|
|
1678 |
//EOF
|