|
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 project. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "../inc/CATProject.h" |
|
20 #include "../inc/CATModule2.h" |
|
21 #include "../inc/CATParseTraceFile.h" |
|
22 #include "../inc/CATParseBinaryFile.h" |
|
23 #include "../inc/CATDatParser.h" |
|
24 |
|
25 //dbghelp.dll version function. |
|
26 extern int showDbgHelpVersionInfo( bool showVersion ); |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // CATProject::CATProject() |
|
30 // ---------------------------------------------------------------------------- |
|
31 CATProject::CATProject() |
|
32 { |
|
33 LOG_FUNC_ENTRY("CATProject::CATProject"); |
|
34 |
|
35 m_bUninstrumented = true; |
|
36 m_bAbldTest = false; |
|
37 |
|
38 // Use windows api to acquire current directory info. |
|
39 GetCurrentDirectory( MAX_LINE_LENGTH, m_cCurrentDir ); |
|
40 |
|
41 m_eBuildSystem = SBS_V1; |
|
42 m_eBuildType = UDEB; |
|
43 m_eLoggingMode = TRACE; |
|
44 m_eMode = NOT_DEFINED; |
|
45 |
|
46 m_iLoggingLevel = 3; |
|
47 |
|
48 m_pAnalyzer = 0; |
|
49 |
|
50 m_sBinaryTarget = ""; |
|
51 m_sBuildCommand = ""; |
|
52 m_sDataFile = ""; |
|
53 m_sDataFileOutput = ""; |
|
54 m_sDataFileTemp = ""; |
|
55 m_sBinaryLogFileTemp = ""; |
|
56 m_sEpocRoot = "\\"; |
|
57 m_sMakeFile = ""; |
|
58 m_sPlatform = ""; |
|
59 m_sS60FileName = ""; |
|
60 m_sS60FilePath = ""; |
|
61 m_sTargetModule = ""; |
|
62 m_sVariant = ""; |
|
63 |
|
64 m_vRomSymbolFiles.clear(); |
|
65 m_vModules.clear(); |
|
66 m_vStaticLibraries.clear(); |
|
67 m_vTargetModules.clear(); |
|
68 m_vUnsupportedModules.clear(); |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CATProject::~CATProject() |
|
73 // ---------------------------------------------------------------------------- |
|
74 CATProject::~CATProject() |
|
75 { |
|
76 LOG_FUNC_ENTRY("CATProject::~CATProject"); |
|
77 |
|
78 CleanModuleVectors(); |
|
79 |
|
80 // Delete analyzer |
|
81 if ( m_pAnalyzer ) |
|
82 delete m_pAnalyzer; |
|
83 |
|
84 // Temporary datafile |
|
85 if ( !m_sDataFileTemp.empty() ) |
|
86 { |
|
87 if ( FileExists( m_sDataFileTemp.c_str() ) ) |
|
88 FileDelete( m_sDataFileTemp, false ); |
|
89 } |
|
90 |
|
91 // Temporary trace file |
|
92 if ( !m_sBinaryLogFileTemp.empty() ) |
|
93 { |
|
94 if ( FileExists( m_sBinaryLogFileTemp.c_str() ) ) |
|
95 FileDelete( m_sBinaryLogFileTemp, false ); |
|
96 } |
|
97 |
|
98 } |
|
99 |
|
100 bool CATProject::SetArguments( ARGUMENTS& arguments ) |
|
101 { |
|
102 LOG_FUNC_ENTRY("CATProject::SetArguments"); |
|
103 bool bRet = true; |
|
104 |
|
105 //Project mode. |
|
106 if( arguments.eHookSwitch == HOOK_INTERNAL ) |
|
107 { |
|
108 SetMode( CATProject::COMPILE ); |
|
109 SetLoggingMode( CATProject::FILE ); |
|
110 } |
|
111 else if ( arguments.eHookSwitch == HOOK_EXTERNAL ) |
|
112 { |
|
113 SetMode( CATProject::COMPILE ); |
|
114 SetLoggingMode( CATProject::TRACE ); |
|
115 } |
|
116 else if ( arguments.eHookSwitch == HOOK_EXTERNAL_FAST ) |
|
117 { |
|
118 SetMode( CATProject::COMPILE ); |
|
119 SetLoggingMode( CATProject::TRACE_FAST ); |
|
120 } |
|
121 /* Extension*/ |
|
122 else if ( arguments.eHookSwitch == HOOK_EXTENSION_INTERNAL ) |
|
123 { |
|
124 SetMode( CATProject::INSTRUMENT ); |
|
125 SetLoggingMode( CATProject::FILE ); |
|
126 } |
|
127 else if ( arguments.eHookSwitch == HOOK_EXTENSION_EXTERNAL ) |
|
128 { |
|
129 SetMode( CATProject::INSTRUMENT ); |
|
130 SetLoggingMode( CATProject::TRACE ); |
|
131 } |
|
132 else if ( arguments.eHookSwitch == HOOK_EXTENSION_EXTERNAL_FAST ) |
|
133 { |
|
134 SetMode( CATProject::INSTRUMENT ); |
|
135 SetLoggingMode( CATProject::TRACE_FAST ); |
|
136 } |
|
137 else if ( arguments.eHookSwitch == HOOK_EXTENSION_UNINSTRUMENT ) |
|
138 { |
|
139 SetMode( CATProject::UNINSTRUMENT ); |
|
140 } |
|
141 else if ( arguments.eHookSwitch == HOOK_EXTENSION_FAILED ) |
|
142 { |
|
143 SetMode( CATProject::UNINSTRUMENT_FAILED ); |
|
144 } |
|
145 //Return if uninstrumenting because no other arguments are set. |
|
146 if ( GetMode() == CATProject::UNINSTRUMENT |
|
147 || GetMode() == CATProject::UNINSTRUMENT_FAILED ) |
|
148 { |
|
149 return bRet; |
|
150 } |
|
151 |
|
152 // No build / instrument. |
|
153 if ( arguments.HOOK.bNoBuild ) |
|
154 SetMode( CATProject::INSTRUMENT_CONSOLE ); |
|
155 |
|
156 // Call stack sizes |
|
157 SetAllocCallStackSize( arguments.HOOK.iAllocCallStackSize ); |
|
158 SetFreeCallStackSize( arguments.HOOK.iFreeCallStackSize ); |
|
159 |
|
160 //Build system. |
|
161 if ( arguments.HOOK.iBuildSystem == 1 ) |
|
162 SetBuildSystem( CATProject::SBS_V1 ); |
|
163 else if ( arguments.HOOK.iBuildSystem == 2 ) |
|
164 SetBuildSystem( CATProject::SBS_V2 ); |
|
165 |
|
166 //Test module build only |
|
167 if ( arguments.HOOK.bAbldTest == true ) |
|
168 m_bAbldTest = true; |
|
169 |
|
170 //Platform. |
|
171 if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "armv5" ) ) |
|
172 SetPlatform( arguments.HOOK.sPlatform ); |
|
173 else if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "gcce" ) ) |
|
174 SetPlatform( arguments.HOOK.sPlatform ); |
|
175 else if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "winscw" ) ) |
|
176 SetPlatform( arguments.HOOK.sPlatform ); |
|
177 else |
|
178 { |
|
179 LOG_STRING( "Error, no supported platform specified (armv5/gcce/winscw)."); |
|
180 bRet = false; |
|
181 } |
|
182 |
|
183 //BuildType. |
|
184 if ( !_stricmp( arguments.HOOK.sBuildType.c_str(), "urel" ) ) |
|
185 SetBuildType( CATProject::UREL ); |
|
186 else if ( !_stricmp( arguments.HOOK.sBuildType.c_str(), "udeb" ) ) |
|
187 SetBuildType( CATProject::UDEB ); |
|
188 else |
|
189 { |
|
190 LOG_STRING( "Error, no build type specified."); |
|
191 bRet = false; |
|
192 } |
|
193 |
|
194 //Internal data file name. |
|
195 if ( arguments.HOOK.bDataFileName ) |
|
196 SetS60FileName( arguments.HOOK.sDataFileName ); |
|
197 |
|
198 //Internal data file path. |
|
199 if ( arguments.HOOK.bDataFilePath ) |
|
200 SetS60FilePath( arguments.HOOK.sDataFilePath ); |
|
201 |
|
202 //Build command. |
|
203 if ( arguments.HOOK.sBuildCmd.empty() && ( |
|
204 GetMode() == CATProject::COMPILE || |
|
205 GetMode() == CATProject::INSTRUMENT || |
|
206 GetMode() == CATProject::INSTRUMENT_CONSOLE |
|
207 )) |
|
208 { |
|
209 cout << AT_MSG << "Error, no build command specified." << endl; |
|
210 bRet = false; |
|
211 } |
|
212 |
|
213 SetBuildCommand( arguments.HOOK.sBuildCmd ); |
|
214 |
|
215 //Variant. |
|
216 SetVariant( arguments.HOOK.sFeatureVariant ); |
|
217 |
|
218 //Target programs. |
|
219 SetTargetModules( arguments.HOOK.vTargetPrograms ); |
|
220 |
|
221 return bRet; |
|
222 } |
|
223 |
|
224 void CATProject::CleanModuleVectors() |
|
225 { |
|
226 LOG_FUNC_ENTRY("CATProject::CleanModuleVectors"); |
|
227 // delete modules from vector. |
|
228 for( size_t i = 0; i < m_vModules.size() ; i++ ) |
|
229 delete m_vModules[i]; |
|
230 m_vModules.clear(); |
|
231 |
|
232 // Delete modules from vector (unsupported). |
|
233 for( size_t i = 0; i < m_vUnsupportedModules.size() ; i++ ) |
|
234 delete m_vUnsupportedModules[i]; |
|
235 m_vUnsupportedModules.clear(); |
|
236 |
|
237 // Delete modules from static library vector. |
|
238 for( size_t i = 0; i < m_vStaticLibraries.size() ; i++ ) |
|
239 delete m_vStaticLibraries[i]; |
|
240 m_vStaticLibraries.clear(); |
|
241 } |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CATProject::Run |
|
244 // ---------------------------------------------------------------------------- |
|
245 int CATProject::Run() |
|
246 { |
|
247 LOG_FUNC_ENTRY("CATProject::Run"); |
|
248 int iReturnCode = 0; |
|
249 switch( m_eMode ) |
|
250 { |
|
251 case COMPILE: |
|
252 // Run compile |
|
253 iReturnCode = RunCompile(); |
|
254 if ( iReturnCode == AT_RETURN_CODE::READ_MAKEFILE_ERROR |
|
255 || iReturnCode == AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR |
|
256 || iReturnCode == AT_RETURN_CODE::INVALID_MMP_DEFINED ) |
|
257 { |
|
258 DeleteTemporaryDirs(); |
|
259 DirDelete( AT_TEMP_DIR, true ); |
|
260 } |
|
261 else |
|
262 { |
|
263 DisplayCompileSummary(); |
|
264 DisplayBuildSummary(); |
|
265 } |
|
266 break; |
|
267 case CLEAN: |
|
268 iReturnCode = RunClean(); |
|
269 break; |
|
270 case ANALYZE: |
|
271 iReturnCode = RunAnalyze(); |
|
272 break; |
|
273 case INSTRUMENT: |
|
274 iReturnCode = RunInstrument(); |
|
275 break; |
|
276 case INSTRUMENT_CONSOLE: |
|
277 iReturnCode = RunInstrumentConsole(); |
|
278 if ( iReturnCode == AT_RETURN_CODE::READ_MAKEFILE_ERROR |
|
279 || iReturnCode == AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR ) |
|
280 { |
|
281 DeleteTemporaryDirs(); |
|
282 DirDelete( AT_TEMP_DIR, true ); |
|
283 } |
|
284 else |
|
285 { |
|
286 DisplayBuildSummary(); |
|
287 } |
|
288 break; |
|
289 case UNINSTRUMENT: |
|
290 iReturnCode = RunUninstrument(); |
|
291 // Show summary |
|
292 DisplayCompileSummary(); |
|
293 DisplayBuildSummary(); |
|
294 break; |
|
295 case UNINSTRUMENT_CONSOLE: |
|
296 iReturnCode = RunUninstrumentConsole(); |
|
297 // Show summary |
|
298 DisplayCompileSummary(); |
|
299 DisplayBuildSummary(); |
|
300 break; |
|
301 case UNINSTRUMENT_FAILED: |
|
302 iReturnCode = RunUninstrumentFailed(); |
|
303 // Display message |
|
304 cout << AT_MSG << "Build aborted, because project contains compile error(s)." |
|
305 << endl; |
|
306 break; |
|
307 default: |
|
308 cout << AT_MSG << "Error, mode not supported / implemented." << endl; |
|
309 break; |
|
310 } |
|
311 // Error messages |
|
312 switch( iReturnCode ) |
|
313 { |
|
314 case AT_RETURN_CODE::MAKEFILE_ERROR: |
|
315 cout << AT_MSG << "Error, creating/reading makefiles." << endl; |
|
316 break; |
|
317 case AT_RETURN_CODE::COMPILE_ERROR: |
|
318 cout << AT_MSG << "Error, compiling project." << endl; |
|
319 break; |
|
320 case AT_RETURN_CODE::UNKNOWN: |
|
321 cout << AT_MSG << "Error, unknown." << endl; |
|
322 break; |
|
323 case AT_RETURN_CODE::WRONG_DATA_FILE_VERSION: |
|
324 cout << AT_MSG << "unable to analyze the data file.\n"; |
|
325 cout << AT_MSG << "wrong data file version.\n"; |
|
326 break; |
|
327 case AT_RETURN_CODE::INVALID_DATA_FILE: |
|
328 cout << AT_MSG << "Error, invalid datafile." << endl; |
|
329 break; |
|
330 case AT_RETURN_CODE::RELEASABLES_ERROR: |
|
331 cout << AT_MSG << "Error, copying releasable(s)." << endl; |
|
332 break; |
|
333 case AT_RETURN_CODE::RESTORE_MODULES_ERROR: |
|
334 cout << AT_MSG << "Error, restoring mmp file(s)." << endl; |
|
335 break; |
|
336 case AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR: |
|
337 cout << AT_MSG << "Error, creating temporary cpp file(s)." << endl; |
|
338 break; |
|
339 case AT_RETURN_CODE::CLEANING_TEMP_ERROR: |
|
340 cout << AT_MSG << "Error, cleaning temporary dir(s)." << endl; |
|
341 break; |
|
342 case AT_RETURN_CODE::READ_MAKEFILE_ERROR: |
|
343 cout << AT_MSG << "Error, reading makefile." << endl; |
|
344 break; |
|
345 case AT_RETURN_CODE::MODIFY_MODULES_ERROR: |
|
346 cout << AT_MSG << "Error, modifying mmp file(s)." << endl; |
|
347 break; |
|
348 case AT_RETURN_CODE::INVALID_MMP_DEFINED: |
|
349 break; |
|
350 case AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR: |
|
351 cout << AT_MSG << "Error, writing attributes." << endl; |
|
352 break; |
|
353 case AT_RETURN_CODE::READ_ATTRIBUTES_ERROR: |
|
354 cout << AT_MSG << "Error, reading project configuration. Instrument project again." << endl; |
|
355 break; |
|
356 case AT_RETURN_CODE::EMPTY_DATA_FILE: |
|
357 cout << AT_MSG << "Error, no data to be analyzed." << endl; |
|
358 break; |
|
359 case AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR: |
|
360 cout << AT_MSG << "Error, no modules found with supported target type." << endl; |
|
361 break; |
|
362 case AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR: |
|
363 cout << AT_MSG << "Error, kernel side component found component. Build/instrument aborted." << endl; |
|
364 break; |
|
365 } |
|
366 return iReturnCode; |
|
367 } |
|
368 // ---------------------------------------------------------------------------- |
|
369 // CATProject::RunRecoveryAndExit() |
|
370 // Restore modules quick and exit. Used when user wants to kill/end process. |
|
371 // ---------------------------------------------------------------------------- |
|
372 int CATProject::RunRecoveryAndExit() |
|
373 { |
|
374 LOG_FUNC_ENTRY("CATProject::RunRecoveryAndExit"); |
|
375 cout << AT_MSG << "Error, user requested exit." << endl; |
|
376 VerifyAndRecoverModules(); |
|
377 DeleteTemporaryDirs(); |
|
378 DirDelete( AT_TEMP_DIR, true ); |
|
379 cout << AT_MSG << "Exit." << endl; |
|
380 return AT_RETURN_CODE::USER_ISSUED_EXIT; |
|
381 } |
|
382 |
|
383 // ---------------------------------------------------------------------------- |
|
384 // CATProject::IsUninstrumented() |
|
385 // Reads projects configuration file if it exists. |
|
386 // Return false in case the data contains information that project is |
|
387 // uninstrumented. Otherwise returns always true. |
|
388 // ---------------------------------------------------------------------------- |
|
389 bool CATProject::IsUninstrumented() |
|
390 { |
|
391 LOG_FUNC_ENTRY("CATProject::IsUninstrumented"); |
|
392 string sCfgFile( AT_TEMP_DIR ); |
|
393 sCfgFile.append( "\\" ); |
|
394 sCfgFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME ); |
|
395 if ( ! FileExists( sCfgFile.c_str() ) ) |
|
396 return true; |
|
397 if( !ReadAttributes() ) |
|
398 { |
|
399 LOG_STRING( "Error, reading project.cfg file." ); |
|
400 return false; |
|
401 } |
|
402 return m_bUninstrumented; |
|
403 } |
|
404 |
|
405 // ---------------------------------------------------------------------------- |
|
406 // CATProject::RunCompile() |
|
407 // Helper functions to run different modes. |
|
408 // ---------------------------------------------------------------------------- |
|
409 int CATProject::RunCompile() |
|
410 { |
|
411 LOG_FUNC_ENTRY("CATProject::RunCompile"); |
|
412 // Store attributes |
|
413 if( ! MakeTempDirIfNotExist() ) |
|
414 return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
415 if ( ! WriteAttributes() ) |
|
416 return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
417 // Create makefile |
|
418 if ( ! CreateMakeFile() ) |
|
419 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
420 // Read makefile to get project attributes |
|
421 if ( ! ReadMakeFile() ) |
|
422 return AT_RETURN_CODE::READ_MAKEFILE_ERROR; |
|
423 // Filter unsupported |
|
424 FilterModules(); |
|
425 // Check that we have some "valid" modules to hook |
|
426 if ( m_vModules.size() == 0 &&( m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) ) |
|
427 return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR; |
|
428 // Check is possible target module defined in project |
|
429 if ( ! IsTargetModuleInProject() ) |
|
430 return AT_RETURN_CODE::INVALID_MMP_DEFINED; |
|
431 // Clean temporary dirs of modules |
|
432 if ( ! CleanTemporaryDirs() ) |
|
433 return AT_RETURN_CODE::CLEANING_TEMP_ERROR; |
|
434 // Create temporary cpps for modulse |
|
435 if (! CreateTemporaryCpps() ) |
|
436 return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR; |
|
437 // Hook modules |
|
438 if (! ModifyModules() ) |
|
439 return AT_RETURN_CODE::MODIFY_MODULES_ERROR; |
|
440 // Compile all |
|
441 // Return code |
|
442 int iRetCode = AT_RETURN_CODE::OK; |
|
443 // Compile |
|
444 if ( ! Compile() ) |
|
445 iRetCode = AT_RETURN_CODE::COMPILE_ERROR; |
|
446 // Listings |
|
447 if (! CreateListings() ) |
|
448 iRetCode = AT_RETURN_CODE::COMPILE_ERROR; |
|
449 // Releasables |
|
450 if (! CopyReleasables() ) |
|
451 iRetCode = AT_RETURN_CODE::RELEASABLES_ERROR; |
|
452 // Restore "unhook" modules |
|
453 if (! RestoreModules() ) |
|
454 iRetCode = AT_RETURN_CODE::RESTORE_MODULES_ERROR; |
|
455 // Return error code OK |
|
456 return iRetCode; |
|
457 } |
|
458 |
|
459 int CATProject::RunClean() |
|
460 { |
|
461 LOG_FUNC_ENTRY("CATProject::RunClean"); |
|
462 int iRetCode = AT_RETURN_CODE::OK; |
|
463 bool bNothingFound = true; |
|
464 // Read attributes. |
|
465 if ( ReadAttributes() ) |
|
466 { |
|
467 bNothingFound = false; |
|
468 if ( m_eBuildSystem == SBS_V1 ) |
|
469 InitSbs1MakeFileWithPathToTemp(); |
|
470 // Read makefile to get project attributes |
|
471 if( ReadMakeFile() ) |
|
472 { |
|
473 // Filter unsupported |
|
474 FilterModules(); |
|
475 // Restore modules to make sure no changes left |
|
476 if( VerifyAndRecoverModules() ) |
|
477 { |
|
478 // Run reallyclean |
|
479 switch ( m_eBuildSystem ) |
|
480 { |
|
481 case SBS_V1: |
|
482 RunReallyCleanSbs1(); |
|
483 break; |
|
484 case SBS_V2: |
|
485 RunReallyCleanSbs2(); |
|
486 break; |
|
487 default: |
|
488 break; |
|
489 } |
|
490 // Delete temporary dirs of modules |
|
491 if(! DeleteTemporaryDirs() ) |
|
492 { |
|
493 |
|
494 } |
|
495 } |
|
496 else |
|
497 { |
|
498 |
|
499 } |
|
500 } |
|
501 } |
|
502 // Projects |
|
503 if ( ! DirDelete( AT_TEMP_DIR, true ) ) |
|
504 { |
|
505 |
|
506 } |
|
507 else |
|
508 bNothingFound = false; |
|
509 |
|
510 if ( bNothingFound ) |
|
511 cout << AT_MSG << "Nothing found to clean." << endl; |
|
512 else |
|
513 cout << AT_MSG << "Cleaning done." << endl; |
|
514 return iRetCode; |
|
515 } |
|
516 |
|
517 int CATProject::RunAnalyze() |
|
518 { |
|
519 LOG_FUNC_ENTRY("CATProject::RunAnalyze"); |
|
520 |
|
521 // Parse data file if it is not data file. |
|
522 if ( !IsDataFile( m_sDataFile ) ) |
|
523 { |
|
524 m_sDataFileTemp.clear(); |
|
525 m_sDataFileTemp.append( m_sDataFile ); |
|
526 m_sDataFileTemp.append( ".atool" ); |
|
527 |
|
528 // make filename for file with cleaned timestamps |
|
529 // <m_sDataFile>.cleaned in the same place as output file |
|
530 string sTraceFileCleaned( GetPathOrFileName( false, m_sDataFileOutput ) ); |
|
531 sTraceFileCleaned.append( GetPathOrFileName( true, m_sDataFile ) ); |
|
532 sTraceFileCleaned.append( ".cleaned" ); |
|
533 |
|
534 //check if it is binary log file |
|
535 if( IsBinaryLogFile( m_sDataFile ) ) |
|
536 { |
|
537 // convert binary log file to ASCII trace format |
|
538 m_sBinaryLogFileTemp.clear(); |
|
539 m_sBinaryLogFileTemp.append( m_sDataFile ); |
|
540 m_sBinaryLogFileTemp.append( ".totraces" ); |
|
541 |
|
542 cout << AT_MSG << "Parsing binary data file..." << endl; |
|
543 |
|
544 CATParseBinaryFile Parser; |
|
545 stringstream dataToParse; |
|
546 if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sBinaryLogFileTemp.c_str() ) ) |
|
547 { |
|
548 return AT_RETURN_CODE::EMPTY_DATA_FILE; |
|
549 } |
|
550 m_sDataFile = m_sBinaryLogFileTemp; |
|
551 |
|
552 } |
|
553 else |
|
554 { |
|
555 cout << AT_MSG << "Parsing trace file..." << endl; |
|
556 } |
|
557 |
|
558 CATParseTraceFile Parser; |
|
559 if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sDataFileTemp.c_str(), sTraceFileCleaned.c_str() ) ) |
|
560 { |
|
561 return AT_RETURN_CODE::EMPTY_DATA_FILE; |
|
562 } |
|
563 m_sDataFile = m_sDataFileTemp; |
|
564 } |
|
565 |
|
566 // Init makefile member for this run mode. |
|
567 if ( m_eBuildSystem == SBS_V1 ) |
|
568 InitSbs1MakeFileWithPathToTemp(); |
|
569 // Read makefile to get project attributes |
|
570 if( ! ReadMakeFile() ) |
|
571 { |
|
572 cout << AT_MSG << "Error, cannot find project build with AnalyzeTool." << endl; |
|
573 } |
|
574 else |
|
575 FilterModules(); |
|
576 |
|
577 #ifndef ADDR2LINE |
|
578 // Initialize modules locating code lines. |
|
579 for( size_t i = 0 ; i < m_vModules.size() ; i++ ) |
|
580 { |
|
581 m_vModules.at(i)->InitializeAddressToLine(); |
|
582 } |
|
583 #endif |
|
584 |
|
585 // Create analyzer |
|
586 m_pAnalyzer = new CATDatParser( &m_vModules ); |
|
587 |
|
588 // Pass some info from project if it "exists" to analyzer. |
|
589 if ( m_vModules.size() > 0 ) |
|
590 { |
|
591 // Pass platform. |
|
592 m_pAnalyzer->SetProjectPlatform( m_sPlatform ); |
|
593 // Pass build type. |
|
594 m_pAnalyzer->SetProjectBuildType( m_eBuildType ); |
|
595 } |
|
596 |
|
597 // Set file. |
|
598 m_pAnalyzer->SetInputFile( m_sDataFile ); |
|
599 |
|
600 // Set rom symbol file. |
|
601 m_pAnalyzer->SetRomSymbolFiles( m_vRomSymbolFiles ); |
|
602 |
|
603 // Set output file if specified |
|
604 if ( ! m_sDataFileOutput.empty() ) |
|
605 { |
|
606 m_pAnalyzer->SetOutputFile( m_sDataFileOutput ); |
|
607 } |
|
608 // Set log level |
|
609 m_pAnalyzer->SetLogLevel( m_iLoggingLevel ); |
|
610 |
|
611 // Analyze |
|
612 return m_pAnalyzer->Analyze(); |
|
613 } |
|
614 |
|
615 int CATProject::RunInstrument() |
|
616 { |
|
617 LOG_FUNC_ENTRY("CATProject::RunInstrument"); |
|
618 // Store attributes |
|
619 if( ! MakeTempDirIfNotExist() ) |
|
620 return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
621 if ( ! WriteAttributes() ) |
|
622 return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
623 if ( m_eBuildSystem == SBS_V1 ) |
|
624 { |
|
625 // Initialize level 1 make file member. |
|
626 if ( ! InitSbs1MakeFileWithPath() ) |
|
627 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
628 // Copy it to temporary folder. |
|
629 CopyMakeFileSbs1ToTemporaryFolder(); |
|
630 // Run export. |
|
631 if( ! RunExportSbs1() ) |
|
632 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
633 // Create level 2 makefiles. |
|
634 if ( ! CreateMakeFileSbs1Level2() ) |
|
635 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
636 } |
|
637 else if ( m_eBuildSystem == SBS_V2 ) |
|
638 { |
|
639 // Create makefile only when using SBS v.2 |
|
640 if ( ! CreateMakeFile() ) |
|
641 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
642 } |
|
643 else |
|
644 { |
|
645 return AT_RETURN_CODE::UNKNOWN; |
|
646 } |
|
647 // Read makefile to get project attributes |
|
648 if ( ! ReadMakeFile() ) |
|
649 return AT_RETURN_CODE::READ_MAKEFILE_ERROR; |
|
650 // Filter unsupported |
|
651 FilterModules(); |
|
652 // Check that we have some "valid" modules to hook |
|
653 if ( m_vModules.size() == 0 &&( m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) ) |
|
654 return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR; |
|
655 |
|
656 // Clean temporary dirs of modules |
|
657 if ( ! CleanTemporaryDirs() ) |
|
658 return AT_RETURN_CODE::CLEANING_TEMP_ERROR; |
|
659 // Create temporary cpps for modulse |
|
660 if (! CreateTemporaryCpps() ) |
|
661 return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR; |
|
662 // Hook modules |
|
663 if (! ModifyModules() ) |
|
664 return AT_RETURN_CODE::MODIFY_MODULES_ERROR; |
|
665 return AT_RETURN_CODE::OK; |
|
666 } |
|
667 |
|
668 int CATProject::RunInstrumentConsole() |
|
669 { |
|
670 LOG_FUNC_ENTRY("CATProject::RunInstrumentConsole"); |
|
671 if( ! MakeTempDirIfNotExist() ) |
|
672 return AT_RETURN_CODE::UNKNOWN; |
|
673 // Store attributes |
|
674 m_bUninstrumented = false; |
|
675 if ( ! WriteAttributes() ) |
|
676 return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
677 // Create makefile |
|
678 if ( ! CreateMakeFile() ) |
|
679 return AT_RETURN_CODE::MAKEFILE_ERROR; |
|
680 // Read makefile to get project attributes |
|
681 if ( ! ReadMakeFile() ) |
|
682 return AT_RETURN_CODE::READ_MAKEFILE_ERROR; |
|
683 // Filter unsupported |
|
684 FilterModules(); |
|
685 // Check that we have some "valid" modules to hook |
|
686 if ( m_vModules.size() == 0 &&( m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) ) |
|
687 return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR; |
|
688 |
|
689 // Clean temporary dirs of modules |
|
690 if ( ! CleanTemporaryDirs() ) |
|
691 return AT_RETURN_CODE::CLEANING_TEMP_ERROR; |
|
692 // Create temporary cpps for modulse |
|
693 if (! CreateTemporaryCpps() ) |
|
694 return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR; |
|
695 // Hook modules |
|
696 if (! ModifyModules() ) |
|
697 return AT_RETURN_CODE::MODIFY_MODULES_ERROR; |
|
698 // Run Reallyclean when using abld. |
|
699 if ( m_eBuildSystem == SBS_V1 ) |
|
700 RunReallyCleanSbs1(); |
|
701 return AT_RETURN_CODE::OK; |
|
702 } |
|
703 |
|
704 int CATProject::RunUninstrument() |
|
705 { |
|
706 LOG_FUNC_ENTRY("CATProject::RunUninstrument"); |
|
707 // Read attributes. |
|
708 if ( ! ReadAttributes() ) |
|
709 return AT_RETURN_CODE::READ_ATTRIBUTES_ERROR; |
|
710 // Init makefile member for this run mode. |
|
711 if ( m_eBuildSystem == SBS_V1 ) |
|
712 InitSbs1MakeFileWithPathToTemp(); |
|
713 // Read makefile to get project attributes |
|
714 if ( ! ReadMakeFile() ) |
|
715 return AT_RETURN_CODE::READ_MAKEFILE_ERROR; |
|
716 // Filter unsupported |
|
717 FilterModules(); |
|
718 // Check that we have some "valid" modules to hook |
|
719 if ( m_vModules.size() == 0 &&( m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) ) |
|
720 return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR; |
|
721 // Create lst files |
|
722 if (! CreateListings() ) |
|
723 return AT_RETURN_CODE::COMPILE_ERROR; |
|
724 // Copy releasables of modules |
|
725 if (! CopyReleasables() ) |
|
726 return AT_RETURN_CODE::RELEASABLES_ERROR; |
|
727 // Restore "unhook" modules |
|
728 if (! RestoreModules() ) |
|
729 return AT_RETURN_CODE::RESTORE_MODULES_ERROR; |
|
730 // Return error code OK |
|
731 return AT_RETURN_CODE::OK; |
|
732 } |
|
733 |
|
734 int CATProject::RunUninstrumentConsole() |
|
735 { |
|
736 LOG_FUNC_ENTRY("CATProject::RunUninstrumentConsole"); |
|
737 int iErrorCode = AT_RETURN_CODE::OK; |
|
738 // Read attributes |
|
739 if ( ReadAttributes() ) |
|
740 { |
|
741 // Init makefile member for this run mode. |
|
742 if ( m_eBuildSystem == SBS_V1 ) |
|
743 InitSbs1MakeFileWithPathToTemp(); |
|
744 // Read makefile to get project attributes |
|
745 if( ReadMakeFile() ) |
|
746 { |
|
747 // Filter unsupported |
|
748 FilterModules(); |
|
749 // Create lst files |
|
750 CreateListings(); |
|
751 if (! CopyReleasables() ) |
|
752 iErrorCode = AT_RETURN_CODE::RELEASABLES_ERROR; |
|
753 } |
|
754 else |
|
755 iErrorCode = AT_RETURN_CODE::READ_MAKEFILE_ERROR; |
|
756 // Change state to uninstrumented and write status |
|
757 m_bUninstrumented = true; |
|
758 if ( ! WriteAttributes() ) |
|
759 iErrorCode = AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR; |
|
760 } |
|
761 else |
|
762 { |
|
763 iErrorCode = AT_RETURN_CODE::READ_ATTRIBUTES_ERROR; |
|
764 } |
|
765 return iErrorCode; |
|
766 } |
|
767 |
|
768 int CATProject::RunUninstrumentFailed() |
|
769 { |
|
770 LOG_FUNC_ENTRY("CATProject::RunUninstrumentFailed"); |
|
771 // Read attributes. |
|
772 if ( ! ReadAttributes() ) |
|
773 return AT_RETURN_CODE::READ_ATTRIBUTES_ERROR; |
|
774 // Init makefile member for this run mode. |
|
775 if ( m_eBuildSystem == SBS_V1 ) |
|
776 InitSbs1MakeFileWithPathToTemp(); |
|
777 // Read makefile to get project attributes |
|
778 if( ReadMakeFile() ) |
|
779 { |
|
780 // Filter modules |
|
781 FilterModules(); |
|
782 // Restore modules to make sure no changes left |
|
783 if( RestoreModules() ) |
|
784 { |
|
785 // Delete temporary dirs of modules |
|
786 if(! DeleteTemporaryDirs() ) |
|
787 { |
|
788 |
|
789 } |
|
790 |
|
791 } |
|
792 else |
|
793 { |
|
794 |
|
795 } |
|
796 } |
|
797 else |
|
798 { |
|
799 |
|
800 } |
|
801 // Projects |
|
802 if ( ! DirDelete( AT_TEMP_DIR, true ) ) |
|
803 { |
|
804 |
|
805 } |
|
806 return AT_RETURN_CODE::OK; |
|
807 } |
|
808 |
|
809 // ---------------------------------------------------------------------------- |
|
810 // Main Functions |
|
811 // ---------------------------------------------------------------------------- |
|
812 void CATProject::DisplayCompileSummary() |
|
813 { |
|
814 LOG_FUNC_ENTRY("CATProject::DisplayCompileSummary"); |
|
815 cout << AT_BUILD_SUMMARY_HEADER; |
|
816 // Supported modules |
|
817 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
818 { |
|
819 // Successful |
|
820 if ( m_vModules.at(i)->GetErrors().empty() ) |
|
821 { |
|
822 // Create build complete file for Carbide xtension |
|
823 m_vModules.at(i)->CreateBuildCompleteFile(); |
|
824 cout << AT_BUILD_SUMMARY_INSTRUMENTED_BUILD_COMPLETE |
|
825 << GetPathOrFileName( true, m_vModules.at(i)->GetMmpFile() ) |
|
826 << endl |
|
827 << AT_BUILD_SUMMARY_TARGET |
|
828 << m_vModules.at(i)->GetBinaryName() |
|
829 << endl; |
|
830 // Datafiles |
|
831 // Use module data file name if project's data file not defined. |
|
832 if ( m_eLoggingMode == CATProject::FILE |
|
833 && m_vModules.at(i)->GetTargetType().compare("exe") == 0 ) |
|
834 { |
|
835 cout << AT_BUILD_SUMMARY_DATA_FILE_NAME |
|
836 << m_vModules.at(i)->GetS60FileName() |
|
837 << endl; |
|
838 |
|
839 // if filePath not empty, use it for log file |
|
840 if ( !m_sS60FilePath.empty() ) |
|
841 { |
|
842 cout << AT_BUILD_SUMMARY_DATA_FILE_PATH |
|
843 << m_sS60FilePath |
|
844 << endl; |
|
845 } |
|
846 } |
|
847 } |
|
848 else |
|
849 { |
|
850 // Failed |
|
851 cout << AT_BUILD_SUMMARY_FAILED |
|
852 << GetPathOrFileName( true, m_vModules.at(i)->GetMmpFile() ) |
|
853 << endl |
|
854 << AT_BUILD_SUMMARY_TARGET |
|
855 << m_vModules.at(i)->GetBinaryName() |
|
856 << endl; |
|
857 // Print errors. |
|
858 cout << AT_BUILD_SUMMARY_ERRORS |
|
859 << m_vModules.at(i)->GetErrors() |
|
860 << endl; |
|
861 } |
|
862 } |
|
863 |
|
864 // Static libraries |
|
865 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
866 { |
|
867 if ( m_vStaticLibraries.at(i)->GetErrors().empty() ) |
|
868 { |
|
869 cout << AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE |
|
870 << GetPathOrFileName( true, m_vStaticLibraries.at(i)->GetMmpFile()) |
|
871 << endl |
|
872 << AT_BUILD_SUMMARY_TARGET |
|
873 << m_vStaticLibraries.at(i)->GetBinaryName() |
|
874 << endl |
|
875 << AT_BUILD_SUMMARY_STATIC_LIBRARY |
|
876 << endl; |
|
877 |
|
878 } |
|
879 else |
|
880 { |
|
881 // Failed |
|
882 cout << AT_BUILD_SUMMARY_FAILED |
|
883 << GetPathOrFileName( true, m_vStaticLibraries.at(i)->GetMmpFile() ) |
|
884 << endl |
|
885 << AT_BUILD_SUMMARY_TARGET |
|
886 << m_vStaticLibraries.at(i)->GetBinaryName() |
|
887 << endl; |
|
888 // Print errors. |
|
889 cout << AT_BUILD_SUMMARY_ERRORS |
|
890 << m_vStaticLibraries.at(i)->GetErrors() |
|
891 << endl; |
|
892 } |
|
893 } |
|
894 |
|
895 // Unsupported modules |
|
896 for( size_t i = 0; i < m_vUnsupportedModules.size(); i++ ) |
|
897 { |
|
898 cout << AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE |
|
899 << GetPathOrFileName( true, m_vUnsupportedModules.at(i)->GetMmpFile() ) |
|
900 << endl |
|
901 << AT_BUILD_SUMMARY_TARGET |
|
902 << m_vUnsupportedModules.at(i)->GetBinaryName() |
|
903 << endl; |
|
904 cout << m_vUnsupportedModules.at(i)->GetCompileInfoText() << endl; |
|
905 } |
|
906 } |
|
907 |
|
908 void CATProject::DisplayBuildSummary( void ) |
|
909 { |
|
910 LOG_FUNC_ENTRY("CATProject::DisplayBuildSummary"); |
|
911 cout << endl; |
|
912 // Build information |
|
913 cout << AT_BUILD_SUMMARY_BUILD_TYPE << GetBuildTypeString() << endl; |
|
914 // Platform |
|
915 cout << AT_BUILD_SUMMARY_BUILD_PLATFORM << m_sPlatform << endl; |
|
916 // Possible variant |
|
917 if ( ! m_sVariant.empty() ) |
|
918 cout << AT_BUILD_SUMMARY_BUILD_VARIANT << m_sVariant << endl; |
|
919 // Logging mode |
|
920 cout << AT_BUILD_SUMMARY_LOGGING_MODE; |
|
921 if ( m_eLoggingMode == FILE ) |
|
922 cout << AT_BUILD_SUMMARY_FILE; |
|
923 else if ( m_eLoggingMode == TRACE ) |
|
924 cout << AT_BUILD_SUMMARY_TRACE; |
|
925 else if ( m_eLoggingMode == TRACE_FAST ) |
|
926 cout << AT_BUILD_SUMMARY_TRACE_FAST; |
|
927 cout << endl; |
|
928 // Call stack sizes |
|
929 cout << AT_BUILD_SUMMARY_ALLOC_CALL_STACK_SIZE |
|
930 << m_iAllocCallStackSize |
|
931 << endl; |
|
932 cout << AT_BUILD_SUMMARY_FREE_CALL_STACK_SIZE |
|
933 << m_iFreeCallStackSize |
|
934 << endl; |
|
935 |
|
936 if(!_stricmp(m_sPlatform.c_str(), ("winscw"))) |
|
937 { |
|
938 //print version info only when version is not up-to-date |
|
939 cout << endl; |
|
940 showDbgHelpVersionInfo( false ); |
|
941 } |
|
942 } |
|
943 |
|
944 bool CATProject::CreateMakeFile() |
|
945 { |
|
946 switch ( m_eBuildSystem ) |
|
947 { |
|
948 case SBS_V1: |
|
949 if( ! CreateMakeFileSbs1() ) |
|
950 return false; |
|
951 // Copy main make file. |
|
952 if( ! CopyMakeFileSbs1ToTemporaryFolder() ) |
|
953 return false; |
|
954 // Run export. |
|
955 if( ! RunExportSbs1() ) |
|
956 return false; |
|
957 // Create level 2 makefiles. |
|
958 if( ! CreateMakeFileSbs1Level2() ) |
|
959 return false; |
|
960 return true; |
|
961 case SBS_V2: |
|
962 return CreateMakeFileSbs2(); |
|
963 default: |
|
964 return false; |
|
965 } |
|
966 } |
|
967 |
|
968 bool CATProject::CreateMakeFileSbs1() |
|
969 { |
|
970 LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs1"); |
|
971 |
|
972 // If variant defined check does it exist. |
|
973 if( ! m_sVariant.empty() ) |
|
974 { |
|
975 if ( ! CheckVariant( m_sEpocRoot, m_sVariant ) ) |
|
976 { |
|
977 cout << INVALID_VARIANT_ERROR; |
|
978 if ( IsDefaultVariant( m_sEpocRoot ) ) |
|
979 { |
|
980 m_sVariant = "default"; |
|
981 cout << USING_DEFAULT_VARIANT_MESSAGE; |
|
982 if ( ! WriteAttributes() ) |
|
983 return false; |
|
984 } |
|
985 else |
|
986 { |
|
987 cout << NO_DEFAULT_VARIANT_ERROR; |
|
988 return false; |
|
989 } |
|
990 } |
|
991 } |
|
992 |
|
993 // Create level 1 make file. |
|
994 string sCmd( "bldmake bldfiles " ); |
|
995 sCmd.append( m_sPlatform ); |
|
996 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
997 (void)system( sCmd.c_str() ); |
|
998 return InitSbs1MakeFileWithPath(); |
|
999 } |
|
1000 |
|
1001 bool CATProject::CopyMakeFileSbs1ToTemporaryFolder() |
|
1002 { |
|
1003 LOG_FUNC_ENTRY("CATProject::CopyMakeFileSbs1ToTemporaryFolder"); |
|
1004 // Check that temporary dir exists if not create it. |
|
1005 if ( ! MakeTempDirIfNotExist() ) |
|
1006 return false; |
|
1007 // Copy makefile to temporary directory |
|
1008 string sMakeFileInTemp( AT_TEMP_DIR ); |
|
1009 sMakeFileInTemp.append( "\\" ); |
|
1010 sMakeFileInTemp.append( AT_LEVEL_1_MAKEFILE_NAME ); |
|
1011 if ( ! FileCopyToPath( m_sMakeFile, sMakeFileInTemp ) ) |
|
1012 return false; |
|
1013 return true; |
|
1014 |
|
1015 } |
|
1016 |
|
1017 bool CATProject::RunReallyCleanSbs1() |
|
1018 { |
|
1019 LOG_FUNC_ENTRY("CATProject::RunReallyCleanSbs1"); |
|
1020 // Check that abld.bat has been made. |
|
1021 if ( ! FileExists( "abld.bat" ) ) |
|
1022 return false; |
|
1023 // Run reallyclean. |
|
1024 string sCmd; |
|
1025 if ( m_bAbldTest ) |
|
1026 sCmd = "abld test reallyclean "; |
|
1027 else |
|
1028 sCmd = "abld reallyclean "; |
|
1029 sCmd.append( m_sPlatform ); |
|
1030 if ( ! m_sVariant.empty() ) |
|
1031 { |
|
1032 sCmd.append( "." ); |
|
1033 sCmd.append( m_sVariant ); |
|
1034 } |
|
1035 sCmd.append( " " ); |
|
1036 sCmd.append( GetBuildTypeString() ); |
|
1037 if ( m_vTargetModules.size() > 1 ) |
|
1038 { |
|
1039 RunAbldCommandToAllTargets( sCmd ); |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 AddTargetModuleIfDefined( sCmd ); |
|
1044 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1045 (void) system( sCmd.c_str() ); |
|
1046 } |
|
1047 return true; |
|
1048 } |
|
1049 |
|
1050 bool CATProject::RunReallyCleanSbs2() |
|
1051 { |
|
1052 LOG_FUNC_ENTRY("CATProject::RunReallyCleanSbs2"); |
|
1053 string sCmd(""); |
|
1054 if ( m_sBuildCommand.empty() ) |
|
1055 { |
|
1056 // If no build command defined (not found in project.cfg). |
|
1057 sCmd.append( RAPTOR_CMD_BASE );; |
|
1058 sCmd.append( m_sPlatform ); |
|
1059 sCmd.append( "_" ); |
|
1060 sCmd.append( GetBuildTypeString() ); |
|
1061 if ( ! m_sVariant.empty() ) |
|
1062 { |
|
1063 sCmd.append( "." ); |
|
1064 sCmd.append( m_sVariant ); |
|
1065 } |
|
1066 sCmd.append( RAPTOR_REALLYCLEAN_LOG ); |
|
1067 AddTargetModuleIfDefined( sCmd ); |
|
1068 sCmd.append( " REALLYCLEAN" ); |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 // When build command set use it. |
|
1073 sCmd.append( m_sBuildCommand ); |
|
1074 sCmd.append( RAPTOR_REALLYCLEAN_LOG ); |
|
1075 sCmd.append( " REALLYCLEAN" ); |
|
1076 } |
|
1077 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1078 int iRet = (int)system( sCmd.c_str() ); |
|
1079 if ( iRet == 0 ) |
|
1080 return true; |
|
1081 return false; |
|
1082 } |
|
1083 |
|
1084 bool CATProject::RunExportSbs1() |
|
1085 { |
|
1086 LOG_FUNC_ENTRY("CATProject::RunExportSbs1"); |
|
1087 // Run export. |
|
1088 string sCmd; |
|
1089 if ( m_bAbldTest ) |
|
1090 sCmd = "abld test export"; |
|
1091 else |
|
1092 sCmd = "abld export"; |
|
1093 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1094 (void) system( sCmd.c_str() ); |
|
1095 return true; |
|
1096 } |
|
1097 |
|
1098 bool CATProject::CreateMakeFileSbs1Level2() |
|
1099 { |
|
1100 LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs1Level2"); |
|
1101 // Create level 2 makefiles. |
|
1102 |
|
1103 string sCmd; |
|
1104 |
|
1105 if ( m_bAbldTest ) |
|
1106 sCmd ="abld test makefile "; |
|
1107 else |
|
1108 sCmd ="abld makefile "; |
|
1109 |
|
1110 sCmd.append( m_sPlatform ); |
|
1111 if ( ! m_sVariant.empty() ) |
|
1112 { |
|
1113 sCmd.append( "." ); |
|
1114 sCmd.append( m_sVariant ); |
|
1115 } |
|
1116 |
|
1117 // Check if multiple targets defined and sbs 1. |
|
1118 if ( m_vTargetModules.size() > 1 ) |
|
1119 { |
|
1120 RunAbldCommandToAllTargets( sCmd ); |
|
1121 } |
|
1122 else |
|
1123 { |
|
1124 AddTargetModuleIfDefined( sCmd ); |
|
1125 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1126 (void) system( sCmd.c_str() ); |
|
1127 } |
|
1128 return true; |
|
1129 } |
|
1130 |
|
1131 bool CATProject::CreateMakeFileSbs2() |
|
1132 { |
|
1133 LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs2"); |
|
1134 // Delete build directory if it exists before creating new makefiles. |
|
1135 if ( DirectoryExists( "atool_temp\\build" ) ) |
|
1136 DirDelete( "atool_temp\\build", true ); |
|
1137 // Create command to create makefiles. |
|
1138 string sCmd( m_sBuildCommand ); |
|
1139 sCmd.append( " " ); |
|
1140 sCmd.append( RAPTOR_MAKEFILE_SWITCH ); |
|
1141 sCmd.append( " " ); |
|
1142 sCmd.append( RAPTOR_NOBUILD_SWITCH ); |
|
1143 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1144 int iRet = (int)system( sCmd.c_str() ); |
|
1145 if ( iRet == 0 ) |
|
1146 return true; |
|
1147 return false; |
|
1148 } |
|
1149 |
|
1150 bool CATProject::ReadMakeFile() |
|
1151 { |
|
1152 // Clean modules before reading. |
|
1153 CleanModuleVectors(); |
|
1154 if ( m_eBuildSystem == SBS_V1 ) |
|
1155 { |
|
1156 // Read level 1 makefile which contains module name and makefiles. |
|
1157 if( ! ReadMakeFileSbs1Level1() ) |
|
1158 return false; |
|
1159 // Read level 2 makefiles. |
|
1160 vector<CATModule2*>::iterator it; |
|
1161 // If we are compiling or etc... we need to create temporary directories. |
|
1162 if ( m_eMode == COMPILE || m_eMode == INSTRUMENT || m_eMode == INSTRUMENT_CONSOLE ) |
|
1163 { |
|
1164 // Read make makefiles from /epoc32/build... and create temporary directory. |
|
1165 bool bLevel2 = true; |
|
1166 for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ ) |
|
1167 { |
|
1168 if( ! (*it)->CreateTemporaryDirectory() ) |
|
1169 return false; |
|
1170 if( ! (*it)->ReadMakeFile() ) |
|
1171 { |
|
1172 bLevel2 = false; |
|
1173 break; |
|
1174 } |
|
1175 } |
|
1176 // If failed reading modules from level 2 makefiles. |
|
1177 if ( ! bLevel2 ) |
|
1178 { |
|
1179 // Clean modules. |
|
1180 CleanModuleVectors(); |
|
1181 // Try use default variant if it exists. |
|
1182 if ( CheckVariant( m_sEpocRoot, "default" ) ) |
|
1183 { |
|
1184 m_sVariant = "default"; |
|
1185 cout << USING_DEFAULT_VARIANT_MESSAGE; |
|
1186 if ( ! WriteAttributes() ) |
|
1187 return false; |
|
1188 if ( ! InitSbs1MakeFileWithPath() ) |
|
1189 return false; |
|
1190 if ( ! ReadMakeFileSbs1Level1() ) |
|
1191 return false; |
|
1192 for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ ) |
|
1193 { |
|
1194 if( ! (*it)->CreateTemporaryDirectory() ) |
|
1195 return false; |
|
1196 if( ! (*it)->ReadMakeFile() ) |
|
1197 return false; |
|
1198 } |
|
1199 |
|
1200 } |
|
1201 } |
|
1202 } |
|
1203 else |
|
1204 { |
|
1205 // Read make files from temporary directories. |
|
1206 for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ ) |
|
1207 { |
|
1208 if ( ! (*it)->ReadMakeFileFromTemp() ) |
|
1209 return false; |
|
1210 } |
|
1211 } |
|
1212 return true; |
|
1213 } |
|
1214 else if ( m_eBuildSystem == SBS_V2 ) |
|
1215 { |
|
1216 // Read make file. |
|
1217 if( ! ReadMakeFileSbs2() ) |
|
1218 return false; |
|
1219 // Create module temporary directories if we are compiling or etc... |
|
1220 if ( m_eMode == COMPILE || m_eMode == INSTRUMENT || m_eMode == INSTRUMENT_CONSOLE ) |
|
1221 { |
|
1222 for( vector<CATModule2*>::iterator it = m_vModules.begin(); it < m_vModules.end(); it++ ) |
|
1223 (*it)->CreateTemporaryDirectory(); |
|
1224 for( vector<CATModule2*>::iterator it = m_vStaticLibraries.begin(); it < m_vStaticLibraries.end(); it++ ) |
|
1225 (*it)->CreateTemporaryDirectory(); |
|
1226 } |
|
1227 } |
|
1228 return true; |
|
1229 } |
|
1230 |
|
1231 bool CATProject::ReadMakeFileSbs1Level1() |
|
1232 { |
|
1233 LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs1Level1"); |
|
1234 |
|
1235 bool bRet = false; |
|
1236 |
|
1237 //Try to open makefile |
|
1238 ifstream in; |
|
1239 in.open( m_sMakeFile.c_str() ); |
|
1240 |
|
1241 //File open ok? |
|
1242 if( !in.good() ) |
|
1243 { |
|
1244 printf( "Can not open file: %s\n", m_sMakeFile.c_str() ); |
|
1245 in.close(); |
|
1246 return bRet; |
|
1247 } |
|
1248 |
|
1249 // Add also these so "compatible with sbs2". |
|
1250 // Releasables path (binaries). |
|
1251 string sReleasePath( m_sEpocRoot ); |
|
1252 // add trailing '\' if root path is missing it |
|
1253 if ( sReleasePath.size() < 1 ) |
|
1254 sReleasePath.append( "\\" ); |
|
1255 else if ( sReleasePath.at( sReleasePath.length() -1 ) != '\\' ) |
|
1256 sReleasePath.append( "\\" ); |
|
1257 sReleasePath.append( "epoc32\\release" ); |
|
1258 string sFullVariantPath( m_sPlatform ); |
|
1259 sFullVariantPath.append( "\\" ); |
|
1260 sFullVariantPath.append( GetBuildTypeString() ); |
|
1261 |
|
1262 char cTemp[MAX_LINE_LENGTH]; |
|
1263 bool bContinueSearch = true; |
|
1264 bool bMmpInfoFound = false; |
|
1265 CATModule2* pModule = 0; |
|
1266 string sTempLineFromFile; |
|
1267 string sMmpFileSearchString; |
|
1268 if ( m_bAbldTest ) |
|
1269 sMmpFileSearchString = MMPTESTFILE_SEARCH_STRING; |
|
1270 else |
|
1271 sMmpFileSearchString = MMPFILE_SEARCH_STRING; |
|
1272 do |
|
1273 { |
|
1274 // get line from file |
|
1275 in.getline( cTemp, MAX_LINE_LENGTH ); |
|
1276 sTempLineFromFile.clear(); |
|
1277 sTempLineFromFile.append( cTemp ); |
|
1278 |
|
1279 //Search makefile string |
|
1280 if( sTempLineFromFile.find( MAKEFILE_SEARCH_STRING ) != string::npos ) |
|
1281 { |
|
1282 bMmpInfoFound = true; |
|
1283 if( sTempLineFromFile.find( sMmpFileSearchString ) != string::npos ) |
|
1284 { |
|
1285 bRet = true; |
|
1286 //Parse mmp path + mmp filename |
|
1287 sTempLineFromFile.erase( 0, sTempLineFromFile.find_first_of("\"") ); |
|
1288 sTempLineFromFile.erase( 0, 1 ); |
|
1289 |
|
1290 string sPath = sTempLineFromFile.substr(0, sTempLineFromFile.find_first_of("\"") ); |
|
1291 |
|
1292 sPath = ChangeSlashToBackSlash( sPath ); |
|
1293 //Remove text "bld.inf" |
|
1294 sPath.erase( (sPath.find_last_of( "\\" ) + 1) , string::npos ); |
|
1295 |
|
1296 string sFileName = sTempLineFromFile.substr( (sTempLineFromFile.find( sMmpFileSearchString ) + sMmpFileSearchString.length() + 3), string::npos ); |
|
1297 sFileName = ChangeSlashToBackSlash( sFileName ); |
|
1298 sFileName = sFileName.substr( 0, sFileName.find_first_of("\"") ); |
|
1299 |
|
1300 // Append .mmp to filename if it does not exist |
|
1301 if ( sFileName.find(".mmp") == string::npos ) |
|
1302 sFileName.append(".mmp"); |
|
1303 |
|
1304 //Insert drive letter |
|
1305 sPath.insert(0, string( m_cCurrentDir).substr(0,2) ); |
|
1306 |
|
1307 //Insert mmp file to the end |
|
1308 sPath.append( sFileName ); |
|
1309 |
|
1310 ChangeToLower( sPath ); |
|
1311 |
|
1312 // If target programs defined find from those or do not |
|
1313 // add module to vector. |
|
1314 bool bAddToVector = true; |
|
1315 if ( m_vTargetModules.size() > 0 ) |
|
1316 { |
|
1317 bAddToVector = false; |
|
1318 vector<string>::iterator it; |
|
1319 for( it = m_vTargetModules.begin() ; it != m_vTargetModules.end() ; it++ ) |
|
1320 { |
|
1321 string sFind( *it ); |
|
1322 sFind.insert( 0, "\\" ); |
|
1323 if ( sPath.find( sFind ) != string::npos ) |
|
1324 { |
|
1325 bAddToVector = true; |
|
1326 break; |
|
1327 } |
|
1328 } |
|
1329 } |
|
1330 |
|
1331 if ( bAddToVector ) |
|
1332 { |
|
1333 pModule = new CATModule2(); |
|
1334 pModule->SetMmpFile( sPath ); |
|
1335 pModule->SetVariantType( GetBuildTypeString() ); |
|
1336 pModule->SetVariantPlatform( m_sPlatform ); |
|
1337 pModule->SetReleasePath( sReleasePath ); |
|
1338 pModule->SetFullVariantPath( sFullVariantPath ); |
|
1339 pModule->SetBuildSystem( SBS_V1 ); |
|
1340 m_vModules.push_back( pModule ); |
|
1341 } |
|
1342 } |
|
1343 } |
|
1344 else if( bMmpInfoFound ) |
|
1345 //Do not continue search if mmp info lines are all handled |
|
1346 bContinueSearch = false; |
|
1347 if( !in.good() ) |
|
1348 bContinueSearch = false; |
|
1349 } |
|
1350 while( bContinueSearch ); |
|
1351 |
|
1352 bContinueSearch = true; |
|
1353 |
|
1354 //Search MAKEFILES for invidual modules |
|
1355 do |
|
1356 { |
|
1357 in.getline( cTemp, MAX_LINE_LENGTH ); |
|
1358 sTempLineFromFile.clear(); |
|
1359 sTempLineFromFile.append( cTemp ); |
|
1360 // find the lines 'MAKEFILE[modulename]_FILES' |
|
1361 if( (sTempLineFromFile.find( "MAKEFILE" ) == 0) && (sTempLineFromFile.find( "_FILES" ) != string::npos) ) |
|
1362 { |
|
1363 //Math the makefile line with one of our modules |
|
1364 for( size_t i = 0 ; i < m_vModules.size() ; i++ ) |
|
1365 { |
|
1366 //Create name |
|
1367 string sMakeFile( "MAKEFILE" ); |
|
1368 string sTempMmpFile( RemovePathAndExt( m_vModules.at(i)->GetMmpFile(), true ) ); |
|
1369 ChangeToUpper( sTempMmpFile ); |
|
1370 sMakeFile.append( sTempMmpFile ); |
|
1371 sMakeFile.append( "_FILES" ); |
|
1372 // matched |
|
1373 if( sTempLineFromFile.find( sMakeFile ) != string::npos ) |
|
1374 { |
|
1375 //parse the makefile name from line |
|
1376 in.getline( cTemp, MAX_LINE_LENGTH ); |
|
1377 sTempLineFromFile.clear(); |
|
1378 sTempLineFromFile.append( cTemp ); |
|
1379 //Remove character "\"" |
|
1380 sTempLineFromFile.erase( 0, ( sTempLineFromFile.find_first_of("\"") + 1 ) ); |
|
1381 // in winscw last part is '" \' and on armd '"' so remove all after last '"' |
|
1382 sTempLineFromFile.erase( sTempLineFromFile.find_last_of("\""), sTempLineFromFile.size() ); |
|
1383 // Set correct makefile for module |
|
1384 m_vModules.at( i )->SetMakeFile( sTempLineFromFile ); |
|
1385 // break |
|
1386 break; |
|
1387 } // If mathed to mmp |
|
1388 } // End of mmp file loop |
|
1389 } // found lines 'MAKEFILE[modulename]_FILES' |
|
1390 if( !in.good() ) |
|
1391 bContinueSearch = false; |
|
1392 } |
|
1393 while( bContinueSearch ); |
|
1394 in.close(); |
|
1395 return bRet; |
|
1396 } |
|
1397 |
|
1398 bool CATProject::ReadMakeFileSbs2( void ) |
|
1399 { |
|
1400 LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs2(void)"); |
|
1401 // File is by default named make_build.default but when building specific layer |
|
1402 // make_build_LAYERNAME.default is produced by Raptor. |
|
1403 // So find makefile(s) and read them. |
|
1404 vector<string> vMakeFiles = DirList( "atool_temp\\build\\", false, true ); |
|
1405 bool bRet = true; |
|
1406 for( vector<string>::iterator it = vMakeFiles.begin(); it != vMakeFiles.end() ; it++ ) |
|
1407 { |
|
1408 // Recognize multiple makefiles. |
|
1409 if ( it->find("make_build_") != string::npos && it->find(".default") != string::npos ) |
|
1410 { |
|
1411 if ( ! ReadMakeFileSbs2( *it ) ) |
|
1412 bRet = false; |
|
1413 } |
|
1414 // Single makefile. |
|
1415 else if ( it->find( "make_build.default" ) != string::npos ) |
|
1416 { |
|
1417 if ( ! ReadMakeFileSbs2( *it ) ) |
|
1418 bRet = false; |
|
1419 } |
|
1420 } |
|
1421 // We got some modules? |
|
1422 if ( m_vModules.size() == 0 ) |
|
1423 bRet = false; |
|
1424 return bRet; |
|
1425 } |
|
1426 |
|
1427 bool CATProject::ReadMakeFileSbs2( string& sMakeFile ) |
|
1428 { |
|
1429 LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs2(string)"); |
|
1430 try { |
|
1431 // Open file |
|
1432 ifstream in; |
|
1433 in.open( sMakeFile.c_str() , ios_base::in ); |
|
1434 // Check that open ok |
|
1435 if ( ! in.good() ) |
|
1436 { |
|
1437 cout << AT_MSG << "Error, opening file " |
|
1438 << RAPTOR_MAKEFILE << endl; |
|
1439 in.close(); |
|
1440 return false; |
|
1441 } |
|
1442 // Source line from file |
|
1443 string sSourceLine; |
|
1444 // Module pointer |
|
1445 CATModule2* pModule = 0; |
|
1446 // Are we looking for module attributes |
|
1447 bool bFindAttributes = false; |
|
1448 // Until end of file |
|
1449 while( in.good() ) |
|
1450 { |
|
1451 // Get new line from file |
|
1452 string sLine; |
|
1453 getline(in, sLine); |
|
1454 // New module |
|
1455 if ( sLine.find( RAPTOR_PROJECT_META ) == 0 ) |
|
1456 { |
|
1457 // Remove project_meta from line |
|
1458 sLine.erase(0, strlen( RAPTOR_PROJECT_META ) ); |
|
1459 LOG_STRING("Found module: " << sLine ); |
|
1460 // Check is name empty |
|
1461 // This seems to happen when sbs2 "wraps" i.e. mifconv to a module type item |
|
1462 if ( sLine.empty() ) |
|
1463 { |
|
1464 LOG_STRING("skipping empty module"); |
|
1465 // Skip it |
|
1466 continue; |
|
1467 } |
|
1468 // If module add it to vector |
|
1469 if ( pModule ) |
|
1470 { |
|
1471 // Add sources, |
|
1472 pModule->AddSources( sSourceLine ); |
|
1473 // Build system. |
|
1474 pModule->SetBuildSystem( SBS_V1 ); |
|
1475 // Push to vector. |
|
1476 m_vModules.push_back( pModule ); |
|
1477 } |
|
1478 // New module |
|
1479 pModule = new CATModule2(); |
|
1480 // Clear sourceline |
|
1481 sSourceLine.clear(); |
|
1482 // Set modules mmp with path |
|
1483 |
|
1484 if ( ! pModule->SetMmpFile( sLine ) ) |
|
1485 { |
|
1486 // Fatal error setting mmp file |
|
1487 in.close(); |
|
1488 return false; |
|
1489 } |
|
1490 // Find attributes on |
|
1491 bFindAttributes = true; |
|
1492 // Get new line from file |
|
1493 getline(in, sLine); |
|
1494 } |
|
1495 // If attribute finding on |
|
1496 if ( bFindAttributes ) |
|
1497 { |
|
1498 // Pickup modules attributes |
|
1499 if ( sLine.find ( RAPTOR_SOURCE ) == 0 ) |
|
1500 { |
|
1501 sLine.erase(0, strlen( RAPTOR_SOURCE ) ); |
|
1502 sSourceLine = sLine; |
|
1503 } |
|
1504 else if ( sLine.find ( RAPTOR_TARGET ) == 0 ) |
|
1505 { |
|
1506 sLine.erase(0, strlen( RAPTOR_TARGET ) ); |
|
1507 pModule->SetTarget( sLine ); |
|
1508 } |
|
1509 else if ( sLine.find ( RAPTOR_TARGETYPE ) == 0 ) |
|
1510 { |
|
1511 sLine.erase(0, strlen( RAPTOR_TARGETYPE )); |
|
1512 pModule->SetTargetType( sLine ); |
|
1513 } |
|
1514 else if ( sLine.find( RAPTOR_REQUESTEDTARGETEXT ) == 0 ) |
|
1515 { |
|
1516 sLine.erase(0, strlen( RAPTOR_REQUESTEDTARGETEXT ) ); |
|
1517 pModule->SetRequestedTargetExt( sLine ); |
|
1518 } |
|
1519 else if ( sLine.find ( RAPTOR_VARIANTPLATFORM ) == 0 ) |
|
1520 { |
|
1521 sLine.erase(0, strlen( RAPTOR_VARIANTPLATFORM )); |
|
1522 pModule->SetVariantPlatform( sLine ); |
|
1523 } |
|
1524 else if ( sLine.find ( RAPTOR_VARIANTTYPE ) == 0 ) |
|
1525 { |
|
1526 sLine.erase(0, strlen( RAPTOR_VARIANTTYPE )); |
|
1527 pModule->SetVariantType( sLine ); |
|
1528 } |
|
1529 else if ( sLine.find ( RAPTOR_FEATUREVARIANT ) == 0 ) |
|
1530 { |
|
1531 sLine.erase(0, strlen( RAPTOR_FEATUREVARIANT )); |
|
1532 pModule->SetFeatureVariant( sLine ); |
|
1533 } |
|
1534 else if ( sLine.find ( RAPTOR_FEATUREVARIANTNAME ) == 0 ) |
|
1535 { |
|
1536 sLine.erase(0, strlen( RAPTOR_FEATUREVARIANTNAME )); |
|
1537 pModule->SetFeatureVariantName( sLine ); |
|
1538 } |
|
1539 else if ( sLine.find ( RAPTOR_RELEASEPATH ) == 0 ) |
|
1540 { |
|
1541 sLine.erase(0, strlen( RAPTOR_RELEASEPATH )); |
|
1542 pModule->SetReleasePath( sLine ); |
|
1543 } |
|
1544 else if ( sLine.find ( RAPTOR_FULLVARIANTPATH ) == 0 ) |
|
1545 { |
|
1546 sLine.erase(0, strlen( RAPTOR_FULLVARIANTPATH )); |
|
1547 pModule->SetFullVariantPath( sLine ); |
|
1548 } |
|
1549 else if ( sLine.find ( RAPTOR_COMPILE_DEFINITIONS ) == 0 ) |
|
1550 { |
|
1551 sLine.erase(0, strlen( RAPTOR_COMPILE_DEFINITIONS ) ); |
|
1552 pModule->SetCompileDefinitions( sLine ); |
|
1553 } |
|
1554 } |
|
1555 } // while in.good() |
|
1556 // Add last module if n number of modules found |
|
1557 if ( pModule ) |
|
1558 { |
|
1559 if ( ! pModule->GetTarget().empty() ) |
|
1560 { |
|
1561 // Add sources |
|
1562 pModule->AddSources( sSourceLine ); |
|
1563 // Build system. |
|
1564 pModule->SetBuildSystem( SBS_V1 ); |
|
1565 // Push back to vector |
|
1566 m_vModules.push_back( pModule ); |
|
1567 } |
|
1568 } |
|
1569 // Close file |
|
1570 in.close(); |
|
1571 return true; |
|
1572 } // try. |
|
1573 catch(...) |
|
1574 { |
|
1575 LOG_STRING("Unexpected exception reading sbs 2 makefile"); |
|
1576 return false; |
|
1577 } |
|
1578 } |
|
1579 bool CATProject::CreateTemporaryDirectories() |
|
1580 { |
|
1581 LOG_FUNC_ENTRY("CATProject::CreateTemporaryDirectories"); |
|
1582 bool bRet = true; |
|
1583 for( size_t i = 0 ; i < m_vModules.size(); i++) |
|
1584 { |
|
1585 if( ! m_vModules.at(i)->CreateTemporaryDirectory() ) |
|
1586 bRet = false; |
|
1587 } |
|
1588 for( size_t i = 0 ; i < m_vStaticLibraries.size(); i++) |
|
1589 { |
|
1590 if( ! m_vStaticLibraries.at(i)->CreateTemporaryDirectory() ) |
|
1591 bRet = false; |
|
1592 } |
|
1593 return bRet; |
|
1594 |
|
1595 } |
|
1596 |
|
1597 bool CATProject::CreateTemporaryCpps() |
|
1598 { |
|
1599 LOG_FUNC_ENTRY("CATProject::CreateTemporaryCpps"); |
|
1600 bool bRet = true; |
|
1601 for( size_t i = 0 ; i < m_vModules.size(); i++) |
|
1602 { |
|
1603 if( ! m_vModules.at(i)->CreateTempCpp( |
|
1604 m_sS60FileName, m_sS60FilePath, m_eLoggingMode, m_eBuildType, m_iAllocCallStackSize, m_iFreeCallStackSize ) ) |
|
1605 bRet = false; |
|
1606 } |
|
1607 return bRet; |
|
1608 } |
|
1609 |
|
1610 bool CATProject::FilterModules() |
|
1611 { |
|
1612 LOG_FUNC_ENTRY("CATProject::FilterModules"); |
|
1613 vector<CATModule2*>::iterator it; |
|
1614 // Loop thru modules. |
|
1615 it = m_vModules.begin(); |
|
1616 while( it != m_vModules.end() ) |
|
1617 { |
|
1618 // Get target type of module to separate string (will be modified). |
|
1619 string sTargetType = (*it)->GetTargetType(); |
|
1620 // Modules compile definitions. |
|
1621 string sCompileDefinition = (*it)->GetCompileDefinitions(); |
|
1622 // Check is it supported. |
|
1623 if ( !IsTargetTypeSupported( sTargetType) ) |
|
1624 { |
|
1625 (*it)->SetCompileInfoText( AT_UNSUPPORTED_TARGET_TYPE ); |
|
1626 // Not supported add to not supported vector. |
|
1627 m_vUnsupportedModules.push_back( *it ); |
|
1628 // Erase cell. |
|
1629 it = m_vModules.erase( it ); |
|
1630 } |
|
1631 // Check if its static library |
|
1632 else if ( _stricmp( sTargetType.c_str(), "lib" ) == 0 ) |
|
1633 { |
|
1634 // Static librarie move to their vector. |
|
1635 m_vStaticLibraries.push_back( *it ); |
|
1636 // Erase cell. |
|
1637 it = m_vModules.erase( it ); |
|
1638 |
|
1639 } |
|
1640 else if ( sCompileDefinition.find( KERNEL_MODE_COMPILE_DEFINITION ) != string::npos ) |
|
1641 { |
|
1642 (*it)->SetCompileInfoText( AT_UNSUPPORTED_COMPILE_DEFINITION ); |
|
1643 // Not supported add to not supported vector. |
|
1644 m_vUnsupportedModules.push_back( *it ); |
|
1645 // Erase cell. |
|
1646 it = m_vModules.erase( it ); |
|
1647 } |
|
1648 else |
|
1649 it++; |
|
1650 } |
|
1651 return true; |
|
1652 } |
|
1653 |
|
1654 bool CATProject::ModifyModules() |
|
1655 { |
|
1656 LOG_FUNC_ENTRY("CATProject::ModifyModules"); |
|
1657 bool bRet = true; |
|
1658 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1659 { |
|
1660 if (! m_vModules.at(i)->ModifyMmp() ) |
|
1661 bRet = false; |
|
1662 } |
|
1663 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
1664 { |
|
1665 if (! m_vStaticLibraries.at(i)->ModifyMmp() ) |
|
1666 bRet = false; |
|
1667 } |
|
1668 return bRet; |
|
1669 } |
|
1670 |
|
1671 bool CATProject::RestoreModules() |
|
1672 { |
|
1673 LOG_FUNC_ENTRY("CATProject::RestoreModules"); |
|
1674 bool bRet = true; |
|
1675 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1676 { |
|
1677 if (! m_vModules.at(i)->RestoreMmp() ) |
|
1678 bRet = false; |
|
1679 } |
|
1680 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
1681 { |
|
1682 if (! m_vStaticLibraries.at(i)->RestoreMmp() ) |
|
1683 bRet = false; |
|
1684 } |
|
1685 return bRet; |
|
1686 } |
|
1687 |
|
1688 bool CATProject::VerifyAndRecoverModules() |
|
1689 { |
|
1690 LOG_FUNC_ENTRY("CATProject::VerifyAndRecoverModules"); |
|
1691 bool bRet = true; |
|
1692 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1693 { |
|
1694 if (! m_vModules.at(i)->VerifyAndRecoverMmp() ) |
|
1695 bRet = false; |
|
1696 } |
|
1697 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
1698 { |
|
1699 if (! m_vStaticLibraries.at(i)->VerifyAndRecoverMmp() ) |
|
1700 bRet = false; |
|
1701 } |
|
1702 return bRet; |
|
1703 } |
|
1704 bool CATProject::Compile() |
|
1705 { |
|
1706 switch ( m_eBuildSystem ) |
|
1707 { |
|
1708 case SBS_V1: |
|
1709 // Run Reallyclean. |
|
1710 if( ! RunReallyCleanSbs1() ) |
|
1711 return false; |
|
1712 return CompileSbs1(); |
|
1713 case SBS_V2: |
|
1714 return CompileSbs2(); |
|
1715 default: |
|
1716 return false; |
|
1717 } |
|
1718 } |
|
1719 |
|
1720 bool CATProject::CompileSbs1() |
|
1721 { |
|
1722 LOG_FUNC_ENTRY("CATProject::CompileSbs1"); |
|
1723 string sCommand(""); |
|
1724 if ( m_sBuildCommand.empty() ) |
|
1725 { |
|
1726 sCommand = "abld build"; |
|
1727 // -debug if urel |
|
1728 if ( m_eBuildType == UREL ) |
|
1729 sCommand.append( " -debug" ); |
|
1730 |
|
1731 // No variant |
|
1732 if ( m_sVariant.empty() ) |
|
1733 { |
|
1734 sCommand.append( " " ); |
|
1735 sCommand.append( m_sPlatform ); |
|
1736 } |
|
1737 else |
|
1738 { |
|
1739 // Add variant |
|
1740 sCommand.append( " " ); |
|
1741 sCommand.append( m_sPlatform ); |
|
1742 sCommand.append( "." ); |
|
1743 sCommand.append( m_sVariant ); |
|
1744 } |
|
1745 |
|
1746 // urel vs udeb |
|
1747 sCommand.append( " " ); |
|
1748 sCommand.append( GetBuildTypeString() ); |
|
1749 |
|
1750 // Possible target module |
|
1751 AddTargetModuleIfDefined( sCommand ); |
|
1752 } |
|
1753 // Check that build command contains -debug switch if sbs v.1 used |
|
1754 else if ( ! m_sBuildCommand.empty() |
|
1755 && m_eBuildType == UREL |
|
1756 && m_eBuildSystem == SBS_V1 |
|
1757 && m_sBuildCommand.find( "-debug" ) == string::npos ) |
|
1758 { |
|
1759 // Find correct index to insert -debug switch |
|
1760 size_t iPos = m_sBuildCommand.find( "build" ); |
|
1761 if ( iPos != string::npos ) |
|
1762 { |
|
1763 sCommand = m_sBuildCommand; |
|
1764 sCommand.insert( iPos+5, " -debug" ); |
|
1765 } |
|
1766 else |
|
1767 { |
|
1768 LOG_STRING("Overwriting given build command to add -debug switch. Original command is: " << m_sBuildCommand ); |
|
1769 if ( m_bAbldTest ) |
|
1770 sCommand = "abld test build -debug "; |
|
1771 else |
|
1772 sCommand = "abld build -debug "; |
|
1773 // No variant |
|
1774 if ( m_sVariant.empty() ) |
|
1775 { |
|
1776 sCommand.append( m_sPlatform ); |
|
1777 } |
|
1778 else |
|
1779 { |
|
1780 // Add variant |
|
1781 sCommand.append( m_sPlatform ); |
|
1782 sCommand.append( "." ); |
|
1783 sCommand.append( m_sVariant ); |
|
1784 } |
|
1785 |
|
1786 // urel vs udeb |
|
1787 sCommand.append( " " ); |
|
1788 sCommand.append( GetBuildTypeString() ); |
|
1789 // Possible target module |
|
1790 AddTargetModuleIfDefined( sCommand ); |
|
1791 } |
|
1792 } |
|
1793 else |
|
1794 sCommand = m_sBuildCommand; |
|
1795 // Run command |
|
1796 cout << AT_MSG_SYSTEM_CALL << sCommand << endl; |
|
1797 (void)system( sCommand.c_str() ); |
|
1798 return true; |
|
1799 } |
|
1800 |
|
1801 bool CATProject::CompileSbs2() |
|
1802 { |
|
1803 LOG_FUNC_ENTRY("CATProject::CompileSbs2"); |
|
1804 // Create command to compile with raptor |
|
1805 string sCmd( m_sBuildCommand ); |
|
1806 sCmd.append( RAPTOR_BUILD_LOG ); |
|
1807 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1808 int iRet = (int)system( sCmd.c_str() ); |
|
1809 if ( iRet == 0 ) |
|
1810 return true; |
|
1811 return false; |
|
1812 } |
|
1813 |
|
1814 bool CATProject::CreateListings() |
|
1815 { |
|
1816 // Create listings if no addr2line defined |
|
1817 #ifndef ADDR2LINE |
|
1818 if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 ) |
|
1819 { |
|
1820 switch ( m_eBuildSystem ) |
|
1821 { |
|
1822 case SBS_V1: |
|
1823 return CreateListingsSbs1(); |
|
1824 case SBS_V2: |
|
1825 return CreateListingsSbs2(); |
|
1826 default: |
|
1827 return false; |
|
1828 } |
|
1829 } |
|
1830 #endif |
|
1831 return true; |
|
1832 } |
|
1833 |
|
1834 bool CATProject::CreateListingsSbs1() |
|
1835 { |
|
1836 LOG_FUNC_ENTRY("CATProject::CreateListingsSbs1"); |
|
1837 string sCommand; |
|
1838 if ( m_bAbldTest ) |
|
1839 sCommand = "abld test listing "; |
|
1840 else |
|
1841 sCommand = "abld listing "; |
|
1842 |
|
1843 // Listing |
|
1844 if ( m_sVariant.empty() ) |
|
1845 { |
|
1846 // No variant |
|
1847 sCommand.append( m_sPlatform ); |
|
1848 } |
|
1849 else |
|
1850 { |
|
1851 // Use specified variant |
|
1852 sCommand.append( m_sPlatform ); |
|
1853 sCommand.append( "." ); |
|
1854 sCommand.append( m_sVariant ); |
|
1855 } |
|
1856 // udeb vs urel |
|
1857 sCommand.append( " " ); |
|
1858 sCommand.append( GetBuildTypeString() ); |
|
1859 |
|
1860 if ( m_vTargetModules.size() > 1 ) |
|
1861 { |
|
1862 RunAbldCommandToAllTargets( sCommand ); |
|
1863 } |
|
1864 else |
|
1865 { |
|
1866 AddTargetModuleIfDefined( sCommand ); |
|
1867 cout << AT_MSG_SYSTEM_CALL << sCommand << endl; |
|
1868 (void)system( sCommand.c_str() ); |
|
1869 } |
|
1870 return true; |
|
1871 } |
|
1872 |
|
1873 bool CATProject::CreateListingsSbs2() |
|
1874 { |
|
1875 LOG_FUNC_ENTRY("CATProject::CreateListingsSbs2"); |
|
1876 string sCmd( m_sBuildCommand ); |
|
1877 sCmd.append( RAPTOR_LISTING_LOG ); |
|
1878 sCmd.append( " LISTING"); |
|
1879 cout << AT_MSG_SYSTEM_CALL << sCmd << endl; |
|
1880 int iRet = (int)system( sCmd.c_str() ); |
|
1881 if ( iRet == 0 ) |
|
1882 return true; |
|
1883 return false; |
|
1884 } |
|
1885 |
|
1886 bool CATProject::CopyReleasables() |
|
1887 { |
|
1888 bool bRet = true; |
|
1889 LOG_FUNC_ENTRY("CATProject::CopyReleasables"); |
|
1890 // Only copy releasables on armv5 platform and no addr2line defined. |
|
1891 #ifndef ADDR2LINE |
|
1892 if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 ) |
|
1893 { |
|
1894 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1895 { |
|
1896 if ( ! m_vModules.at(i)->CopyReleasables() ) |
|
1897 bRet = false; |
|
1898 } |
|
1899 // Static libraries lst files. |
|
1900 // First create directory for them (delete old one if exists). |
|
1901 if ( ! DirectoryExists( AT_TEMP_LST_DIR ) ) |
|
1902 { |
|
1903 DirCreate( AT_TEMP_LST_DIR, true ); |
|
1904 } |
|
1905 else |
|
1906 { |
|
1907 DirDelete( AT_TEMP_LST_DIR, true ); |
|
1908 DirCreate( AT_TEMP_LST_DIR, true ); |
|
1909 } |
|
1910 for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ ) |
|
1911 { |
|
1912 if( ! m_vStaticLibraries.at(i)->CopyLstFilesToDir( AT_TEMP_LST_DIR ) ) |
|
1913 bRet = false; |
|
1914 } |
|
1915 |
|
1916 // Delete lst files from all type of modules in project. |
|
1917 // Ignoring errors because different modules might use same source/lst files. |
|
1918 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1919 m_vModules.at(i)->DeleteLstFilesFromSrc(); |
|
1920 for ( size_t i = 0 ; i < m_vUnsupportedModules.size(); i ++ ) |
|
1921 m_vUnsupportedModules.at(i)->DeleteLstFilesFromSrc(); |
|
1922 for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ ) |
|
1923 m_vStaticLibraries.at(i)->DeleteLstFilesFromSrc(); |
|
1924 |
|
1925 return bRet; |
|
1926 } |
|
1927 #endif |
|
1928 // When addr2line defined and used we use symbol and map file(s). |
|
1929 #ifdef ADDR2LINE |
|
1930 if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 ) |
|
1931 { |
|
1932 // Verify that module(s) symbol file(s) exist |
|
1933 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1934 { |
|
1935 // Check symbol file. |
|
1936 if ( ! m_vModules.at(i)->SymbolFileExist() ) |
|
1937 bRet = false; |
|
1938 // Check map file. |
|
1939 if ( ! m_vModules.at(i)->MapFileExist() ) |
|
1940 bRet = false; |
|
1941 } |
|
1942 } |
|
1943 #endif |
|
1944 // Platform winscw. |
|
1945 else if ( _stricmp( m_sPlatform.c_str(), "winscw" ) == 0 ) |
|
1946 { |
|
1947 // Verify that module(s) binaries exist |
|
1948 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1949 { |
|
1950 if ( ! m_vModules.at(i)->BinaryFileExist() ) |
|
1951 bRet = false; |
|
1952 } |
|
1953 // For static libraries binary/target is same as their library. |
|
1954 for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ ) |
|
1955 if ( ! m_vStaticLibraries.at(i)->BinaryFileExist() ) |
|
1956 bRet = false; |
|
1957 } |
|
1958 // Platform gcce. |
|
1959 else if ( _stricmp( m_sPlatform.c_str(), "gcce" ) == 0 ) |
|
1960 { |
|
1961 // Verify that module(s) symbol file(s) exist |
|
1962 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
1963 { |
|
1964 // Check symbol file. |
|
1965 if ( ! m_vModules.at(i)->SymbolFileExist() ) |
|
1966 bRet = false; |
|
1967 } |
|
1968 } |
|
1969 return bRet; |
|
1970 } |
|
1971 |
|
1972 // ---------------------------------------------------------------------------- |
|
1973 // Write project's (user) attributes to a file under temp folder |
|
1974 // ---------------------------------------------------------------------------- |
|
1975 bool CATProject::WriteAttributes() const |
|
1976 { |
|
1977 LOG_FUNC_ENTRY("CATProject::WriteAttributes"); |
|
1978 // File to write to |
|
1979 string sOutFile( AT_TEMP_DIR ); |
|
1980 sOutFile.append( "\\" ); |
|
1981 sOutFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME ); |
|
1982 // Open file truncate if exists |
|
1983 ofstream out( sOutFile.c_str(), ios_base::trunc ); |
|
1984 // Check file opened successfully |
|
1985 if ( ! out.good() ) |
|
1986 return false; |
|
1987 // Write attributes line by line |
|
1988 out << m_bUninstrumented << endl; // Is project instrumented |
|
1989 // Sbs version |
|
1990 if ( m_eBuildSystem == CATProject::SBS_V2 ) |
|
1991 out << "SBS_2" << endl; |
|
1992 else |
|
1993 out << "SBS_1" << endl; |
|
1994 out << endl; // Reserved for possible binary data |
|
1995 out << m_sPlatform << endl; |
|
1996 out << m_sVariant << endl; |
|
1997 out << m_eLoggingMode << endl; |
|
1998 out << m_eBuildType << endl; |
|
1999 out << m_sS60FileName << endl; |
|
2000 out << m_iAllocCallStackSize << endl; |
|
2001 out << m_iFreeCallStackSize << endl; |
|
2002 for ( size_t i = 0 ; i < m_vTargetModules.size() ; i++ ) |
|
2003 out << m_vTargetModules.at(i) << AT_PROJECT_ATTRIBUTES_SEPARATOR; |
|
2004 out << endl; |
|
2005 out << m_sBuildCommand << endl; |
|
2006 out << m_sS60FilePath << endl; |
|
2007 out.close(); |
|
2008 return true; |
|
2009 } |
|
2010 // ---------------------------------------------------------------------------- |
|
2011 // Reads project's (user) attributes to a file under temp folder |
|
2012 // ---------------------------------------------------------------------------- |
|
2013 bool CATProject::ReadAttributes() |
|
2014 { |
|
2015 LOG_FUNC_ENTRY("CATProject::ReadAttributes"); |
|
2016 // File to read on |
|
2017 string sInFile( AT_TEMP_DIR ); |
|
2018 sInFile.append( "\\" ); |
|
2019 sInFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME ); |
|
2020 // Open file |
|
2021 ifstream in( sInFile.c_str() ); |
|
2022 // Check file opened successfully |
|
2023 if ( ! in.good() ) |
|
2024 return false; |
|
2025 // Read attributes |
|
2026 char cLine[ MAX_LINE_LENGTH ]; |
|
2027 string sLine; |
|
2028 in.getline( cLine, MAX_LINE_LENGTH ); |
|
2029 int iValue = atoi( cLine ); |
|
2030 if ( iValue == 1 ) |
|
2031 m_bUninstrumented = true; |
|
2032 else |
|
2033 m_bUninstrumented = false; |
|
2034 // Sbs version |
|
2035 in.getline( cLine, MAX_LINE_LENGTH ); string sBuildSystem = string( cLine ); |
|
2036 if ( sBuildSystem.compare( "SBS_1" ) == 0 ) |
|
2037 m_eBuildSystem = CATProject::SBS_V1; |
|
2038 else if ( sBuildSystem.compare( "SBS_2" ) == 0 ) |
|
2039 m_eBuildSystem = CATProject::SBS_V2; |
|
2040 else { |
|
2041 LOG_STRING("Error invalid build system defined in project.cfg"); |
|
2042 m_eBuildSystem = CATProject::SBS_V1; |
|
2043 } |
|
2044 in.getline( cLine, MAX_LINE_LENGTH ); // reserverd for possible binary timestamp or similar |
|
2045 in.getline( cLine, MAX_LINE_LENGTH ); m_sPlatform = string( cLine ); |
|
2046 in.getline( cLine, MAX_LINE_LENGTH ); m_sVariant = string( cLine ); |
|
2047 in.getline( cLine, MAX_LINE_LENGTH ); m_eLoggingMode = atoi( cLine ); |
|
2048 in.getline( cLine, MAX_LINE_LENGTH ); m_eBuildType = atoi( cLine ); |
|
2049 in.getline( cLine, MAX_LINE_LENGTH ); m_sS60FileName = string( cLine ); |
|
2050 in.getline( cLine, MAX_LINE_LENGTH ); m_iAllocCallStackSize = atoi( cLine ); |
|
2051 in.getline( cLine, MAX_LINE_LENGTH ); m_iFreeCallStackSize = atoi( cLine ); |
|
2052 in.getline( cLine, MAX_LINE_LENGTH ); sLine = cLine; |
|
2053 size_t iSpot = sLine.find( AT_PROJECT_ATTRIBUTES_SEPARATOR ); |
|
2054 while ( iSpot != string::npos ) |
|
2055 { |
|
2056 string sTarget = sLine.substr(0, iSpot ); |
|
2057 m_vTargetModules.push_back( sTarget ); |
|
2058 sLine.erase(0, iSpot + AT_PROJECT_ATTRIBUTES_SEPARATOR.size() ); |
|
2059 iSpot = sLine.find( AT_PROJECT_ATTRIBUTES_SEPARATOR ); |
|
2060 } |
|
2061 in.getline( cLine, MAX_LINE_LENGTH ); m_sBuildCommand = cLine; |
|
2062 in.getline( cLine, MAX_LINE_LENGTH ); m_sS60FilePath = string( cLine ); |
|
2063 in.close(); |
|
2064 return true; |
|
2065 } |
|
2066 |
|
2067 // ---------------------------------------------------------------------------- |
|
2068 // Creates atool_temp directory to current folder if does not exist |
|
2069 // ---------------------------------------------------------------------------- |
|
2070 bool CATProject::MakeTempDirIfNotExist() |
|
2071 { |
|
2072 LOG_FUNC_ENTRY("CATProject::MakeTempDirIfNotExist"); |
|
2073 if ( ! DirectoryExists( AT_TEMP_DIR ) ) |
|
2074 { |
|
2075 if( !CreateDirectory( AT_TEMP_DIR , NULL ) ) |
|
2076 { |
|
2077 return false; |
|
2078 } |
|
2079 } |
|
2080 return true; |
|
2081 } |
|
2082 // ---------------------------------------------------------------------------- |
|
2083 // Utilities |
|
2084 // ---------------------------------------------------------------------------- |
|
2085 |
|
2086 bool CATProject::RunAbldCommandToAllTargets( const string& sCommand ) |
|
2087 { |
|
2088 LOG_FUNC_ENTRY("CATProject::RunAbldCommandToAllTargets"); |
|
2089 |
|
2090 // Check for space at the commands end. |
|
2091 string sSystemCall( sCommand ); |
|
2092 if ( *(sSystemCall.rbegin()) != ' ' ) |
|
2093 sSystemCall.append( " " ); |
|
2094 |
|
2095 // Loop calls. |
|
2096 bool bRet = true; |
|
2097 for ( vector<string>::iterator it = m_vTargetModules.begin(); it < m_vTargetModules.end(); it++ ) |
|
2098 { |
|
2099 string sCall( sSystemCall ); |
|
2100 sCall.append( RemovePathAndExt( *it, true ) ); |
|
2101 cout << AT_MSG_SYSTEM_CALL << sCall << endl; |
|
2102 if ( (int) system( sCall.c_str() ) != 0 ) |
|
2103 bRet = false; |
|
2104 } |
|
2105 return bRet; |
|
2106 } |
|
2107 |
|
2108 void CATProject::AddTargetModuleIfDefined( string& sCmd ) |
|
2109 { |
|
2110 LOG_FUNC_ENTRY("CATProject::AddTargetModuleIfDefined"); |
|
2111 // Do we have target modules defined |
|
2112 if ( m_vTargetModules.size() > 0 ) |
|
2113 { |
|
2114 switch( m_eBuildSystem ) |
|
2115 { |
|
2116 case SBS_V1: |
|
2117 // Add first target modules name without extension to build cmd. |
|
2118 sCmd.append( " " ); |
|
2119 sCmd.append( RemovePathAndExt( m_vTargetModules.at( 0 ), true ) ); |
|
2120 break; |
|
2121 case SBS_V2: |
|
2122 // Add all target modules to build command using raptor switch '-p'. |
|
2123 for( size_t i = 0 ; i < m_vTargetModules.size() ; i++ ) |
|
2124 { |
|
2125 LOG_STRING("Adding :" << m_vTargetModules.at( i ) ); |
|
2126 sCmd.append( " -p " ); |
|
2127 sCmd.append( m_vTargetModules.at( i ) ); |
|
2128 } |
|
2129 break; |
|
2130 } |
|
2131 } |
|
2132 } |
|
2133 |
|
2134 bool CATProject::IsTargetModuleInProject() const |
|
2135 { |
|
2136 LOG_FUNC_ENTRY("CATProject::IsTargetModuleInProject"); |
|
2137 vector<CATModule2*>::const_iterator modules; |
|
2138 vector<CATModule2*>::const_iterator staticModules; |
|
2139 vector<string>::const_iterator targets; |
|
2140 bool bRet = true; |
|
2141 // Do we have target modules defined |
|
2142 if ( m_vTargetModules.size() > 0 ) |
|
2143 { |
|
2144 // Sbs version 1 support only single target module. |
|
2145 if ( m_eBuildSystem == SBS_V1 ) |
|
2146 { |
|
2147 // Try to find module from project. |
|
2148 bRet = false; |
|
2149 string sTarget = m_vTargetModules.at(0); |
|
2150 for( modules = m_vModules.begin() ; modules != m_vModules.end() ; modules++ ) |
|
2151 { |
|
2152 if( (*modules)->GetMmpFile().find( sTarget ) != string::npos ) |
|
2153 { |
|
2154 // Found it return true. |
|
2155 bRet = true; |
|
2156 break; |
|
2157 } |
|
2158 } |
|
2159 for( staticModules = m_vStaticLibraries.begin(); staticModules != m_vStaticLibraries.end(); staticModules++ ) |
|
2160 { |
|
2161 if( (*staticModules)->GetMmpFile().find( sTarget ) != string::npos ) |
|
2162 { |
|
2163 bRet = true; |
|
2164 break; |
|
2165 } |
|
2166 } |
|
2167 if ( ! bRet ) |
|
2168 { |
|
2169 // Not found display error message. |
|
2170 cout << AT_MSG << "Error, " << sTarget << " not defined in project." << endl; |
|
2171 } |
|
2172 } |
|
2173 // Sbs version 2 supports multiple target modules. |
|
2174 else if ( m_eBuildSystem == SBS_V2 ) |
|
2175 { |
|
2176 // Check that all targets are defined in project. |
|
2177 for( targets = m_vTargetModules.begin(); targets != m_vTargetModules.end() ; targets++ ) |
|
2178 { |
|
2179 // Found iterated target? |
|
2180 bool bFound = false; |
|
2181 for ( modules = m_vModules.begin() ; modules != m_vModules.end() ; modules++ ) |
|
2182 { |
|
2183 if( (*modules)->GetMmpFile().find( *targets ) != string::npos ) |
|
2184 { |
|
2185 // yes. |
|
2186 bFound = true; |
|
2187 break; |
|
2188 } |
|
2189 } |
|
2190 for( staticModules = m_vStaticLibraries.begin(); staticModules != m_vStaticLibraries.end(); staticModules++ ) |
|
2191 { |
|
2192 if( (*staticModules)->GetMmpFile().find( *targets ) != string::npos ) |
|
2193 { |
|
2194 bFound = true; |
|
2195 break; |
|
2196 } |
|
2197 } |
|
2198 if ( ! bFound ) |
|
2199 { |
|
2200 // Display error when not found and set return value false. |
|
2201 bRet = false; |
|
2202 cout << AT_MSG << "Error, " << targets->c_str() << " not defined in project." << endl; |
|
2203 } |
|
2204 } |
|
2205 } |
|
2206 } |
|
2207 return bRet; |
|
2208 } |
|
2209 |
|
2210 string CATProject::GetBuildTypeString() |
|
2211 { |
|
2212 LOG_LOW_FUNC_ENTRY("CATProject::GetBuildTypeString"); |
|
2213 // Return build type as lowercase string |
|
2214 switch( m_eBuildType ) |
|
2215 { |
|
2216 case UDEB: |
|
2217 return string("udeb"); |
|
2218 case UREL: |
|
2219 return string("urel"); |
|
2220 default: |
|
2221 return ""; |
|
2222 } |
|
2223 } |
|
2224 |
|
2225 string CATProject::GetBuildTypeString( int eType ) |
|
2226 { |
|
2227 LOG_LOW_FUNC_ENTRY("CATProject::GetBuildTypeString( int eType )"); |
|
2228 // Return build type as lowercase string |
|
2229 switch( eType ) |
|
2230 { |
|
2231 case UDEB: |
|
2232 return string("udeb"); |
|
2233 case UREL: |
|
2234 return string("urel"); |
|
2235 default: |
|
2236 return string("unknown"); |
|
2237 } |
|
2238 } |
|
2239 |
|
2240 bool CATProject::CleanTemporaryDirs() |
|
2241 { |
|
2242 LOG_FUNC_ENTRY("CATProject::CleanTemporaryDirs"); |
|
2243 bool bRet = true; |
|
2244 // Modules |
|
2245 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
2246 { |
|
2247 if ( ! m_vModules.at(i)->CleanTemporaryDir() ) |
|
2248 bRet = false; |
|
2249 } |
|
2250 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
2251 { |
|
2252 if ( ! m_vStaticLibraries.at(i)->CleanTemporaryDir() ) |
|
2253 bRet = false; |
|
2254 } |
|
2255 // Projects |
|
2256 vector<string> vFileList = DirList( AT_TEMP_DIR, false , true ); |
|
2257 vector<string>::iterator it2 = vFileList.begin(); |
|
2258 // Size of constant table |
|
2259 int iCount = sizeof( TEMP_EXTENSION_NO_DELETE ) / sizeof( string ); |
|
2260 while ( it2 != vFileList.end() ) |
|
2261 { |
|
2262 // Get extension and compare it to list |
|
2263 bool bDelete = true; |
|
2264 string sExtension = GetExtension( *it2 ); |
|
2265 ChangeToLower( sExtension ); |
|
2266 for ( int i = 0 ; i < iCount ; i++ ) |
|
2267 { |
|
2268 if( sExtension.compare( TEMP_EXTENSION_NO_DELETE[i] ) == 0 ) |
|
2269 { |
|
2270 bDelete = false; |
|
2271 break; |
|
2272 } |
|
2273 } |
|
2274 if ( bDelete ) |
|
2275 { |
|
2276 // Delete file |
|
2277 if ( ! FileDelete( *it2, true ) ) |
|
2278 bRet = false; |
|
2279 } |
|
2280 // Increment |
|
2281 it2++; |
|
2282 } |
|
2283 return bRet; |
|
2284 } |
|
2285 |
|
2286 bool CATProject::DeleteTemporaryDirs() |
|
2287 { |
|
2288 LOG_FUNC_ENTRY("CATProject::DeleteTemporaryDirs"); |
|
2289 bool bRet = true; |
|
2290 // Modules |
|
2291 for( size_t i = 0; i < m_vModules.size(); i++ ) |
|
2292 { |
|
2293 if (! m_vModules.at(i)->DeleteTemporaryDir() ) |
|
2294 bRet = false; |
|
2295 } |
|
2296 for( size_t i = 0; i < m_vStaticLibraries.size(); i++ ) |
|
2297 { |
|
2298 if (! m_vStaticLibraries.at(i)->DeleteTemporaryDir() ) |
|
2299 bRet = false; |
|
2300 } |
|
2301 return bRet; |
|
2302 } |
|
2303 |
|
2304 bool CATProject::InitSbs1MakeFileWithPathToTemp() |
|
2305 { |
|
2306 LOG_FUNC_ENTRY("CATProject::InitSbs1MakeFileWithPathToTemp"); |
|
2307 // Use temporary folder |
|
2308 m_sMakeFile.clear(); |
|
2309 m_sMakeFile.append( AT_TEMP_DIR ); |
|
2310 m_sMakeFile.append( "\\" ); |
|
2311 m_sMakeFile.append( AT_LEVEL_1_MAKEFILE_NAME ); |
|
2312 // At end check does it exist, return the result. |
|
2313 return FileExists( m_sMakeFile.c_str() ); |
|
2314 } |
|
2315 |
|
2316 bool CATProject::InitSbs1MakeFileWithPath() |
|
2317 { |
|
2318 LOG_FUNC_ENTRY("CATProject::InitMakeFileWithPath"); |
|
2319 if ( m_sEpocRoot.empty() ) |
|
2320 { |
|
2321 LOG_STRING("Error, epocroot is not set."); |
|
2322 return false; |
|
2323 } |
|
2324 m_sMakeFile.clear(); |
|
2325 m_sMakeFile.append( m_sEpocRoot ); |
|
2326 if( *m_sMakeFile.rbegin() != '\\' ) |
|
2327 m_sMakeFile.append( "\\" ); |
|
2328 m_sMakeFile.append( "epoc32\\build\\" ); |
|
2329 // Add current directory to path (first remove driveletter). |
|
2330 string sCurrentDir( m_cCurrentDir ); |
|
2331 if ( sCurrentDir.length() < 3 ) |
|
2332 { |
|
2333 LOG_STRING("Error, current dir invalid."); |
|
2334 return false; |
|
2335 } |
|
2336 sCurrentDir.erase(0,3); |
|
2337 m_sMakeFile.append( sCurrentDir ); |
|
2338 m_sMakeFile.append( "\\" ); |
|
2339 // Platform |
|
2340 string sPlatInUpper( m_sPlatform); |
|
2341 ChangeToUpper( sPlatInUpper ); |
|
2342 m_sMakeFile.append( sPlatInUpper ); |
|
2343 // Possible variant |
|
2344 if ( m_sVariant.empty() ) |
|
2345 { |
|
2346 // Test modules only? |
|
2347 if ( m_bAbldTest ) |
|
2348 m_sMakeFile.append( "TEST" ); |
|
2349 m_sMakeFile.append( "." ); |
|
2350 m_sMakeFile.append( "MAKE" ); |
|
2351 } |
|
2352 else |
|
2353 { |
|
2354 m_sMakeFile.append( "." ); |
|
2355 m_sMakeFile.append( m_sVariant ); |
|
2356 // Test modules only? |
|
2357 if ( m_bAbldTest ) |
|
2358 m_sMakeFile.append( "TEST" ); |
|
2359 m_sMakeFile.append( ".MAKE" ); |
|
2360 } |
|
2361 // At end check does it exist, return the result. |
|
2362 return FileExists( m_sMakeFile.c_str() ); |
|
2363 } |
|
2364 |
|
2365 // ---------------------------------------------------------------------------- |
|
2366 // Get & Sets |
|
2367 // ---------------------------------------------------------------------------- |
|
2368 void CATProject::SetBuildSystem( BUILD_SYSTEM eSystem ) |
|
2369 { |
|
2370 LOG_FUNC_ENTRY("CATProject::SetBuildSystem"); |
|
2371 m_eBuildSystem = eSystem; |
|
2372 } |
|
2373 void CATProject::SetMode( PROJECT_MODE eMode ) |
|
2374 { |
|
2375 LOG_FUNC_ENTRY("CATProject::SetMode"); |
|
2376 m_eMode = eMode; |
|
2377 } |
|
2378 int CATProject::GetMode() const |
|
2379 { |
|
2380 LOG_LOW_FUNC_ENTRY("CATProject::GetMode"); |
|
2381 return m_eMode; |
|
2382 } |
|
2383 void CATProject::SetEpocRoot( const string& sEpocRoot ) |
|
2384 { |
|
2385 LOG_FUNC_ENTRY("CATProject::SetEpocRoot"); |
|
2386 m_sEpocRoot = sEpocRoot; |
|
2387 } |
|
2388 void CATProject::SetPlatform( const string& sPlatform ) |
|
2389 { |
|
2390 LOG_FUNC_ENTRY("CATProject::SetPlatform"); |
|
2391 m_sPlatform = sPlatform; |
|
2392 } |
|
2393 void CATProject::SetVariant( const string& sVariant ) |
|
2394 { |
|
2395 LOG_FUNC_ENTRY("CATProject::SetVariant"); |
|
2396 m_sVariant = sVariant; |
|
2397 } |
|
2398 void CATProject::SetLoggingMode( LOGGING_MODE eLoggingMode) |
|
2399 { |
|
2400 LOG_FUNC_ENTRY("CATProject::SetLoggingMode"); |
|
2401 m_eLoggingMode = eLoggingMode; |
|
2402 } |
|
2403 void CATProject::SetAllocCallStackSize( int iAllocCallStackSize ) |
|
2404 { |
|
2405 m_iAllocCallStackSize = iAllocCallStackSize; |
|
2406 } |
|
2407 void CATProject::SetFreeCallStackSize( int iFreeCallStackSize ) |
|
2408 { |
|
2409 m_iFreeCallStackSize = iFreeCallStackSize; |
|
2410 } |
|
2411 void CATProject::SetBuildType( BUILD_TYPE eType ) |
|
2412 { |
|
2413 LOG_FUNC_ENTRY("CATProject::SetBuildType"); |
|
2414 m_eBuildType = eType; |
|
2415 } |
|
2416 void CATProject::SetS60FileName( const string& sFileName) |
|
2417 { |
|
2418 LOG_FUNC_ENTRY("CATProject::SetS60FileName"); |
|
2419 m_sS60FileName = sFileName; |
|
2420 } |
|
2421 void CATProject::SetS60FilePath( const string& sFilePath) |
|
2422 { |
|
2423 LOG_FUNC_ENTRY("CATProject::SetS60FilePath"); |
|
2424 m_sS60FilePath = sFilePath; |
|
2425 } |
|
2426 void CATProject::SetRomSymbolFiles(const vector<string>& vRomSymbolFiles) |
|
2427 { |
|
2428 LOG_FUNC_ENTRY("CATProject::SetRomSymbolFiles"); |
|
2429 m_vRomSymbolFiles = vRomSymbolFiles; |
|
2430 } |
|
2431 void CATProject::SetTargetModule(const string& sTargetModule) |
|
2432 { |
|
2433 LOG_FUNC_ENTRY("CATProject::SetTargetModule"); |
|
2434 m_sTargetModule = sTargetModule; |
|
2435 ChangeToLower( m_sTargetModule); |
|
2436 } |
|
2437 void CATProject::SetBinaryTarget(const string& sBinaryTarget) |
|
2438 { |
|
2439 LOG_FUNC_ENTRY("CATProject::SetBinaryTarget"); |
|
2440 m_sBinaryTarget = sBinaryTarget; |
|
2441 ChangeToLower( m_sBinaryTarget ); |
|
2442 } |
|
2443 void CATProject::SetDataFile( const string& sDataFile ) |
|
2444 { |
|
2445 LOG_FUNC_ENTRY("CATProject::SetDataFile"); |
|
2446 m_sDataFile = sDataFile; |
|
2447 } |
|
2448 void CATProject::SetLogLevel( int iLogLevel ) |
|
2449 { |
|
2450 LOG_FUNC_ENTRY("CATProject::SetLogLevel"); |
|
2451 m_iLoggingLevel = iLogLevel; |
|
2452 } |
|
2453 void CATProject::SetDataFileOutput( const string& sDataFileOutput ) |
|
2454 { |
|
2455 LOG_FUNC_ENTRY("CATProject::SetDataFileOutput"); |
|
2456 m_sDataFileOutput = sDataFileOutput; |
|
2457 } |
|
2458 void CATProject::SetTargetModules( const vector<string>& vTargetModules ) |
|
2459 { |
|
2460 LOG_FUNC_ENTRY("CATProject::SetTargetModules"); |
|
2461 m_vTargetModules = vTargetModules; |
|
2462 } |
|
2463 void CATProject::SetBuildCommand( const string& sBuildCommand ) |
|
2464 { |
|
2465 LOG_FUNC_ENTRY("CATProject::SetBuildCommand"); |
|
2466 m_sBuildCommand = sBuildCommand; |
|
2467 } |
|
2468 // End of file |