31
31
#include "Puma/VerboseMgr.h"
32
#include "Puma/SysCall.h"
34
35
bool ACCompiler::execute(){
36
VerboseMgr vm(cout,_config.verbose());
37
vm << "Weaving" << endvm;
39
// command line string
40
string exec_str= "\""+_config.acc_bin()+"\" --config \""+_config.puma_config()+"\" "+
41
_config.optvec().getString(OptionItem::OPT_ACC);
43
// get output path for .acc files from -o option
44
string acc_output_path=_config.output_file();
45
file::stripFilename(acc_output_path);
47
// process each file separetly
48
OptionVec::iterator opt = _config.optvec().begin();
49
while(opt != _config.optvec().end()){
51
if( (opt->flag() & OptionItem::OPT_FILE_ACC) != OptionItem::OPT_FILE_ACC){
56
const string file = opt->name();
58
//construct name for intermediate output file
59
string out_file(file);
60
// if we want to weave more than one file or want to compile a file
61
// after weaving put intermediate .acc file in acc_output_path
62
if( _config.output_file().empty() || _config.compile() ){
67
int endpos =out_file.rfind('.') ;
68
out_file.replace(endpos,string::npos,".acc");
69
out_file = acc_output_path + out_file;
72
out_file=_config.output_file();
76
// construct final command string
77
string local_exec_str = exec_str+" -c \""+file+"\" -o \""+out_file+"\"";
80
System acc(_err,_config,local_exec_str);
85
//change filename in input_file list, so that the next steps
86
//get the proper filename
88
opt->flag(opt->flag()|OptionItem::OPT_FILE_GCC);
90
//AGxxConfig::FileCont::iterator tmp=file;
95
if (_config.gen_includes()){
96
string local_exec_str = exec_str+" -i -d \""+_config.dest_path()+"\"";
97
System acc(_err,_config,local_exec_str);
37
VerboseMgr vm(cout,_config.verbose());
38
vm << "Weaving" << endvm;
40
// command line string
41
string exec_str= "\""+_config.acc_bin()+"\" --config \""+_config.pumaconfig_file()+"\" "+
42
_config.optvec().getString(OptionItem::OPT_ACC,OptionItem::OPT_FILE);
44
// get output path for .acc files from -o option
45
string acc_output_path=_config.output_file();
46
file::stripFilename(acc_output_path);
48
// loop through all options searching a file
49
OptionVec::iterator opt = _config.optvec().begin();
50
while(opt != _config.optvec().end())
52
// skip all options that are not a file which should be processed by
54
if( ( opt->flag() & ( OptionItem::OPT_ACC | OptionItem::OPT_FILE )) !=
55
( OptionItem::OPT_ACC | OptionItem::OPT_FILE )
62
const string file = opt->name();
64
//construct name for output file
67
// if an output file for the woven result is not specified on command line
68
// or the file(s) shall be compiled after weaving put an intermediate .acc file
70
if( _config.compile() == true || _config.output_file().empty() )
72
//if we do not want to keep the intermediate acc files
73
//generate files in the systems temporary directory
74
if(_config.keep_woven() == false)
78
prefix.append("_agxx_");
79
char* tmp_file= (char*) Puma::SysCall::mktemp(prefix.c_str(),&_err);
83
//otherwise create name of output file from name of output file
89
int endpos =out_file.rfind('.') ;
90
out_file.replace(endpos,string::npos,".acc");
91
out_file = acc_output_path + out_file;
96
out_file=_config.output_file();
100
// construct final command string
101
string local_exec_str = exec_str+" -c \""+file+"\" -o \""+out_file+"\"";
104
System acc(_err,_config,local_exec_str);
105
if(! acc.execute() ){
109
//change filename in input_file list, so that the next steps
110
//get the proper filename
112
opt->flag(opt->flag() | (OptionItem::OPT_GCC) );
114
//AGxxConfig::FileCont::iterator tmp=file;
118
if (_config.gen_includes()){
119
string local_exec_str = exec_str+" -i -d \""+_config.dest_path()+"\"";
120
System acc(_err,_config,local_exec_str);
121
return acc.execute();