~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to Ag++/ACCompiler.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:
29
29
 
30
30
//Puma includes 
31
31
#include "Puma/VerboseMgr.h"
 
32
#include "Puma/SysCall.h"
32
33
 
33
34
 
34
35
bool ACCompiler::execute(){
35
 
                
36
 
        VerboseMgr vm(cout,_config.verbose());
37
 
        vm << "Weaving" << endvm;
38
 
        
39
 
        // command line string
40
 
        string exec_str= "\""+_config.acc_bin()+"\" --config \""+_config.puma_config()+"\" "+
41
 
        _config.optvec().getString(OptionItem::OPT_ACC);
42
 
 
43
 
        // get output path for .acc files from -o option
44
 
        string acc_output_path=_config.output_file();
45
 
        file::stripFilename(acc_output_path);
46
 
        
47
 
        // process each file separetly
48
 
        OptionVec::iterator opt = _config.optvec().begin();
49
 
        while(opt != _config.optvec().end()){
50
 
                
51
 
                if( (opt->flag() & OptionItem::OPT_FILE_ACC) != OptionItem::OPT_FILE_ACC){
52
 
                        opt++;  
53
 
                        continue;
54
 
                }
55
 
                
56
 
                const string file = opt->name();
57
 
                
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() ){
63
 
                
64
 
                        //out_file=*file;
65
 
                        stripPath(out_file);
66
 
                        
67
 
                        int endpos =out_file.rfind('.') ;
68
 
                        out_file.replace(endpos,string::npos,".acc");
69
 
                        out_file = acc_output_path  + out_file;
70
 
                        
71
 
                }else{
72
 
                        out_file=_config.output_file();
73
 
                }
74
 
                        
75
 
 
76
 
                // construct final command string
77
 
                string local_exec_str = exec_str+" -c \""+file+"\" -o \""+out_file+"\"";
78
 
                
79
 
                // execute AspectC++
80
 
                System acc(_err,_config,local_exec_str);
81
 
                if(! acc.execute() ){
82
 
                        return false;
83
 
                }
84
 
                
85
 
                //change filename in input_file list, so that the next steps 
86
 
                //get the proper filename
87
 
                opt->name(out_file);
88
 
                opt->flag(opt->flag()|OptionItem::OPT_FILE_GCC);
89
 
                
90
 
                //AGxxConfig::FileCont::iterator tmp=file;
91
 
                opt++;  
92
 
        }
93
 
 
94
 
        
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);
98
 
                return acc.execute();
99
 
        }
100
 
        
101
 
 
102
 
        return true;
 
36
 
 
37
   VerboseMgr vm(cout,_config.verbose());
 
38
   vm << "Weaving" << endvm;
 
39
 
 
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);
 
43
 
 
44
   // get output path for .acc files from -o option
 
45
   string acc_output_path=_config.output_file();
 
46
   file::stripFilename(acc_output_path);
 
47
 
 
48
   // loop through all options searching a file
 
49
   OptionVec::iterator opt = _config.optvec().begin();
 
50
   while(opt != _config.optvec().end())
 
51
   {
 
52
      // skip all options that are not a file which should be processed by
 
53
      // AspectC++
 
54
      if( ( opt->flag() & ( OptionItem::OPT_ACC | OptionItem::OPT_FILE )) != 
 
55
            ( OptionItem::OPT_ACC | OptionItem::OPT_FILE )
 
56
        )
 
57
      {
 
58
         opt++; 
 
59
         continue;
 
60
      }
 
61
 
 
62
      const string file = opt->name();
 
63
 
 
64
      //construct name for output file
 
65
      string out_file;
 
66
 
 
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 
 
69
      // in acc_output_path 
 
70
      if( _config.compile() == true || _config.output_file().empty() )
 
71
      {
 
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)
 
75
         {
 
76
            string prefix(file);
 
77
            stripPath(prefix);
 
78
            prefix.append("_agxx_");
 
79
            char* tmp_file= (char*) Puma::SysCall::mktemp(prefix.c_str(),&_err);
 
80
            out_file=tmp_file;
 
81
            free(tmp_file);
 
82
         }
 
83
         //otherwise create name of output file from name of output file
 
84
         else
 
85
         {
 
86
            string tmp(file);
 
87
            stripPath(tmp);
 
88
            out_file=tmp;
 
89
            int endpos =out_file.rfind('.') ;
 
90
            out_file.replace(endpos,string::npos,".acc");
 
91
            out_file = acc_output_path  + out_file;
 
92
         }
 
93
      }
 
94
      else
 
95
      {
 
96
         out_file=_config.output_file();
 
97
      }
 
98
 
 
99
 
 
100
      // construct final command string
 
101
      string local_exec_str = exec_str+" -c \""+file+"\" -o \""+out_file+"\"";
 
102
 
 
103
      // execute AspectC++
 
104
      System acc(_err,_config,local_exec_str);
 
105
      if(! acc.execute() ){
 
106
         return false;
 
107
      }
 
108
 
 
109
      //change filename in input_file list, so that the next steps 
 
110
      //get the proper filename
 
111
      opt->name(out_file);
 
112
      opt->flag(opt->flag() | (OptionItem::OPT_GCC) );
 
113
 
 
114
      //AGxxConfig::FileCont::iterator tmp=file;
 
115
      opt++;    
 
116
   }
 
117
 
 
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();
 
122
   }
 
123
 
 
124
   return true;
103
125
}