|
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 #ifndef __CATPROJECT_H__ |
|
20 #define __CATPROJECT_H__ |
|
21 |
|
22 #include "ATCommonDefines.h" |
|
23 #include "CATBase.h" |
|
24 #include "../inc/CATParseBinaryFile.h" |
|
25 |
|
26 class CATModule2; |
|
27 class CATDatParser; |
|
28 |
|
29 // Raptor cmd and makefile constants used |
|
30 #define RAPTOR_CMD_BASE "sbs -b bld.inf --makefile=atool_temp/build/make_build --config=" |
|
31 #define RAPTOR_MAKEFILE "atool_temp\\build\\make_build.default" |
|
32 #define RAPTOR_MAKEFILE_LOG " --logfile=atool_temp\\build\\makefile.xml" |
|
33 #define RAPTOR_BUILD_LOG " --logfile=atool_temp\\build\\build.xml" |
|
34 #define RAPTOR_REALLYCLEAN_LOG " --logfile=atool_temp\\build\\reallyclean.xml" |
|
35 #define RAPTOR_BUILD_LOG_NAME "atool_temp\\build\\build.xml" |
|
36 #define RAPTOR_LISTING_LOG " --logfile=atool_temp\\build\\listing.xml" |
|
37 |
|
38 #define RAPTOR_NOBUILD_SWITCH " --nobuild" |
|
39 #define RAPTOR_MAKEFILE_SWITCH "--makefile=atool_temp/build/make_build" |
|
40 |
|
41 |
|
42 // Raptor makefile constant variable names |
|
43 #define RAPTOR_PROJECT_META "PROJECT_META:=" |
|
44 #define RAPTOR_SOURCE "SOURCE:=" |
|
45 #define RAPTOR_TARGET "TARGET:=" |
|
46 #define RAPTOR_TARGETYPE "TARGETTYPE:=" |
|
47 #define RAPTOR_REQUESTEDTARGETEXT "REQUESTEDTARGETEXT:=" |
|
48 #define RAPTOR_VARIANTPLATFORM "VARIANTPLATFORM:=" |
|
49 #define RAPTOR_VARIANTTYPE "VARIANTTYPE:=" |
|
50 #define RAPTOR_FEATUREVARIANT "FEATUREVARIANT:=" |
|
51 #define RAPTOR_FEATUREVARIANTNAME "FEATUREVARIANTNAME:=" |
|
52 #define RAPTOR_RELEASEPATH "RELEASEPATH:=" |
|
53 #define RAPTOR_FULLVARIANTPATH "FULLVARIANTPATH:=" |
|
54 #define RAPTOR_COMPILE_DEFINITIONS "CDEFS:=" |
|
55 |
|
56 // Sbs v.1 makefile constants. |
|
57 #define MAKEFILE_SEARCH_STRING "@perl -S checksource.pl" |
|
58 #define MMPFILE_SEARCH_STRING "PRJ_MMPFILES MMP" |
|
59 #define MMPTESTFILE_SEARCH_STRING "PRJ_TESTMMPFILES MMP" |
|
60 #define SOURCE_PATH "SOURCEPATH" |
|
61 #define SOURCE_STRING "SOURCE" |
|
62 #define TARGET_STRING "TARGET" |
|
63 |
|
64 /** |
|
65 * CATProject represents a project (collection of modules). |
|
66 * It has to be set mode in which it operates like |
|
67 * compile / analyze and necessary parameters for that. |
|
68 * Then call Run method which also returs error codes |
|
69 * defined in AT_ERROR_CODES enumeration. |
|
70 * @author |
|
71 */ |
|
72 class CATProject : public CATBase |
|
73 { |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Enumeration representing used build systems |
|
78 */ |
|
79 enum BUILD_SYSTEM { |
|
80 SBS_V1 = 1, |
|
81 SBS_V2 = 2 |
|
82 }; |
|
83 |
|
84 /** |
|
85 * Enumeration representing the mode project is run. |
|
86 */ |
|
87 enum PROJECT_MODE { |
|
88 COMPILE = 0, |
|
89 INSTRUMENT = 1, |
|
90 UNINSTRUMENT = 2, |
|
91 UNINSTRUMENT_FAILED =3, |
|
92 FAILED = 4, |
|
93 CLEAN = 5, |
|
94 ANALYZE = 6, |
|
95 INSTRUMENT_CONSOLE = 7, |
|
96 UNINSTRUMENT_CONSOLE = 8, |
|
97 FAILED_CONSOLE = 9, |
|
98 NOT_DEFINED = 10 |
|
99 }; |
|
100 |
|
101 /** |
|
102 * Enumeration repserenting the logging mode. |
|
103 */ |
|
104 enum LOGGING_MODE { |
|
105 DEFAULT = 0, |
|
106 FILE = 1, |
|
107 TRACE = 2, |
|
108 TRACE_FAST = 3 |
|
109 }; |
|
110 |
|
111 /** |
|
112 * Enumeration representing build type. |
|
113 */ |
|
114 enum BUILD_TYPE { |
|
115 UREL = 0, |
|
116 UDEB = 1 |
|
117 }; |
|
118 |
|
119 public: |
|
120 |
|
121 /** |
|
122 * Constructor |
|
123 */ |
|
124 CATProject(); |
|
125 |
|
126 /** |
|
127 * Destructor |
|
128 */ |
|
129 ~CATProject(); |
|
130 |
|
131 CATParseBinaryFile Parser; |
|
132 |
|
133 /** |
|
134 * Set arguments. |
|
135 * @param arguments. |
|
136 * @return true if arguments ok. |
|
137 */ |
|
138 bool SetArguments( ARGUMENTS& arguments ); |
|
139 |
|
140 /** |
|
141 * Set build system to be used with project. |
|
142 * See BUILD_SYSTEM enumeration for available systems. |
|
143 * @param eSystem system. |
|
144 */ |
|
145 void SetBuildSystem( BUILD_SYSTEM eSystem ); |
|
146 |
|
147 /** |
|
148 * Set mode which to run. |
|
149 * See PROJECT_MODE enumeration for available modes. |
|
150 * @param eMode mode. |
|
151 */ |
|
152 void SetMode(PROJECT_MODE eMode); |
|
153 |
|
154 /** |
|
155 * Get project mode. |
|
156 * @return mode of project. |
|
157 */ |
|
158 int GetMode() const; |
|
159 |
|
160 /** |
|
161 * Set epocroot. |
|
162 * @param sEpocroot |
|
163 */ |
|
164 void SetEpocRoot( const string& sEpocRoot ); |
|
165 |
|
166 /** |
|
167 * Set project platform. |
|
168 * @param sPlatform platform. |
|
169 */ |
|
170 void SetPlatform( const string& sPlatform ); |
|
171 |
|
172 /** |
|
173 * Set variant. |
|
174 * @sVariant variant. |
|
175 */ |
|
176 void SetVariant( const string& sVariant ); |
|
177 |
|
178 /** |
|
179 * Set logging mode. See LOGGING_MODE enumeration for available modes. |
|
180 * @param eLogginMode logging mode. |
|
181 */ |
|
182 void SetLoggingMode( LOGGING_MODE eLoggingMode); |
|
183 |
|
184 /** |
|
185 * Set build type. See BUILD_TYPE enumeration for available types. |
|
186 * @param eType build type. |
|
187 */ |
|
188 void SetBuildType( BUILD_TYPE eType ); |
|
189 |
|
190 /** |
|
191 * Set S60 logging filename. |
|
192 * @param sFileName filename. |
|
193 */ |
|
194 void SetS60FileName( const string& sFileName); |
|
195 |
|
196 /** |
|
197 * Set S60 logging file path. |
|
198 * @param sFilePath filename. |
|
199 */ |
|
200 void SetS60FilePath( const string& sFilePath ); |
|
201 |
|
202 /** |
|
203 * Set target module. |
|
204 * @param sTargetModule target module name. |
|
205 */ |
|
206 void SetTargetModule( const string& sTargetModule ); |
|
207 |
|
208 /** |
|
209 * Set multiple target modules used in project. |
|
210 * @param vTargetModules target module names. |
|
211 */ |
|
212 void SetTargetModules( const vector<string>& vTargetModules ); |
|
213 |
|
214 /** |
|
215 * Set Binary target name to create analysis results to. |
|
216 * @param sBinaryTarget binary target name. |
|
217 */ |
|
218 void SetBinaryTarget( const string& sBinaryTarget ); |
|
219 |
|
220 /** |
|
221 * Set data file to analyze. |
|
222 * @param sDataFile datafile. |
|
223 */ |
|
224 void SetDataFile( const string& sDataFile ); |
|
225 |
|
226 /** |
|
227 * Set rom symbol file(s) used in analyze. |
|
228 * @param sRomSymbolFile. |
|
229 */ |
|
230 void SetRomSymbolFiles(const vector<string>& vRomSymbolFiles); |
|
231 |
|
232 /** |
|
233 * Set the logging level of analysis report. |
|
234 * @param iLogLevel log level. |
|
235 */ |
|
236 void SetLogLevel( int iLogLevel ); |
|
237 |
|
238 /** |
|
239 * Set the size of allocation call stack to be written in temporary cpp. |
|
240 * @param iAllocCallStackSize |
|
241 */ |
|
242 void SetAllocCallStackSize( int iAllocCallStackSize ); |
|
243 |
|
244 /** |
|
245 * Set the size of free call stack to be written in temporary cpp. |
|
246 * @param iFreeCallStackSize |
|
247 */ |
|
248 void SetFreeCallStackSize( int iFreeCallStackSize ); |
|
249 |
|
250 /** |
|
251 * Set the output file name to store analyse report. |
|
252 * @param sDataFileOutput data file name. |
|
253 */ |
|
254 void SetDataFileOutput( const string& sDataFileOutput ); |
|
255 |
|
256 /** |
|
257 * Set build command used in compile phase. |
|
258 * @param sBuildCommand build command. |
|
259 */ |
|
260 void SetBuildCommand( const string& sBuildCommand ); |
|
261 |
|
262 /** |
|
263 * Run the set mode. |
|
264 * @return error code. |
|
265 */ |
|
266 int Run(); |
|
267 |
|
268 /** |
|
269 * Run recovery, used when "instatly" need to recover modules and exit. |
|
270 */ |
|
271 int RunRecoveryAndExit(); |
|
272 |
|
273 /** |
|
274 * Get build type string. |
|
275 * @param eType type from which to get correponding string. |
|
276 * @return types corresponding string. |
|
277 */ |
|
278 static string GetBuildTypeString( int eType ); |
|
279 |
|
280 /** |
|
281 * Reads projects configuration file if it exists. |
|
282 * @return false in case the data contains information that project is uninstrumented. Otherwise returns always true. |
|
283 */ |
|
284 bool IsUninstrumented(); |
|
285 |
|
286 #ifndef MODULE_TEST |
|
287 private: |
|
288 #endif |
|
289 /** |
|
290 * Run compiling in console. |
|
291 * @return error code. |
|
292 */ |
|
293 int RunCompile( void ); |
|
294 |
|
295 /** |
|
296 * Run cleaning project. |
|
297 * @return error code. |
|
298 */ |
|
299 int RunClean( void ); |
|
300 |
|
301 /** |
|
302 * Run running analyze. |
|
303 * @return error code. |
|
304 */ |
|
305 int RunAnalyze( void ); |
|
306 |
|
307 /** |
|
308 * Run instrumenting of project for Carbide extension (pre-build). |
|
309 * @return error code. |
|
310 */ |
|
311 int RunInstrument( void ); |
|
312 |
|
313 /** |
|
314 * Run uninstrumenting of project for Carbide extension (post-build). |
|
315 * @return error code. |
|
316 */ |
|
317 int RunUninstrument( void ); |
|
318 |
|
319 /** |
|
320 * Run uninstrumenting of project for Carbide extension(post-build), when build failed. |
|
321 * @return error code. |
|
322 */ |
|
323 int RunUninstrumentFailed( void ); |
|
324 |
|
325 /** |
|
326 * Run console instrumenting. |
|
327 * @return error code. |
|
328 */ |
|
329 int RunInstrumentConsole( void ); |
|
330 |
|
331 /** |
|
332 * Run Console uninstrumenting. |
|
333 * @return error code. |
|
334 */ |
|
335 int RunUninstrumentConsole( void ); |
|
336 |
|
337 /** |
|
338 * Run console uninstrumenting, when build failed. |
|
339 * @return error code. |
|
340 */ |
|
341 int RunFailedConsole( void ); |
|
342 |
|
343 /** |
|
344 * Show summary of compilation. |
|
345 */ |
|
346 void DisplayCompileSummary( void ); |
|
347 |
|
348 /** |
|
349 * Show summary, build target, build type, logging mode... |
|
350 */ |
|
351 void DisplayBuildSummary( void ); |
|
352 |
|
353 /** |
|
354 * Create make files. |
|
355 * @return true if successful |
|
356 */ |
|
357 bool CreateMakeFile( void ); |
|
358 /** |
|
359 * Create SBS v.1 make files. |
|
360 * @return true if successful. |
|
361 */ |
|
362 bool CreateMakeFileSbs1( void ); |
|
363 /** |
|
364 * Copy sbs1 makefile to temporary folder. |
|
365 * @return true if successful. |
|
366 */ |
|
367 bool CopyMakeFileSbs1ToTemporaryFolder( void ); |
|
368 /** |
|
369 * Run really clean in SBS v.1. |
|
370 * @return true if successful. |
|
371 */ |
|
372 bool RunReallyCleanSbs1( void ); |
|
373 /** |
|
374 * Run really clean in SBS v.2. |
|
375 * @return true if successful. |
|
376 */ |
|
377 bool RunReallyCleanSbs2( void ); |
|
378 /** |
|
379 * Run export in SBS v.1. |
|
380 * @return true if successful. |
|
381 */ |
|
382 bool RunExportSbs1( void ); |
|
383 /** |
|
384 * Create make files (level2) SBS v.1. |
|
385 * @return true if successful. |
|
386 */ |
|
387 bool CreateMakeFileSbs1Level2( void ); |
|
388 /** |
|
389 * Create makefile SBS v.2. |
|
390 * @return true if successful. |
|
391 */ |
|
392 bool CreateMakeFileSbs2( void ); |
|
393 /** |
|
394 * Read makefile. |
|
395 * @return true if successful. |
|
396 */ |
|
397 bool ReadMakeFile( void ); |
|
398 /** |
|
399 * Read SBS v.1 makefile. |
|
400 * @return true if successful. |
|
401 */ |
|
402 bool ReadMakeFileSbs1( void ); |
|
403 /** |
|
404 * Read SBS v.1 makefile (Level1). |
|
405 * @return true if successful. |
|
406 */ |
|
407 bool ReadMakeFileSbs1Level1( void ); |
|
408 /** |
|
409 * Read SBS v.2 makefiles. |
|
410 * @return true if successful. |
|
411 */ |
|
412 bool ReadMakeFileSbs2( void ); |
|
413 /** |
|
414 * Read specified SBS v.2 makefile. |
|
415 * @param sMakeFile makefile to be read. |
|
416 * @return true if succesful. |
|
417 */ |
|
418 bool ReadMakeFileSbs2( string& sMakeFile ); |
|
419 |
|
420 /** |
|
421 * Filter unsupported and static libraries to their own vectors. |
|
422 * Unsupported include kernel types, modules with kernel mode compile definition. |
|
423 * @return true if successful. |
|
424 */ |
|
425 bool FilterModules(); |
|
426 |
|
427 /** |
|
428 * Creates temporary directories for all modules |
|
429 * in member vector. |
|
430 * @return true if successful. |
|
431 */ |
|
432 bool CreateTemporaryDirectories(); |
|
433 |
|
434 /** |
|
435 * Creates tempororary cpp files for all modules |
|
436 * in member vector. |
|
437 * @return true if successful. |
|
438 */ |
|
439 bool CreateTemporaryCpps(); |
|
440 |
|
441 /** |
|
442 * Hooks all modules in member vector |
|
443 * (modifies mmp files) |
|
444 * @return true if successful |
|
445 */ |
|
446 bool ModifyModules( void ); |
|
447 |
|
448 /** |
|
449 * Unhooks all modules in member vector |
|
450 * (removes changes from mmp files) |
|
451 * @return true if successful |
|
452 */ |
|
453 bool RestoreModules( void ); |
|
454 |
|
455 /** |
|
456 * Verifys that member vectors modules |
|
457 * mmp files unchanged. Restores if they are |
|
458 * from backup or from original. |
|
459 * @return true if successful |
|
460 */ |
|
461 bool VerifyAndRecoverModules( void ); |
|
462 |
|
463 /** |
|
464 * Runs compilation. |
|
465 * @return true if successful. |
|
466 */ |
|
467 bool Compile( void ); |
|
468 /** |
|
469 * @return true if successful. |
|
470 */ |
|
471 bool CompileSbs1( void ); |
|
472 /** |
|
473 * @return true if successful. |
|
474 */ |
|
475 bool CompileSbs2( void ); |
|
476 |
|
477 /** |
|
478 * Runs listing creatation. |
|
479 * @return true if successful |
|
480 */ |
|
481 bool CreateListings( void ); |
|
482 /** |
|
483 * @return true if successful. |
|
484 */ |
|
485 bool CreateListingsSbs1( void ); |
|
486 /** |
|
487 * @return true if successful. |
|
488 */ |
|
489 bool CreateListingsSbs2( void ); |
|
490 /** |
|
491 * Copies releasables of modules including lst & map files |
|
492 * for all modules in project to their temporary directories. |
|
493 * @return true if successful. |
|
494 */ |
|
495 bool CopyReleasables( void ); |
|
496 /** |
|
497 * Deletes all atool_temp directories |
|
498 * of member vector modules. |
|
499 * @return true if successful. |
|
500 */ |
|
501 bool DeleteTemporaryDirs( void ); |
|
502 /** |
|
503 * Deletes files from atool_temp directory |
|
504 * of member vector modules which extension not defined |
|
505 * in TEMP_EXTENSION_NO_DELETE table. |
|
506 * @return true if successful. |
|
507 */ |
|
508 bool CleanTemporaryDirs( void ); |
|
509 /** |
|
510 * Writes class attributes to a file |
|
511 * under atool_temp directory. |
|
512 * @return true if successful. |
|
513 */ |
|
514 bool WriteAttributes( void ) const; |
|
515 /** |
|
516 * Read class attributes from a file |
|
517 * under atool_temp directory. |
|
518 * @return true if successful. |
|
519 */ |
|
520 bool ReadAttributes( void ); |
|
521 |
|
522 /** |
|
523 * Creates atool_temp directory if it does not |
|
524 * exist in current directory. |
|
525 * @return true if successful. |
|
526 */ |
|
527 bool MakeTempDirIfNotExist( void ); |
|
528 |
|
529 #ifndef MODULE_TEST |
|
530 private: |
|
531 #endif |
|
532 |
|
533 /** |
|
534 * Clean all module vectors. |
|
535 */ |
|
536 void CleanModuleVectors(); |
|
537 |
|
538 /** |
|
539 * Get build type as string. |
|
540 * @return buildtype string. |
|
541 */ |
|
542 string GetBuildTypeString(); |
|
543 |
|
544 /** |
|
545 * Helper function to add target module(s) |
|
546 * if any defined in class to given sbs command. |
|
547 * @param sCmd command to add modules to. |
|
548 */ |
|
549 void AddTargetModuleIfDefined(string& sCmd); |
|
550 |
|
551 /** |
|
552 * Run given system/abld command to all defined target modules in vector. |
|
553 * Space char (if its missing) will be added to given command + one target |
|
554 * module at a time. |
|
555 * @param sCommand sCommand to run. |
|
556 * @return true if none system call sets error level other than 0. |
|
557 */ |
|
558 bool RunAbldCommandToAllTargets( const string& sCommand ); |
|
559 |
|
560 /** |
|
561 * Check is target module in project. |
|
562 * If no modules / targets defined return value is true. |
|
563 * @return true if target module is in project. |
|
564 */ |
|
565 bool IsTargetModuleInProject( void ) const; |
|
566 |
|
567 /** |
|
568 * Initializes member make file variable with correct full path to point (epoc32/build)... |
|
569 * @return true if successful. |
|
570 */ |
|
571 bool InitSbs1MakeFileWithPath(); |
|
572 |
|
573 /** |
|
574 * Initializes member make file variable with correct full path to (atoo_temp...) |
|
575 * @return true if successful. |
|
576 */ |
|
577 bool InitSbs1MakeFileWithPathToTemp(); |
|
578 |
|
579 #ifndef MODULE_TEST |
|
580 private: |
|
581 #endif |
|
582 // System current directory. |
|
583 char m_cCurrentDir[ MAX_LINE_LENGTH ]; |
|
584 // Projects build system |
|
585 int m_eBuildSystem; |
|
586 // Project modules. |
|
587 vector<CATModule2*> m_vModules; |
|
588 // Static libraries. |
|
589 vector<CATModule2*> m_vStaticLibraries; |
|
590 // Unsupported project modules. |
|
591 vector<CATModule2*> m_vUnsupportedModules; |
|
592 // Run mode. |
|
593 int m_eMode; |
|
594 // Logging level (used in analyse). |
|
595 int m_iLoggingLevel; |
|
596 // Is project unsinstrumented. |
|
597 bool m_bUninstrumented; |
|
598 // Is build just for test modules |
|
599 bool m_bAbldTest; |
|
600 // Build command. |
|
601 string m_sBuildCommand; |
|
602 // Epocroot |
|
603 string m_sEpocRoot; |
|
604 // Platform i.e. armv5. |
|
605 string m_sPlatform; |
|
606 // SBS2 variant. |
|
607 string m_sVariant; |
|
608 // Logging mode (used in compile,instrumenting). |
|
609 int m_eLoggingMode; |
|
610 // Allocation call stack size |
|
611 int m_iAllocCallStackSize; |
|
612 // Free call stack size |
|
613 int m_iFreeCallStackSize; |
|
614 // Build type udeb / urel. |
|
615 int m_eBuildType; |
|
616 // Sbs v.1 level 1 make file |
|
617 string m_sMakeFile; |
|
618 // User given S60 log file name. |
|
619 string m_sS60FileName; |
|
620 // User given S60 log file path. |
|
621 string m_sS60FilePath; |
|
622 // Target module. |
|
623 string m_sTargetModule; |
|
624 // Target modules (used in carbide instrumenting). |
|
625 vector<string> m_vTargetModules; |
|
626 // Binary target (used in analyse). |
|
627 string m_sBinaryTarget; |
|
628 // User given datafile to analyse. |
|
629 string m_sDataFile; |
|
630 // |
|
631 vector<string> m_vRomSymbolFiles; |
|
632 // Temporary data file name if user gave trace file. |
|
633 string m_sDataFileTemp; |
|
634 // Temporary data file name if user gave binary log file. |
|
635 string m_sBinaryLogFileTemp; |
|
636 // User given output file to store analyse results. |
|
637 string m_sDataFileOutput; |
|
638 // Analyser object. |
|
639 CATDatParser* m_pAnalyzer; |
|
640 }; |
|
641 #endif |
|
642 // End of file |