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