]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/test-macros/compileEveMacros.C
Extra header added to the list
[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. cd $ALICE_ROOT/EVE/test-macros/
26  *  2. Launch alieve from terminal: alieve
27  *  3. from terminal execute this script: .x compileEveMacros.C
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  * The possible options are:
42      k : keep the shared library after the session end.
43      f : force recompilation.
44      g : compile with debug symbol
45      O : optimized the code (ignore if 'g' is specified)
46      c : compile only, do not attempt to load the library.
47      - : if buildir is set, use a flat structure (see buildir below)
48  */
49
50 void compileEveMacros( const char * macDir="", Option_t *opt="")
51 {
52
53    // solves current issue in ROOT when pre-compiling with ACLiC
54    gSystem->Load("libCint");
55    gSystem->Load("libTender");
56    gSystem->Load("libPWGPP");
57
58   if(macDir == "")
59     macDir = Form("%s/EVE/alice-macros", gSystem->Getenv("ALICE_ROOT") );
60   
61   if(opt == "")
62     opt = "-kc"; // compilation options
63   
64   TObjString *mac;
65   TList * listOfFailedMacros = new TList; // list of macros that failed compilation
66     
67   TSystemDirectory *curDir = new TSystemDirectory(macDir, macDir);
68   TSystemFile *curFile = 0;
69   
70   TList* listOfMacros = curDir->GetListOfFiles();
71   TListIter next(listOfMacros);
72   
73   TPMERegexp regex("\\.C$");
74     
75   printf("Directory: %s \tfiles:%d\n",  curDir->GetName(), listOfMacros->GetSize() );
76   gSystem->cd(curDir->GetName());
77
78   const char* incPath = gSystem->GetIncludePath();
79   
80   gSystem->SetIncludePath(Form("%s -I%s", incPath, "$ROOTSYS/include"));
81   
82   
83   Int_t nMacros = 0;
84   
85   while( (curFile = static_cast<TSystemFile*>(next())) )
86   {
87     mac = new TObjString(curFile->GetName());
88     
89     if( regex.Match(mac->String().Data() ) > 0 )
90     {
91         nMacros++;
92       
93         printf("Macro %s\n", mac->String().Data() );
94         TEveUtil::CheckMacro(mac->String().Data() );
95         if(!gSystem->CompileMacro(mac->String().Data(), opt ) )
96           listOfFailedMacros->Add(mac);
97     }
98     
99   }
100   
101   printf("\n\nTotal Macros:%d \tFailed:%d \n", nMacros, listOfFailedMacros->GetSize() );
102   
103   printf("\nFollowing macros failed compilation: \n");
104   TListIter failed(listOfFailedMacros);
105   while( (mac = static_cast<TObjString*>(failed())) )
106   {
107     printf( "%s\n", mac->String().Data() );
108   }
109   
110   delete listOfFailedMacros;
111   delete listOfMacros;
112   delete curDir;
113 }