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