]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/test-macros/compileEveMacros.C
Adding new test macro (Mihai)
[u/mrichter/AliRoot.git] / EVE / test-macros / compileEveMacros.C
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: 
25  *  1. Launch alieve from terminal
26  *  2. ROOT command prompt from terminal execute this script: .x compileEveMacros.C
27  *  3. Wait for compilation to finish
28  * 
29  * NOTE:
30  *  At the end of compilation,you might get a list 
31  * with all macros that failed compilation
32  * 
33  * Parameters:
34  *  macDir  - absolute directory path where to find the macros
35  *  opt     - compilation options (See: TSystem::CompileMacro)
36  * 
37  * Default:
38  *  - compiles all macros from AliRoot installation dir ($ALICE_ROOT/EVE/alice-macros)
39  *  - options for compilation (- k f c)
40  */
41
42 void compileEveMacros( const char * macDir="", Option_t *opt="")
43 {
44   if(macDir == "")
45     macDir = Form("%s/EVE/alice-macros", gSystem->Getenv("ALICE_ROOT") );
46   
47   if(opt == "")
48     opt = "-kfc"; // compilation options
49   
50   TObjString *mac;
51   TList * listOfFailedMacros = new TList; // list of macros that failed compilation
52     
53   TSystemDirectory *curDir = new TSystemDirectory(macDir, macDir);
54   TSystemFile *curFile = 0;
55   
56   TList* listOfMacros = curDir->GetListOfFiles();
57   TListIter next(listOfMacros);
58   
59   TPMERegexp regex("\\.C$");
60     
61   printf("Files found in macro directory: %d\n", listOfMacros->GetSize() );
62   
63   Int_t nMacros = 0;
64   
65   while( (curFile = static_cast<TSystemFile*>(next())) )
66   {
67     mac = new TObjString(curFile->GetName());
68     
69     if( regex.Match(mac->String().Data() ) > 0 )
70     {
71         nMacros++;
72       
73         printf("Macro %s\n", mac->String().Data() );
74         TEveUtil::CheckMacro(mac->String().Data() );
75         if(!gSystem->CompileMacro(mac->String().Data(), opt, mac->String().Data(), macDir) )
76           listOfFailedMacros->Add(mac);
77     }
78     
79   }
80   
81   printf("\n\nTotal Macros:%d \tFailed:%d \n", nMacros, listOfFailedMacros->GetSize() );
82   
83   printf("\nFollowing macros failed compilation: \n");
84   TListIter failed(listOfFailedMacros);
85   while( (mac = static_cast<TObjString*>(failed())) )
86   {
87     printf( "%s\n", mac->String().Data() );
88   }
89   
90   delete listOfFailedMacros;
91   delete listOfMacros;
92   delete curDir;
93 }