32
32
#include "Puma/VerboseMgr.h"
33
#include "Puma/SysCall.h"
35
36
bool PumaConfigFile::searchFile(){
36
37
// IF the location of the puma config file is given by an command line argument
38
if(! _config.puma_config().empty() ){
39
if(fileExists(_config.puma_config().c_str())){
39
if( _config.pumaconfig_file().empty() == false)
41
if(fileExists(_config.pumaconfig_file().c_str()))
46
// set filename in configuration to local 'puma.config'
48
// IF '--gen_config' and '-o' options are present write puma configration
49
// into file specified by the argument of '-o'
50
// ELSE write it to a file named "puma.config"
51
if(! ( _config.output_file().empty() || _config.weave() )){
52
_config.puma_config(_config.output_file());
54
_config.puma_config("puma.config");
52
// set filename of puma configuration file
54
if(_config.pumaconfig_tmp() == true)
56
//create temporary file
57
_config.pumaconfig_file(Puma::SysCall::mktemp("agxx_pcfg",&_err));
61
(_config.output_file().empty() == false) &&
62
(_config.nr_files() == 0)
65
// name of puma configuration file is specified using '-o' option
66
_config.pumaconfig_file(_config.output_file());
70
// default name for puma configuration
71
_config.pumaconfig_file("puma.config");
100
117
// check if a sepcial command for generating the out is available
101
118
if(config_command_str.empty()){
102
119
//Construct execution string for C++ Compiler
103
config_command_str = "\""+_config.cc_bin()+"\" " + _config.optvec().getString(OptionItem::OPT_GCC)+" -E -dM -v -x c++ \""+empty_file_name+"\"";
120
config_command_str = "\""+_config.cc_bin()+"\" " +
121
_config.optvec().getString((OptionItem::OPT_GCC|OptionItem::OPT_CONFIG))+
122
" -E -dM -v -x c++ \""+empty_file_name+"\"";
106
125
// get c compiler output
167
186
string::size_type strpos=line.find(" ");
168
187
string option=line.substr(0,strpos);
170
// set '1' as default argument if no argument is defined
189
// set empty string as default argument if no argument is defined
173
192
// find value => find a string behind the option name
174
193
if( ( strpos != string::npos ) &&
192
211
// include paths need specail treatment in a cygwin environment
193
212
bool is_cygwin=false;
195
ofstream puma_file(_config.puma_config().c_str());
214
ofstream puma_file(_config.pumaconfig_file().c_str());
198
_err << sev_error << "Could not open " << _config.puma_config().c_str() << endMessage;
217
_err << sev_error << "Could not open " << _config.pumaconfig_file().c_str() << endMessage;
207
226
for(map<string,string>::iterator opt=_def_options.begin();opt != _def_options.end();opt++){
209
228
// print line '-D <optionname> = <value>' in puma.config
210
puma_file << "-D " <<opt->first;
211
// if vlaue == 1 omit '= <value>' part of the line
212
if(! (opt->second == "1")){
213
puma_file<< "=" <<opt->second;
229
puma_file << "-D \"" <<opt->first;
230
if( opt->second != ""){
231
puma_file<< "=" << _config.str_replace_all(opt->second,"\"","\\\"");
233
puma_file << "\""<<endl;
217
235
// Check gcc version
218
236
if(opt->first == "__GNUC__"){
272
290
istringstream iss(cygpath.stdout_str());
274
292
while ( getline(iss,line)){
275
puma_file << "-I " << line <<endl;
293
puma_file << "-I \"" << line << "\"" <<endl;