Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_compile.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // command used to compile macros with ROOT ACLiC compiler
20 {
21 
23 
24  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
25  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
26  TB.checkFile(gSystem->Getenv("CWB_NETC_FILE"));
27 
28 
29  // get macro path
31  if(gSystem->Getenv("CWB_COMPILE_MACRO_NAME")!=NULL) {
32  // user define condor tag
33  macroPath=TString(gSystem->Getenv("CWB_COMPILE_MACRO_NAME"));
34  }
35  TB.checkFile(macroPath);
36 
37  if(!macroPath.EndsWith(".C"))
38  {cout << "cwb_compile - Error : macro : " << macroPath << " must have extension .C" << endl;gSystem->Exit(1);}
39 
41  libPath.ReplaceAll(".C","_C");
42 
43  int error;
44  char command[1024];
45 
46  // get macro + cWB compiler flags
48 
49  // compile & load macro
50  cout << endl << "cwb_compile : Macro compilation ..." << endl << endl;
51  int success = gSystem->CompileMacro(TString(macroTmp).Data(),"kf",libPath);
52  if(!success) {
53  cout << endl << "cwb_compile : Macro Compilation Failed !!! " << endl << endl;
54  exit(1);
55  }
56 
57  // check if the compiled shared files exists and is readable
58  int check = gROOT->LoadMacro((libPath+".so").Data(),&error,true);
59  if(check==-1) {
60  cout << endl << "cwb_compile : Macro Compilation Failed !!! " << endl << endl;
61  exit(1);
62  }
63 
64  // remove temporary ACLiC_dict_rdict.pcm file created by ACLiC
66  macroTmp1.ReplaceAll(".C","_C_ACLiC_dict_rdict.pcm");
67  sprintf(command, "/bin/rm -f %s", macroTmp1.Data());
68  error=gSystem->Exec(command);
69  if(error) {
70  cout << endl << "cwb_compile - Error -> " << command << endl << endl;
71  exit(1);
72  }
73  // remove temporary _C.d file created by ACLiC
75  macroTmp2.ReplaceAll(".C","_C.d");
76  sprintf(command, "/bin/rm -f %s", macroTmp2.Data());
77  error=gSystem->Exec(command);
78  if(error) {
79  cout << endl << "cwb_compile - Error -> " << command << endl << endl;
80  exit(1);
81  }
82 
83  cout << endl << "cwb_compile : Macro successfully compiled !!! " << endl << endl;
84  exit(0);
85 }
86 
TString libPath
Definition: cwb_compile.C:40
int error
Definition: cwb_compile.C:43
TString("c")
int check
Definition: cwb_compile.C:58
CWB::Toolbox TB
char command[1024]
Definition: cwb_compile.C:44
TString macroTmp
Definition: cwb_compile.C:47
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
sprintf(command, "/bin/rm -f %s", macroTmp1.Data())
TString macroPath
Definition: cwb_compile.C:30
TString macroTmp1
Definition: cwb_compile.C:65
TString macroTmp2
Definition: cwb_compile.C:74
exit(0)
static TString addCWBFlags(TMacro macro, TString ofname="")
Definition: Toolbox.cc:4830