~ubuntu-branches/ubuntu/quantal/aspectc++/quantal

« back to all changes in this revision

Viewing changes to Ag++/PumaConfigFile.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
//Puma includes
32
32
#include "Puma/VerboseMgr.h"
 
33
#include "Puma/SysCall.h"
33
34
 
34
35
 
35
36
bool PumaConfigFile::searchFile(){
36
37
        // IF the location of the puma config file is given by an command line argument
37
38
        // check it exist
38
 
        if(! _config.puma_config().empty() ){
39
 
                if(fileExists(_config.puma_config().c_str())){
 
39
        if( _config.pumaconfig_file().empty() == false)
 
40
   {
 
41
                if(fileExists(_config.pumaconfig_file().c_str()))
 
42
      {
40
43
                        return true;
41
 
                }else{
 
44
                }
 
45
      else
 
46
      {
42
47
                        return false;
43
48
                }
44
49
        }
45
50
        
46
 
        // set filename in configuration to local 'puma.config'
47
 
        
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());
53
 
        }else{
54
 
                _config.puma_config("puma.config");
55
 
        }
 
51
        // 
 
52
   // set filename of puma configuration file
 
53
   //
 
54
   if(_config.pumaconfig_tmp() == true)
 
55
   {
 
56
      //create temporary file
 
57
      _config.pumaconfig_file(Puma::SysCall::mktemp("agxx_pcfg",&_err));
 
58
   }
 
59
   else if
 
60
      ( 
 
61
       (_config.output_file().empty() == false) && 
 
62
       (_config.nr_files() == 0)
 
63
      )
 
64
   {
 
65
      // name of puma configuration file is specified using '-o' option
 
66
      _config.pumaconfig_file(_config.output_file());
 
67
   }
 
68
   else
 
69
   {
 
70
      // default name for puma configuration
 
71
      _config.pumaconfig_file("puma.config");
 
72
   }
56
73
 
57
74
        return false;
58
75
}
74
91
        }
75
92
        
76
93
        // if parsing was successfull write puma config file
77
 
        vm << "Writing puma configuration file" <<endvm;
 
94
        vm << "Writing puma configuration file '" << _config.pumaconfig_file() <<"'"<<endvm;
78
95
        return writeFile();
79
96
}
80
97
 
84
101
bool PumaConfigFile::parseCcOutput(){
85
102
        
86
103
        #ifdef WIN32
87
 
        const char* empty_file_name=_config.puma_config().c_str();
 
104
        const char* empty_file_name=_config.pumaconfig_file().c_str();
88
105
        ofstream empty_file(empty_file_name);
89
106
        
90
107
        if(! empty_file){
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+"\"";
104
123
        }       
105
124
        
106
125
        // get c compiler output 
167
186
                        string::size_type strpos=line.find(" ");
168
187
                        string option=line.substr(0,strpos);
169
188
                        
170
 
                        // set '1' as default argument if no argument is defined
171
 
                        string value = "1";
 
189
                        // set empty string as default argument if no argument is defined
 
190
                        string value = "";
172
191
                        
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;
194
213
        
195
 
        ofstream puma_file(_config.puma_config().c_str());
 
214
        ofstream puma_file(_config.pumaconfig_file().c_str());
196
215
        
197
216
        if(! puma_file){
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;
199
218
                return false;
200
219
        }
201
220
        
207
226
        for(map<string,string>::iterator opt=_def_options.begin();opt != _def_options.end();opt++){
208
227
 
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,"\"","\\\"");
214
232
                }
215
 
                puma_file <<endl;
 
233
                puma_file << "\""<<endl;
216
234
 
217
235
                // Check gcc version
218
236
                if(opt->first == "__GNUC__"){
260
278
                if(is_cygwin){
261
279
                        cygpath_exec_str=cygpath_exec_str+" "+*file;
262
280
                }else{
263
 
                        puma_file << "-I " << *file <<endl;
 
281
                        puma_file << "-I \"" << *file << "\"" <<endl;
264
282
                }
265
283
        }
266
284
 
272
290
                istringstream iss(cygpath.stdout_str());
273
291
                string line;
274
292
                while ( getline(iss,line)){
275
 
                        puma_file << "-I " << line <<endl;
 
293
                        puma_file << "-I \"" << line << "\"" <<endl;
276
294
                }
277
295
        }
278
296