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