source: Sophya/trunk/SophyaPI/PIext/cxxexecutor.cc@ 1291

Last change on this file since 1291 was 1291, checked in by ercodmgr, 25 years ago

pour compat Peida-Sophya Reza cmv 3/11/00

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