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