Increment ClassDef
[u/mrichter/AliRoot.git] / EVE / test-macros / compileEveMacros.C
CommitLineData
36e97d8a 1/**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
3 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
4 * full copyright notice. *
5 **************************************************************************/
6
7//************************************************************************
8// Author: Mihai Niculescu (mihai.niculescu@cern.ch)
9// Jan 31 2012
10//************************************************************************
11
12#if !defined(__CINT__) || defined(__MAKECINT__)
13#include <TList.h>
14#include <TObjString.h>
15#include <TString.h>
16#include <TSystem.h>
17#include <TSystemDirectory.h>
18#include <TSystemFile.h>
19#include <TEveUtil.h>
20#endif
21
22/* Compiles all AliEve macros
23 *
24 * Usage:
6c49a8e1 25 * 1. cd $ALICE_ROOT/EVE/test-macros/
26 * 2. Launch alieve from terminal: alieve
27 * 3. from terminal execute this script: .x compileEveMacros.C
36e97d8a 28 * 3. Wait for compilation to finish
29 *
30 * NOTE:
31 * At the end of compilation,you might get a list
32 * with all macros that failed compilation
33 *
34 * Parameters:
35 * macDir - absolute directory path where to find the macros
36 * opt - compilation options (See: TSystem::CompileMacro)
37 *
38 * Default:
39 * - compiles all macros from AliRoot installation dir ($ALICE_ROOT/EVE/alice-macros)
40 * - options for compilation (- k f c)
41 */
42
43void compileEveMacros( const char * macDir="", Option_t *opt="")
44{
45 if(macDir == "")
46 macDir = Form("%s/EVE/alice-macros", gSystem->Getenv("ALICE_ROOT") );
47
48 if(opt == "")
49 opt = "-kfc"; // compilation options
50
51 TObjString *mac;
52 TList * listOfFailedMacros = new TList; // list of macros that failed compilation
53
54 TSystemDirectory *curDir = new TSystemDirectory(macDir, macDir);
55 TSystemFile *curFile = 0;
56
57 TList* listOfMacros = curDir->GetListOfFiles();
58 TListIter next(listOfMacros);
59
60 TPMERegexp regex("\\.C$");
61
62 printf("Files found in macro directory: %d\n", listOfMacros->GetSize() );
63
64 Int_t nMacros = 0;
65
66 while( (curFile = static_cast<TSystemFile*>(next())) )
67 {
68 mac = new TObjString(curFile->GetName());
69
70 if( regex.Match(mac->String().Data() ) > 0 )
71 {
72 nMacros++;
73
74 printf("Macro %s\n", mac->String().Data() );
75 TEveUtil::CheckMacro(mac->String().Data() );
76 if(!gSystem->CompileMacro(mac->String().Data(), opt, mac->String().Data(), macDir) )
77 listOfFailedMacros->Add(mac);
78 }
79
80 }
81
82 printf("\n\nTotal Macros:%d \tFailed:%d \n", nMacros, listOfFailedMacros->GetSize() );
83
84 printf("\nFollowing macros failed compilation: \n");
85 TListIter failed(listOfFailedMacros);
86 while( (mac = static_cast<TObjString*>(failed())) )
87 {
88 printf( "%s\n", mac->String().Data() );
89 }
90
91 delete listOfFailedMacros;
92 delete listOfMacros;
93 delete curDir;
6c49a8e1 94}