[1224] | 1 | #include "cxxexecutor.h"
|
---|
| 2 |
|
---|
| 3 | #include <typeinfo>
|
---|
| 4 |
|
---|
[1237] | 5 | #include "strutilxx.h"
|
---|
[1224] | 6 | #include "dvlist.h"
|
---|
[1287] | 7 | #include "cxxcmplnk.h"
|
---|
[1224] | 8 |
|
---|
| 9 | #include "nomgadapter.h"
|
---|
| 10 | #include "pistdimgapp.h"
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | /* --Methode-- */
|
---|
| 14 | CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
|
---|
[1287] | 15 | : mUserCodeFn(""), mUserFctFn("")
|
---|
| 16 | , mCompOpt(""), mLinkOpt(""), mMyLibs("")
|
---|
[2287] | 17 | , mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(2), mFgPutVar(false)
|
---|
[1224] | 18 | {
|
---|
| 19 | mIncList.resize(0);
|
---|
| 20 | mCallArgs.resize(0);
|
---|
| 21 |
|
---|
[1297] | 22 | mIncImportList.resize(0);
|
---|
| 23 | mModuleImportList.resize(0);
|
---|
| 24 |
|
---|
| 25 | // La liste de tous les modules que l'on peut ajouter
|
---|
| 26 | mModuleImportDefaultList.resize(0);
|
---|
| 27 | mModuleImportDefaultList.push_back("Samba");
|
---|
| 28 | mModuleImportDefaultList.push_back("SkyMap");
|
---|
[1319] | 29 | mModuleImportDefaultList.push_back("SkyT");
|
---|
| 30 | mModuleImportDefaultList.push_back("FitsIOServer");
|
---|
| 31 | mModuleImportDefaultList.push_back("IFFTW");
|
---|
| 32 | mModuleImportDefaultList.push_back("LinAlg");
|
---|
[1646] | 33 | mModuleImportDefaultList.push_back("XAstroPack");
|
---|
[1297] | 34 |
|
---|
[1224] | 35 | // On enregistre les nouvelles commandes
|
---|
| 36 | string hgrp = "CxxExecutorCmd";
|
---|
| 37 | string usage,kw;
|
---|
| 38 |
|
---|
| 39 | kw = "c++exec";
|
---|
| 40 | usage = "c++exec: Execute the following c++ user code\n";
|
---|
[1237] | 41 | usage+= "Usage: c++exec c++ user code\n";
|
---|
[1268] | 42 | usage+= "Warning: c++ user code can be found in \"TmpDir/"+mDefRoot+".h\"\n";
|
---|
| 43 | usage+= " total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
|
---|
[1224] | 44 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 45 |
|
---|
| 46 | kw = "c++execfrf";
|
---|
[1268] | 47 | usage = "c++execfrf: Execute c++ user_code [user_function_code]\n";
|
---|
| 48 | usage+= "Usage: c++execfrf fileuser.cc [fileuserfct.cc]\n";
|
---|
| 49 | usage+= "Warning: total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
|
---|
[1224] | 50 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 51 |
|
---|
| 52 | kw = "c++args";
|
---|
[1237] | 53 | usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
|
---|
[1230] | 54 | usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
|
---|
| 55 | usage+= " c++args -? : give current arguments\n";
|
---|
| 56 | usage+= " c++args : reset current arguments";
|
---|
[1224] | 57 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 58 |
|
---|
| 59 | kw = "c++create";
|
---|
[1287] | 60 | usage = "c++create: create a file \"file.cc\" to be used by spiapp\n";
|
---|
[1224] | 61 | usage+= "Usage: c++create file.cc func c++ user code...\n";
|
---|
| 62 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 63 |
|
---|
| 64 | kw = "c++createfrf";
|
---|
[1287] | 65 | usage = "c++createfrf: create a file \"file.cc\" to be used by spiapp\n";
|
---|
| 66 | usage+= " with a user file code \"fileuser.cc\"\n";
|
---|
| 67 | usage+= " and an optional user function code \"fileuserfct.cc\"\n";
|
---|
[1268] | 68 | usage+= "Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]\n";
|
---|
[1224] | 69 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 70 |
|
---|
| 71 | kw = "c++compile";
|
---|
| 72 | usage = "c++compile: compile a file (file.cc -> file.so)\n";
|
---|
| 73 | usage+= "Usage: c++compile file\n";
|
---|
| 74 | usage+= "Warning: give \"file\" or \"file.so\" to create \"file.so\" from \"file.cc\"\n";
|
---|
| 75 | usage+= " : to be used before c++link";
|
---|
| 76 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 77 |
|
---|
| 78 | kw = "c++link";
|
---|
| 79 | usage = "c++link: link function \"func\" in file.so to spiapp\n";
|
---|
| 80 | usage+= "Usage: c++link file.so func";
|
---|
| 81 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 82 |
|
---|
| 83 | kw = "c++include";
|
---|
[1297] | 84 | usage = "c++include: add personnal includes to be used by executor\n";
|
---|
[1224] | 85 | usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
|
---|
[1297] | 86 | usage+= " c++include -? : list current additionnal include files\n";
|
---|
| 87 | usage+= " c++include : reset to no additionnal include files\n";
|
---|
| 88 | usage+= "Warning: to be used before c++create c++compile c++exec...";
|
---|
[1224] | 89 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 90 |
|
---|
| 91 | kw = "c++compileopt";
|
---|
[1297] | 92 | usage = "c++compileopt: add personnal compile options\n";
|
---|
[1224] | 93 | usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
|
---|
[1297] | 94 | usage+= " c++compileopt -? : list current additionnal compile options\n";
|
---|
| 95 | usage+= " c++compileopt : reset to no additionnal compile options\n";
|
---|
| 96 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 97 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 98 |
|
---|
| 99 | kw = "c++linkopt";
|
---|
[1297] | 100 | usage = "c++linkopt: add personnal link options\n";
|
---|
[1230] | 101 | usage+= "Usage: c++linkopt -g -O5 ...\n";
|
---|
[1297] | 102 | usage+= " c++linkopt -? : list current additionnal link options\n";
|
---|
| 103 | usage+= " c++linkopt : reset to no additionnal link options\n";
|
---|
| 104 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 105 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 106 |
|
---|
| 107 | kw = "c++mylibs";
|
---|
[1297] | 108 | usage = "c++mylibs: add personnal libraries\n";
|
---|
[1230] | 109 | usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
|
---|
[1297] | 110 | usage+= " c++mylibs -? : list current additionnal libraries\n";
|
---|
| 111 | usage+= " c++mylibs : reset to no additionnal libraries\n";
|
---|
| 112 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 113 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 114 |
|
---|
[1297] | 115 | kw = "c++import";
|
---|
| 116 | usage = "c++import: Sophya additionnal modules to be use in C++ executor\n";
|
---|
| 117 | usage+= "Usage: c++import module1 ... : set list of modules to be used by executor\n";
|
---|
| 118 | usage+= " c++import all : set all modules known by executor\n";
|
---|
| 119 | usage+= " c++import : reset to no additionnal module\n";
|
---|
| 120 | usage+= " c++import -? : list modules currently used in executor\n";
|
---|
| 121 | usage+= " c++import -?? : list of available modules for executor\n";
|
---|
| 122 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
| 123 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[1230] | 124 |
|
---|
[2287] | 125 | kw = "c++declareomgvar";
|
---|
| 126 | usage = "c++declareomgvar: Activate/Deactivate ObjectManager variables declaration \n";
|
---|
| 127 | usage+= "Usage: c++declareomgvar [false/true] \n";
|
---|
| 128 | usage+= " if true, the ObjectManager variables are declared as $varname \n";
|
---|
| 129 | usage+= " no arguments: display the current status of the flag (default=false\n";
|
---|
| 130 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 131 |
|
---|
[1289] | 132 | kw = "c++prtlevel";
|
---|
| 133 | usage = "c++prtlevel: Print level\n";
|
---|
| 134 | usage+= "Usage: c++prtlevel prtlevel\n";
|
---|
| 135 | usage+= " prtlevel=0 : minimum printing\n";
|
---|
| 136 | usage+= " prtlevel=1 : + compiler/linker output\n";
|
---|
| 137 | usage+= " prtlevel=2 : + full infos (default)";
|
---|
| 138 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 139 |
|
---|
[1224] | 140 | }
|
---|
| 141 |
|
---|
| 142 | /* --Methode-- */
|
---|
| 143 | CxxExecutor::~CxxExecutor()
|
---|
| 144 | {
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | /* --Methode-- */
|
---|
[1268] | 148 | int CxxExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
|
---|
[1224] | 149 | {
|
---|
| 150 | int rc=0;
|
---|
[1268] | 151 | if(kw == "c++exec") {
|
---|
[1224] | 152 | if(tokens.size()<1) {
|
---|
| 153 | cout<<"Usage: c++exec c++ user code"<<endl;
|
---|
| 154 | return(1);
|
---|
| 155 | }
|
---|
[1269] | 156 | rc = ExecuteCXX(toks); if(rc) return(1);
|
---|
[1268] | 157 |
|
---|
| 158 | } else if(kw == "c++execfrf") {
|
---|
| 159 | if(tokens.size()<1) {
|
---|
| 160 | cout<<"Usage: c++execfrf fileuser.cc [fileuserfct.cc]"<<endl;
|
---|
| 161 | return(1);
|
---|
| 162 | }
|
---|
[1269] | 163 | rc = FillUserCode(tokens[0]); if(rc) return(1);
|
---|
| 164 | if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
|
---|
[1287] | 165 | else rc = FillUserFctFrF();
|
---|
| 166 | if(rc) return(1);
|
---|
[1224] | 167 | rc = CrFile(); if(rc) return(1);
|
---|
| 168 | rc = Compile(); if(rc) return(1);
|
---|
| 169 | rc = Link(); if(rc) return(1);
|
---|
| 170 | rc = Call(); if(rc) return(1);
|
---|
| 171 |
|
---|
| 172 | } else if(kw == "c++args") {
|
---|
[1233] | 173 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 174 | {cout<<"c++args "<<GetArgs()<<endl; return(0);}
|
---|
[1230] | 175 | FillArgs(tokens);
|
---|
[1224] | 176 |
|
---|
| 177 | } else if(kw == "c++create") {
|
---|
| 178 | if(tokens.size()<3) {
|
---|
| 179 | cout<<"Usage: c++create file.cc func c++ user code ..."<<endl;
|
---|
| 180 | return(1);
|
---|
| 181 | }
|
---|
[1287] | 182 | rc = FillUserCode(toks,2); if(rc) return(1);
|
---|
| 183 | rc = FillUserFctFrS(); if(rc) return(1);
|
---|
| 184 | rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
|
---|
[1224] | 185 |
|
---|
| 186 | } else if(kw == "c++createfrf") {
|
---|
| 187 | if(tokens.size()<3) {
|
---|
[1268] | 188 | cout<<"Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]"<<endl;
|
---|
[1224] | 189 | return(1);
|
---|
| 190 | }
|
---|
[1269] | 191 | rc = FillUserCode(tokens[2]); if(rc) return(1);
|
---|
[1287] | 192 | if(tokens.size()>3) rc = FillUserFctFrF(tokens[3]);
|
---|
| 193 | else rc = FillUserFctFrF(tokens[3]);
|
---|
| 194 | if(rc) return(1);
|
---|
[1224] | 195 | rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
|
---|
| 196 |
|
---|
| 197 | } else if(kw == "c++compile") {
|
---|
| 198 | if(tokens.size()>=1) rc = Compile(tokens[0]);
|
---|
| 199 | else rc = Compile();
|
---|
| 200 | if(rc) return(1);
|
---|
| 201 |
|
---|
| 202 | } else if(kw == "c++link") {
|
---|
| 203 | if(tokens.size()>=2) rc = Link(tokens[0],tokens[1]);
|
---|
| 204 | else if(tokens.size()>=1) rc = Link(tokens[0]);
|
---|
| 205 | else rc = Link();
|
---|
| 206 | if(rc) return(1);
|
---|
| 207 |
|
---|
| 208 | } else if(kw == "c++include") {
|
---|
[1233] | 209 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 210 | {cout<<"c++include "<<GetInclude()<<endl; return(0);}
|
---|
[1230] | 211 | FillInclude(tokens);
|
---|
[1224] | 212 |
|
---|
| 213 | } else if(kw == "c++compileopt") {
|
---|
[1233] | 214 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 215 | {cout<<"c++compileopt "<<GetCompileOpt()<<endl; return(0);}
|
---|
[1230] | 216 | FillCompileOpt(tokens);
|
---|
[1224] | 217 |
|
---|
| 218 | } else if(kw == "c++linkopt") {
|
---|
[1233] | 219 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 220 | {cout<<"c++linkopt "<<GetLinkOpt()<<endl; return(0);}
|
---|
[1230] | 221 | FillLinkOpt(tokens);
|
---|
[1224] | 222 |
|
---|
| 223 | } else if(kw == "c++mylibs") {
|
---|
[1233] | 224 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 225 | {cout<<"c++mylibs "<<GetLinkLibs()<<endl; return(0);}
|
---|
[1230] | 226 | FillLinkLibs(tokens);
|
---|
[1289] | 227 |
|
---|
[1297] | 228 | } else if(kw == "c++import") {
|
---|
| 229 | if(tokens.size()==1) {
|
---|
| 230 | if(tokens[0]=="-?")
|
---|
| 231 | {cout<<"c++import "<<GetModuleImport()<<endl; return(0);}
|
---|
| 232 | if(tokens[0]=="-??") {
|
---|
| 233 | cout<<"c++import possibilities :"<<endl;
|
---|
| 234 | if(mModuleImportDefaultList.size()>0) {
|
---|
| 235 | for(uint_4 i=0;i<mModuleImportDefaultList.size();i++)
|
---|
| 236 | cout<<" "<<mModuleImportDefaultList[i];
|
---|
| 237 | cout<<endl;
|
---|
| 238 | }
|
---|
| 239 | return(0);
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 | FillModuleImport(tokens);
|
---|
[2287] | 243 | } else if(kw == "c++declareomgvar") {
|
---|
| 244 | if (tokens.size() <1) {
|
---|
| 245 | string fgstat = (mFgPutVar) ? "TRUE" : "FALSE" ;
|
---|
| 246 | cout << " c++declareomgvar: Current flag status: " << fgstat << endl;
|
---|
| 247 | }
|
---|
| 248 | else {
|
---|
| 249 | if (tokens[0] == "true") DeclareObjMgrVar(true);
|
---|
| 250 | else if (tokens[0] == "false") DeclareObjMgrVar(false);
|
---|
| 251 | }
|
---|
[1289] | 252 | } else if(kw == "c++prtlevel") {
|
---|
| 253 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 254 | {cout<<"c++prtlevel prtlevel = "<<mPrtLevel<<endl; return(0);}
|
---|
| 255 | if(tokens.size()>0) {
|
---|
| 256 | int lp=atoi(tokens[0].c_str()); if(lp<0) lp=0;
|
---|
| 257 | mPrtLevel=(uint_2) lp;
|
---|
| 258 | } else mPrtLevel=2;
|
---|
| 259 |
|
---|
[1224] | 260 | }
|
---|
| 261 |
|
---|
| 262 | return(0);
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | /* --Methode-- */
|
---|
[1269] | 266 | int CxxExecutor::ExecuteCXX(string usercode,string userfct)
|
---|
| 267 | {
|
---|
| 268 | int rc=0;
|
---|
| 269 | rc = FillUserCode(usercode,0); if(rc) return(1);
|
---|
[1287] | 270 | rc = FillUserFctFrS(userfct); if(rc) return(1);
|
---|
[1269] | 271 | rc = CrFile(); if(rc) return(1);
|
---|
| 272 | rc = Compile(); if(rc) return(1);
|
---|
| 273 | rc = Link(); if(rc) return(1);
|
---|
| 274 | rc = Call(); if(rc) return(1);
|
---|
| 275 | return 0;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | /* --Methode-- */
|
---|
[1268] | 279 | int CxxExecutor::CrFile(string cfilename,string func)
|
---|
[1287] | 280 | // Si un nom n'est pas precise alors TmpDir/cxx_spiapp.cc
|
---|
[1262] | 281 | {
|
---|
[2181] | 282 | if(cfilename.size()<1) cfilename = TmpDir() + mDefRoot + ".cc";
|
---|
[1287] | 283 |
|
---|
[1268] | 284 | if(func.size()<1) func = mDefFunc;
|
---|
[1262] | 285 |
|
---|
[1224] | 286 | ofstream os(cfilename.c_str(),ios::out);
|
---|
[1237] | 287 | if(!os)
|
---|
| 288 | {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
|
---|
| 289 | return 1;}
|
---|
[1224] | 290 |
|
---|
| 291 | PutInclude(os);
|
---|
| 292 | os<<endl;
|
---|
| 293 |
|
---|
| 294 | PutIncludeUser(os);
|
---|
| 295 | os<<endl;
|
---|
| 296 |
|
---|
[1268] | 297 | os<<"//-------------------------------------------------//"<<endl;
|
---|
[1269] | 298 | os<<"//----------------- User Functions ----------------//"<<endl;
|
---|
[1268] | 299 | os<<"//-------------------------------------------------//"<<endl;
|
---|
| 300 | if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
|
---|
| 301 | os<<endl;
|
---|
| 302 |
|
---|
| 303 |
|
---|
[1224] | 304 | os<<"extern \"C\" {"<<endl;
|
---|
| 305 | os<<" int "<<func<<"( vector<string>& args );"<<endl;
|
---|
| 306 | os<<"}"<<endl<<endl;
|
---|
| 307 | os<<"int "<<func<<"( vector<string>& args )"<<endl;
|
---|
| 308 | os<<"{"<<endl;
|
---|
| 309 | os<<"// Some definitions to help using spiapp;"<<endl;
|
---|
| 310 | os<<"NamedObjMgr omg;"<<endl;
|
---|
| 311 | os<<"Services2NObjMgr& srvo = *omg.GetServiceObj();"<<endl;
|
---|
| 312 | os<<endl;
|
---|
| 313 |
|
---|
| 314 | PutObject(os);
|
---|
| 315 | os<<endl;
|
---|
| 316 |
|
---|
[2287] | 317 | if (mFgPutVar) PutVar(os);
|
---|
[1224] | 318 | os<<endl;
|
---|
| 319 |
|
---|
[1237] | 320 | os<<"//--------------------------------------------//"<<endl;
|
---|
[1269] | 321 | os<<"//----------------- User Code ----------------//"<<endl;
|
---|
[1237] | 322 | os<<"//--------------------------------------------//"<<endl;
|
---|
[1269] | 323 | if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
|
---|
[1224] | 324 | os<<endl;
|
---|
| 325 |
|
---|
| 326 | os<<"return 0;"<<endl;
|
---|
| 327 | os<<"}"<<endl;
|
---|
| 328 |
|
---|
[1289] | 329 | if(mPrtLevel>1)
|
---|
[1269] | 330 | cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
|
---|
[1289] | 331 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
---|
[1269] | 332 | cout<<" User code was in file "<<mUserCodeFn<<endl;
|
---|
[1289] | 333 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
---|
[1269] | 334 | cout<<" User function code was in file "<<mUserFctFn<<endl;
|
---|
[1224] | 335 | return 0;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 | /* --Methode-- */
|
---|
| 339 | void CxxExecutor::PutInclude(ofstream& os)
|
---|
| 340 | {
|
---|
[1297] | 341 | os<<"#include \"machdefs.h\""<<endl<<endl;
|
---|
[1224] | 342 |
|
---|
[1297] | 343 | os<<"//---- System et stdc++ include files"<<endl
|
---|
[1224] | 344 | <<"#include <stdio.h>"<<endl
|
---|
| 345 | <<"#include <stdlib.h>"<<endl
|
---|
| 346 | <<"#include <math.h>"<<endl
|
---|
| 347 | <<"#include <ctype.h>"<<endl
|
---|
| 348 | <<"#include <string.h>"<<endl
|
---|
[2322] | 349 | <<"#include <iostream>"<<endl
|
---|
| 350 | <<"#include <fstream>"<<endl
|
---|
[1224] | 351 | <<"#include <complex>"<<endl
|
---|
| 352 | <<endl
|
---|
| 353 |
|
---|
| 354 | <<"#include <typeinfo>"<<endl
|
---|
| 355 | <<"#include <string>"<<endl
|
---|
| 356 | <<"#include <vector>"<<endl
|
---|
| 357 | <<"#include <map>"<<endl
|
---|
| 358 | <<"#include <functional>"<<endl
|
---|
| 359 | <<"#include <list>"<<endl
|
---|
| 360 | <<endl
|
---|
| 361 |
|
---|
[2123] | 362 | #ifdef SANS_EVOLPLANCK
|
---|
| 363 | <<"//---- Peida include files"<<endl
|
---|
| 364 | <<"#include \"toutpeida.h\""<<endl
|
---|
| 365 | #else
|
---|
[1224] | 366 | <<"//---- Sophya include files"<<endl
|
---|
[1607] | 367 | <<"#include \"basetools.h\""<<endl
|
---|
[1224] | 368 | <<"#include \"systools.h\""<<endl
|
---|
[1607] | 369 | <<"#include \"sutils.h\""<<endl
|
---|
[1224] | 370 | <<"#include \"ntools.h\""<<endl
|
---|
| 371 | <<"#include \"array.h\""<<endl
|
---|
| 372 | <<"#include \"histats.h\""<<endl
|
---|
| 373 | <<endl
|
---|
[2123] | 374 | #endif
|
---|
[1224] | 375 |
|
---|
| 376 | <<"//---- Spiapp include files"<<endl
|
---|
| 377 | <<"#include \"nobjmgr.h\""<<endl
|
---|
| 378 | <<"#include \"servnobjm.h\""<<endl
|
---|
[1297] | 379 | <<endl;
|
---|
[1224] | 380 |
|
---|
[1297] | 381 | os<<"//---- Include files from additionnal modules"<<endl;
|
---|
| 382 | if(mIncImportList.size()>0)
|
---|
| 383 | for(uint_4 i=0;i<mIncImportList.size();i++)
|
---|
| 384 | os<<"#include \""<<mIncImportList[i]<<"\""<<endl;
|
---|
| 385 | os<<endl;
|
---|
| 386 |
|
---|
[1469] | 387 | os<<"//---- function to compare bits on double \n"
|
---|
| 388 | <<"int_8 BitCmp64(double v,int_8 flg) \n"
|
---|
| 389 | <<"{return ((int_8)((v<0.) ? v-0.1 : v+0.1))&flg;} \n"
|
---|
| 390 | <<endl;
|
---|
| 391 |
|
---|
[1319] | 392 | os<<"//---- function for Adding and displaying Objects " << endl;
|
---|
| 393 | os<<"void Keep_Object(AnyDataObj & obj, string const & nom) \n{ \n"
|
---|
| 394 | <<" string name = nom; \n NamedObjMgr om; \n"
|
---|
| 395 | <<" if (om.GetObj(name)) \n"
|
---|
| 396 | <<" cerr << \"KeepObj()/Warning Already kept object \" << endl; \n"
|
---|
| 397 | <<" else om.AddObj(obj, name); \n"
|
---|
| 398 | <<"} \n" << endl;
|
---|
| 399 | os<<"void Display_Object(AnyDataObj & obj, string const & opt, string const & nom) \n { \n"
|
---|
| 400 | <<" string name = nom; \n NamedObjMgr om; \n"
|
---|
| 401 | <<" if (!om.GetObj(name)) \n"
|
---|
| 402 | <<" om.AddObj(obj, name); \n"
|
---|
| 403 | <<" om.DisplayObj(name, opt); \n"
|
---|
| 404 | <<"} \n" << endl;
|
---|
[2287] | 405 | os<<"//---- function for getting and setting ObjectManager variables " << endl;
|
---|
| 406 | os<<"void Set_ObjMgrVar(MuTyV v, string const & nom) \n{ \n"
|
---|
| 407 | <<" NamedObjMgr om; \n"
|
---|
| 408 | <<" om.SetVar(nom, (string)v); \n"
|
---|
| 409 | <<"} \n" << endl;
|
---|
| 410 | os<<"MuTyV Get_ObjMgrVar(const char * nom) \n{ \n"
|
---|
| 411 | <<" string name = nom; NamedObjMgr om; \n"
|
---|
| 412 | <<" MuTyV v = om.GetVar(name); \n"
|
---|
| 413 | <<" return v; \n"
|
---|
| 414 | <<"} \n" << endl;
|
---|
[1319] | 415 |
|
---|
[2287] | 416 | os<<"//---- Macro for Objects and variables saving"<<endl
|
---|
| 417 | <<"#define KeepObj(obj) Keep_Object(obj, #obj)"<<endl
|
---|
| 418 | <<"#define GetOMVar(var) Get_ObjMgrVar( #var )"<<endl
|
---|
| 419 | <<"#define SetOMVar(var) Set_ObjMgrVar(var, #var )"<<endl
|
---|
[1224] | 420 | <<endl;
|
---|
| 421 |
|
---|
[2287] | 422 | os<<"//---- Macro Displaying objects and command execution"<<endl;
|
---|
[1319] | 423 | os<<"#define DisplayObj(obj, att) Display_Object(obj, att, #obj); \n" << endl;
|
---|
| 424 | os<<"#define ExecuteCommand(cmd) srvo.ExecuteCommand(cmd); \n" << endl;
|
---|
| 425 |
|
---|
[1224] | 426 | return;
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | /* --Methode-- */
|
---|
| 430 | void CxxExecutor::PutIncludeUser(ofstream& os)
|
---|
| 431 | {
|
---|
| 432 | if(mIncList.size()<1) return;
|
---|
| 433 | for(uint_4 i=0;i<mIncList.size();i++)
|
---|
| 434 | os<<"#include \""<<mIncList[i]<<"\""<<endl;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | /* --Methode-- */
|
---|
| 438 | void CxxExecutor::PutObject(ofstream& os)
|
---|
| 439 | {
|
---|
| 440 | NamedObjMgr omg;
|
---|
| 441 | NObjMgrAdapter* objmgrad;
|
---|
| 442 | vector<string> objlist;
|
---|
| 443 | string patt = "*";
|
---|
| 444 | omg.GetObjList(patt,objlist);
|
---|
| 445 | int nobjs = objlist.size();
|
---|
| 446 |
|
---|
| 447 | os<<"//-------------- Object List --------------"<<endl;
|
---|
| 448 | os<<"//Number of objects = "<<nobjs<<endl;
|
---|
| 449 | os<<"string ___nomobj;"<<endl<<endl;
|
---|
| 450 | if(nobjs<=0) return;
|
---|
| 451 |
|
---|
| 452 | string dir,nobj,stmp,obtype;
|
---|
| 453 | for(int i=0;i<nobjs;i++) {
|
---|
| 454 | objmgrad = omg.GetObjAdapter(objlist[i]);
|
---|
| 455 | omg.ParseObjectName(objlist[i],dir,nobj);
|
---|
| 456 | obtype = objmgrad->GetDataObjType();
|
---|
| 457 | stmp = "___" + nobj;
|
---|
| 458 |
|
---|
| 459 | os<<"___nomobj = \""<<nobj<<"\";"<<endl;
|
---|
| 460 | os<<obtype<<"* "<<stmp
|
---|
| 461 | <<" = dynamic_cast< "<<obtype<<" * >(omg.GetObj(___nomobj));"<<endl;
|
---|
[1450] | 462 | #ifdef SANS_EVOLPLANCK
|
---|
| 463 | os<<"if("<<stmp<<"==NULL) { \n"
|
---|
[2182] | 464 | <<" long mExcErr = nullPtrErr; \n"
|
---|
[1450] | 465 | <<" cerr << \"CxxExecutor::PutObject: Non existing object "
|
---|
| 466 | <<" ... please update file \\n \" ;"
|
---|
[2181] | 467 | <<" throw mExcErr ; \n } "<<endl;
|
---|
[1450] | 468 | #else
|
---|
[1224] | 469 | os<<"if("<<stmp<<"==NULL) throw NullPtrError"
|
---|
| 470 | <<"(\"CxxExecutor::PutObject: Non existing object "<<nobj
|
---|
| 471 | <<"... please update file\");"<<endl;
|
---|
[1450] | 472 | #endif
|
---|
[1224] | 473 | os<<obtype<<"& "<<nobj<<" = (*"<<stmp<<");"<<endl<<endl;
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | return;
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | /* --Methode-- */
|
---|
| 480 | void CxxExecutor::PutVar(ofstream& os)
|
---|
| 481 | {
|
---|
| 482 | os<<"//-------------- Variable List --------------"<<endl;
|
---|
| 483 | NamedObjMgr omg;
|
---|
| 484 | DVList& varlist = omg.GetVarList();
|
---|
| 485 | // varlist.Show(); varlist.Print();
|
---|
| 486 | DVList::ValList::const_iterator it;
|
---|
| 487 | for(it=varlist.Begin(); it!=varlist.End(); it++) {
|
---|
| 488 | string key = (*it).first;
|
---|
[1262] | 489 | if (isalpha(key[0]) ) {
|
---|
| 490 | os<<"___nomobj = \""<<key<<"\";"<<endl;
|
---|
| 491 | os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
|
---|
| 492 | }
|
---|
[1224] | 493 | }
|
---|
| 494 |
|
---|
[1237] | 495 | return;
|
---|
[1224] | 496 | }
|
---|
| 497 |
|
---|
| 498 | /* --Methode-- */
|
---|
[1268] | 499 | int CxxExecutor::FillUserCode(string& usercode,uint_4 first)
|
---|
[1287] | 500 | // User code is read from input.
|
---|
[1268] | 501 | // - first is the first position in the "string" where the code starts
|
---|
[1287] | 502 | // - Code is put into file "TmpDir/cxx_spiapp.h".
|
---|
[1224] | 503 | {
|
---|
[1237] | 504 | mUserCodeFn = "";
|
---|
[1268] | 505 |
|
---|
| 506 | // get the string part which is after word "first"
|
---|
| 507 | string code = usercode;
|
---|
| 508 | if(code.size()<=0) {cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
|
---|
| 509 | return 1;}
|
---|
| 510 | size_t q;
|
---|
| 511 | for(uint_4 i=0;i<=first;i++) {
|
---|
| 512 | q = code.find_first_not_of(" \t");
|
---|
| 513 | if(q>=code.size()) {code=""; break;}
|
---|
| 514 | code = code.substr(q);
|
---|
| 515 | if(i==first) break;
|
---|
| 516 | q = code.find_first_of(" \t");
|
---|
| 517 | if(q>=code.size()) {code=""; break;}
|
---|
| 518 | code = code.substr(q);
|
---|
| 519 | }
|
---|
| 520 | if(code.size()<=0)
|
---|
| 521 | {cout<<"CxxExecutor::FillUserCode: no user code after "<<first<<endl;
|
---|
| 522 | return 1;}
|
---|
| 523 |
|
---|
| 524 | // Fill the file with user code
|
---|
[2181] | 525 | mUserCodeFn = TmpDir() + mDefRoot + ".h";
|
---|
[1237] | 526 | ofstream os(mUserCodeFn.c_str(),ios::out);
|
---|
| 527 | if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
|
---|
| 528 | <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;}
|
---|
[1269] | 529 | os<<code<<endl;
|
---|
[1289] | 530 | if(mPrtLevel>1)
|
---|
[1269] | 531 | cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
|
---|
[1224] | 532 | return 0;
|
---|
| 533 | }
|
---|
| 534 |
|
---|
| 535 | /* --Methode-- */
|
---|
[1287] | 536 | int CxxExecutor::FillUserFctFrS(string userfctcode)
|
---|
[1269] | 537 | // - Fill user Fonction code from string "userfct"
|
---|
[1287] | 538 | // - Code is put into file "TmpDir/cxx_spiapp_fct.h".
|
---|
[1224] | 539 | {
|
---|
[1269] | 540 | mUserFctFn = "";
|
---|
[1287] | 541 | if(userfctcode.size()<1) return 0;
|
---|
[2181] | 542 | mUserFctFn = TmpDir() + mDefRoot + "_fct.h";
|
---|
[1269] | 543 | ofstream os(mUserFctFn.c_str(),ios::out);
|
---|
| 544 | if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
|
---|
| 545 | <<mUserFctFn<<endl; mUserFctFn = ""; return 1;}
|
---|
[1287] | 546 | os<<userfctcode<<endl;
|
---|
[1289] | 547 | if(mPrtLevel>1)
|
---|
[1269] | 548 | cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl;
|
---|
| 549 | return 0;
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | /* --Methode-- */
|
---|
| 553 | int CxxExecutor::FillUserCode(string filename)
|
---|
| 554 | // User code is read from "filename".
|
---|
| 555 | {
|
---|
[1237] | 556 | mUserCodeFn = filename;
|
---|
[1289] | 557 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
---|
[1269] | 558 | cout<<"User code filled from file "<<mUserCodeFn<<endl;
|
---|
[1224] | 559 | return 0;
|
---|
| 560 | }
|
---|
| 561 |
|
---|
| 562 | /* --Methode-- */
|
---|
[1270] | 563 | int CxxExecutor::FillUserFctFrF(string filefctname)
|
---|
[1287] | 564 | // User function code is read from "filefctname".
|
---|
[1269] | 565 | {
|
---|
| 566 | mUserFctFn = filefctname;
|
---|
[1289] | 567 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
---|
[1269] | 568 | cout<<"User Function code filled from file "<<mUserFctFn<<endl;
|
---|
| 569 | return 0;
|
---|
| 570 | }
|
---|
| 571 |
|
---|
| 572 | /* --Methode-- */
|
---|
[1224] | 573 | int CxxExecutor::Compile(string rootfilename)
|
---|
[1287] | 574 | //--------------------------------------------------------//
|
---|
| 575 | // rootfilename = | name | "" ou (default) //
|
---|
| 576 | //--------------------------------------------------------//
|
---|
| 577 | // fichier .cc | name.cc | TmpDir/cxx_spiapp.cc //
|
---|
| 578 | // | ../dir/name.cc | //
|
---|
| 579 | // fichier .o | TmpDir/name.o | TmpDir/cxx_spiapp.o //
|
---|
| 580 | // fichier .so | TmpDir/name.so | TmpDir/cxx_spiapp.so //
|
---|
| 581 | //--------------------------------------------------------//
|
---|
[1224] | 582 | {
|
---|
[2181] | 583 | if(rootfilename.size()<1) rootfilename = TmpDir() + mDefRoot;
|
---|
[1289] | 584 | if(mPrtLevel>1) cout<<"Compile "<<rootfilename<<endl;
|
---|
[1287] | 585 |
|
---|
| 586 | int rc;
|
---|
[2123] | 587 | #ifdef SANS_EVOLPLANCK
|
---|
[1287] | 588 | CxxCompilerLinker cxx;
|
---|
[2123] | 589 | string sophlib = " -lPIE -lm ";
|
---|
| 590 | cxx.AddLinkOptions(sophlib);
|
---|
| 591 | #else
|
---|
| 592 | CxxCompilerLinker cxx(true,true,true);
|
---|
| 593 | #endif
|
---|
[2181] | 594 | if(TmpDir().size()>0) cxx.SetTmpDir(TmpDir());
|
---|
[1289] | 595 | if(mPrtLevel>0) cxx.SetVerbose(true);
|
---|
| 596 | else cxx.SetVerbose(false);
|
---|
[1287] | 597 |
|
---|
| 598 | // Compilation
|
---|
| 599 | string fcc = rootfilename + ".cc";
|
---|
| 600 | string fo = "";
|
---|
| 601 | cxx.AddCompileOptions(mCompOpt);
|
---|
| 602 | rc = cxx.Compile(fcc,fo);
|
---|
[1289] | 603 | if(mPrtLevel>1) cout << "Compilation rc = "<<rc<< endl;
|
---|
[1287] | 604 | if(rc) return 1;
|
---|
| 605 |
|
---|
| 606 | // Fabrication Shared Lib.
|
---|
| 607 | string fso = "";
|
---|
| 608 | cxx.AddLinkOptions(mLinkOpt);
|
---|
| 609 | cxx.AddLinkOptions(mMyLibs);
|
---|
| 610 | rc = cxx.BuildSO(fo,fso);
|
---|
[1289] | 611 | if(mPrtLevel>1) cout << "Shared Library rc = "<<rc<< endl;
|
---|
[1287] | 612 | if(rc) return 2;
|
---|
| 613 |
|
---|
[1224] | 614 | return 0;
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | /* --Methode-- */
|
---|
[1287] | 618 | //int CxxExecutor::Compile(string rootfilename)
|
---|
| 619 | // Ne marche pas si TmpDir != ""
|
---|
| 620 | //{
|
---|
| 621 | //if(rootfilename.size()<1) rootfilename = mDefRoot;
|
---|
[1289] | 622 | //if(mPrtLevel>1) cout<<"Compile: "<<rootfilename<<endl;
|
---|
[1287] | 623 | //int rc = 0;
|
---|
| 624 | //rc = CrMakefile();
|
---|
| 625 | //if(rc) return(1);
|
---|
| 626 | //string make = "";
|
---|
| 627 | //make += "make -f " + mDefRoot + "_Makefile";
|
---|
| 628 | //make += " CXXFLAGS=\"" + mCompOpt + "\"";
|
---|
| 629 | //make += " LDFLAGS=\"" + mLinkOpt + "\"";
|
---|
| 630 | //make += " MYLIBS=\"" + mMyLibs + "\"";
|
---|
| 631 | //make += " " + rootfilename;
|
---|
| 632 | //rc = system(make.c_str());
|
---|
| 633 | //if(rc)
|
---|
| 634 | // {cout<<"CxxExecutor::Compile : \n"<<make<<" Failed"<<endl;
|
---|
| 635 | // return 1000+rc;}
|
---|
| 636 | //return 0;
|
---|
| 637 | //}
|
---|
| 638 |
|
---|
| 639 | /* --Methode-- */
|
---|
| 640 | //int CxxExecutor::CrMakefile(void)
|
---|
| 641 | // Ne marche pas si TmpDir != ""
|
---|
| 642 | //{
|
---|
[2181] | 643 | //string makename = TmpDir() + mDefRoot + "_Makefile";
|
---|
[1287] | 644 | //ofstream os(makename.c_str(),ios::out);
|
---|
| 645 | //if(!os)
|
---|
| 646 | // {cout<<"CxxExecutor::CrMakefile: unable to open file for Makefile"<<endl;
|
---|
| 647 | // return 1;}
|
---|
[1224] | 648 | //---------------------------------------------------------------------
|
---|
[1287] | 649 | //os<<"MODULEDECCXXFLAGS := -msg_quiet"<<endl;
|
---|
[2437] | 650 | //os<<"include $(SOPHYABASEREP)/Include/MakefileUser.h"<<endl;
|
---|
[1287] | 651 | //os<<"MYLIBS ="<<endl;
|
---|
| 652 | //os<<"LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm"<<endl;
|
---|
| 653 | //os<<"ifeq ($(MACHEROS),OSF1)"<<endl;
|
---|
| 654 | //os<<"LIBS := $(LIBS) -lfor"<<endl;
|
---|
| 655 | //os<<"endif"<<endl;
|
---|
| 656 | //os<<"ifeq ($(MACHEROS),Linux)"<<endl;
|
---|
[1473] | 657 | //os<<"#LIBS := $(LIBS) -ldl -lf2c"<<endl;
|
---|
| 658 | //os<<"LIBS := $(LIBS) -ldl -lg2c"<<endl;
|
---|
[1287] | 659 | //os<<"endif"<<endl;
|
---|
| 660 | //os<<"%.so:%.o"<<endl;
|
---|
| 661 | //os<<"%:%.cc"<<endl;
|
---|
| 662 | //os<<"%:%.o"<<endl;
|
---|
| 663 | //os<<"%.o:%.cc"<<endl;
|
---|
| 664 | //os<<"%.o:%.c"<<endl;
|
---|
| 665 | //os<<"%:%.c"<<endl;
|
---|
| 666 | //os<<endl;
|
---|
| 667 | //os<<".PRECIOUS: %.so"<<endl;
|
---|
| 668 | //os<<endl;
|
---|
| 669 | //os<<"%:%.so"<<endl;
|
---|
| 670 | //os<<"\t"<<"echo $@ \" made (.so) \""<<endl;
|
---|
| 671 | //os<<"%.so:%.o"<<endl;
|
---|
| 672 | //os<<"\t"<<"$(LINK.cc) -shared -o $@ $< $(LIBS) $(MYLIBS)"<<endl;
|
---|
| 673 | //os<<"%.o:%.cc"<<endl;
|
---|
| 674 | //os<<"\t"<<"$(COMPILE.cc) -o $@ $<"<<endl;
|
---|
| 675 | //os<<"%.o:%.c"<<endl;
|
---|
| 676 | //os<<"\t"<<"$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $<"<<endl;
|
---|
[1224] | 677 | //---------------------------------------------------------------------
|
---|
[1287] | 678 | //return 0;
|
---|
| 679 | //}
|
---|
[1224] | 680 |
|
---|
| 681 | /* --Methode-- */
|
---|
| 682 | int CxxExecutor::Link(string libname,string func)
|
---|
| 683 | {
|
---|
[2181] | 684 | if(libname.size()<1) libname = TmpDir() + mDefRoot + ".so";
|
---|
| 685 | else libname = TmpDir() + libname;
|
---|
[1268] | 686 | if(func.size()<1) func = mDefFunc;
|
---|
| 687 |
|
---|
[1224] | 688 | NamedObjMgr omg;
|
---|
| 689 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
---|
[1287] | 690 |
|
---|
[1276] | 691 | string key("linkff2");
|
---|
[1224] | 692 | vector<string> arg; arg.push_back(libname); arg.push_back(func);
|
---|
[1268] | 693 | string toks = libname + " " + func;
|
---|
| 694 | int rc = mpiac->ExecuteCommand(key,arg,toks);
|
---|
[1289] | 695 | if(mPrtLevel>1) cout<<"Link from "<<libname<<" for function "<<func
|
---|
[1287] | 696 | <<" (rc="<<rc<<")"<<endl;
|
---|
[1224] | 697 | return 0;
|
---|
| 698 | }
|
---|
| 699 |
|
---|
| 700 | /* --Methode-- */
|
---|
| 701 | int CxxExecutor::Call(string func)
|
---|
| 702 | {
|
---|
[1268] | 703 | if(func.size()<1) func = mDefFunc;
|
---|
| 704 |
|
---|
[1224] | 705 | NamedObjMgr omg;
|
---|
| 706 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
---|
[1287] | 707 |
|
---|
[1224] | 708 | string key("call");
|
---|
| 709 | vector<string> arg; arg.push_back(func);
|
---|
[1268] | 710 | string toks = func;
|
---|
[1224] | 711 | if(mCallArgs.size()>0)
|
---|
[1237] | 712 | for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
|
---|
[1268] | 713 | mpiac->ExecuteCommand(key,arg,toks);
|
---|
[1224] | 714 | return 0;
|
---|
| 715 | }
|
---|
| 716 |
|
---|
[1230] | 717 | /* --Methode-- */
|
---|
| 718 | void CxxExecutor::FillArgs(vector<string>& args)
|
---|
| 719 | {
|
---|
| 720 | mCallArgs.resize(0);
|
---|
| 721 | if(args.size()<1) return;
|
---|
| 722 | for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]);
|
---|
| 723 | }
|
---|
| 724 |
|
---|
| 725 | void CxxExecutor::FillArgs(string& args)
|
---|
| 726 | {
|
---|
| 727 | mCallArgs.resize(0);
|
---|
| 728 | FillVStringFrString(args,mCallArgs,' ');
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | string CxxExecutor::GetArgs(void)
|
---|
| 732 | {
|
---|
| 733 | string dum = "";
|
---|
| 734 | if(mCallArgs.size()<1) return dum;
|
---|
| 735 | for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " ";
|
---|
| 736 | return dum;
|
---|
| 737 | }
|
---|
| 738 |
|
---|
| 739 | /* --Methode-- */
|
---|
| 740 | void CxxExecutor::FillInclude(vector<string>& inc)
|
---|
| 741 | {
|
---|
| 742 | mIncList.resize(0);
|
---|
| 743 | if(inc.size()<1) return;
|
---|
| 744 | for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]);
|
---|
| 745 | }
|
---|
| 746 |
|
---|
| 747 | void CxxExecutor::FillInclude(string& inc)
|
---|
| 748 | {
|
---|
| 749 | mIncList.resize(0);
|
---|
| 750 | FillVStringFrString(inc,mIncList,' ');
|
---|
| 751 | }
|
---|
| 752 |
|
---|
| 753 | string CxxExecutor::GetInclude(void)
|
---|
| 754 | {
|
---|
| 755 | string dum = "";
|
---|
| 756 | if(mIncList.size()<1) return dum;
|
---|
| 757 | for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " ";
|
---|
| 758 | return dum;
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | /* --Methode-- */
|
---|
| 762 | void CxxExecutor::FillCompileOpt(vector<string>& copt)
|
---|
| 763 | {
|
---|
| 764 | mCompOpt = "";
|
---|
| 765 | if(copt.size()<1) return;
|
---|
| 766 | for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " ";
|
---|
| 767 | }
|
---|
| 768 |
|
---|
| 769 | void CxxExecutor::FillCompileOpt(string& copt)
|
---|
| 770 | {
|
---|
| 771 | mCompOpt = copt;
|
---|
| 772 | }
|
---|
| 773 |
|
---|
| 774 | string CxxExecutor::GetCompileOpt(void)
|
---|
| 775 | {
|
---|
| 776 | return mCompOpt;
|
---|
| 777 | }
|
---|
| 778 |
|
---|
| 779 | /* --Methode-- */
|
---|
| 780 | void CxxExecutor::FillLinkOpt(vector<string>& lopt)
|
---|
| 781 | {
|
---|
| 782 | mLinkOpt = "";
|
---|
| 783 | if(lopt.size()<1) return;
|
---|
| 784 | for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " ";
|
---|
| 785 | }
|
---|
| 786 |
|
---|
| 787 | void CxxExecutor::FillLinkOpt(string& lopt)
|
---|
| 788 | {
|
---|
| 789 | mLinkOpt = lopt;
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | string CxxExecutor::GetLinkOpt(void)
|
---|
| 793 | {
|
---|
| 794 | return mLinkOpt;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | /* --Methode-- */
|
---|
| 798 | void CxxExecutor::FillLinkLibs(vector<string>& llibs)
|
---|
| 799 | {
|
---|
| 800 | mMyLibs = "";
|
---|
| 801 | if(llibs.size()<1) return;
|
---|
| 802 | for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " ";
|
---|
| 803 | }
|
---|
| 804 |
|
---|
| 805 | void CxxExecutor::FillLinkLibs(string& llibs)
|
---|
| 806 | {
|
---|
| 807 | mMyLibs = llibs;
|
---|
| 808 | }
|
---|
| 809 |
|
---|
| 810 | string CxxExecutor::GetLinkLibs(void)
|
---|
| 811 | {
|
---|
| 812 | return mMyLibs;
|
---|
| 813 | }
|
---|
[1297] | 814 |
|
---|
| 815 | /* --Methode-- */
|
---|
| 816 | void CxxExecutor::FillModuleImport(vector<string>& import)
|
---|
| 817 | {
|
---|
| 818 | mModuleImportList.resize(0);
|
---|
| 819 | mIncImportList.resize(0);
|
---|
| 820 | if(import.size()<1) return;
|
---|
| 821 |
|
---|
| 822 | if(import[0]=="all" || import[0]=="All" || import[0]=="ALL") {
|
---|
| 823 | mModuleImportList = mModuleImportDefaultList;
|
---|
| 824 | } else {
|
---|
| 825 | for(uint_4 i=0;i<import.size();i++) mModuleImportList.push_back(import[i]);
|
---|
| 826 | }
|
---|
| 827 |
|
---|
| 828 | // Set additionnal Includes
|
---|
| 829 | if(mModuleImportList.size()>0)
|
---|
| 830 | for(uint_4 i=0;i<mModuleImportList.size();i++) {
|
---|
[1646] | 831 | if( mModuleImportList[i]=="FitsIOServer")
|
---|
| 832 | mIncImportList.push_back("fitsioserver.h");
|
---|
| 833 | else if(mModuleImportList[i]=="IFFTW")
|
---|
| 834 | mIncImportList.push_back("fftwserver.h");
|
---|
| 835 | else if(mModuleImportList[i]=="LinAlg")
|
---|
| 836 | mIncImportList.push_back("intflapack.h");
|
---|
| 837 | else if( mModuleImportList[i]=="Samba")
|
---|
| 838 | {mIncImportList.push_back("skymap.h"); mIncImportList.push_back("samba.h");}
|
---|
| 839 | else if(mModuleImportList[i]=="SkyMap")
|
---|
[1617] | 840 | mIncImportList.push_back("skymap.h");
|
---|
[1646] | 841 | else if(mModuleImportList[i]=="SkyT")
|
---|
| 842 | mIncImportList.push_back("skyt.h");
|
---|
| 843 | else if(mModuleImportList[i]=="XAstroPack")
|
---|
| 844 | mIncImportList.push_back("xastropack.h");
|
---|
[1297] | 845 | }
|
---|
| 846 |
|
---|
| 847 | return;
|
---|
| 848 | }
|
---|
| 849 |
|
---|
| 850 | void CxxExecutor::FillModuleImport(string& import)
|
---|
| 851 | {
|
---|
| 852 | mModuleImportList.resize(0);
|
---|
| 853 | vector<string> vsimport;
|
---|
| 854 | FillVStringFrString(import,vsimport,' ');
|
---|
| 855 | FillModuleImport(vsimport);
|
---|
| 856 | }
|
---|
| 857 |
|
---|
| 858 | string CxxExecutor::GetModuleImport(void)
|
---|
| 859 | {
|
---|
| 860 | string dum = "";
|
---|
| 861 | if(mModuleImportList.size()<1) return dum;
|
---|
| 862 | for(uint_4 i=0;i<mModuleImportList.size();i++) dum += mModuleImportList[i] + " ";
|
---|
| 863 | return dum;
|
---|
| 864 | }
|
---|