File: AGxxConfig.h

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20080711-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 104,504 kB
  • ctags: 363,975
  • sloc: cpp: 1,645,814; ansic: 16,601; sh: 2,175; makefile: 1,043
file content (233 lines) | stat: -rw-r--r-- 5,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// This file is part of the AspectC++ compiler 'ac++'.
// Copyright (C) 1999-2004  The 'ac++' developers (see aspectc.org)
//                                                                
// This program is free software;  you can redistribute it and/or 
// modify it under the terms of the GNU General Public License as 
// published by the Free Software Foundation; either version 2 of 
// the License, or (at your option) any later version.            
//                                                                
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
// GNU General Public License for more details.                   
//                                                                
// You should have received a copy of the GNU General Public      
// License along with this program; if not, write to the Free     
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
// MA  02111-1307  USA                                           


#ifndef __AGxxConfig_h__
#define __AGxxConfig_h__

#include "OptionVec.h"

// PUMA includes 
#include "Puma/OptsParser.h"
#include "Puma/ErrorStream.h"
using namespace Puma;

// stdc++ includes
#include <string>
#include <list>
using namespace std;


class AGxxConfig{

public:
	typedef list<string> FileCont;


private:
	
	
	// parse options
	bool parseOptions();
   
   // parse some special g++ options
	bool parseGccOpt(OptsParser&);
	
   // analyze options
	bool analyzeOptions();
	
	
	//print a usage message
  	void usage() const;
   
	

	ErrorStream &_err;
	int _argc;
	char** _argv; 

	// list of .ah files passed with -a option
	FileCont _ah_files;
	
	// path to project directory
	FileCont _proj_path;

	// output file name
	string _output_file;

	// name of puma config file
	string _pumaconfig_file;
	
	// path to aspectc++ compiler
	string _acc_bin;

	// path to c++ compiler
	string _cc_bin;

	// Option Vector
	OptionVec _optvec;

	// path to destination directory
	string _dest_path;
	
	// command, which is executed to get the information about 
	// compiler, include paths, defines.
	// default is: <compiler_name> <compiler options> -E -dM -v -x c++ /dev/null
	string _config_command;
	
	// number of files to be processed
	int _nr_files;
	
	// verbose
	int _verbose;


   // indicate wether a config file should be generated
	bool _gen_pumaconfig;
	
	// indicate wether weaving should be done
	bool _weave;
	
   // indicate wether linking should be done
	bool _link;
	
	// indicate wether compiling should be done
	bool _compile;
   
   
   
   // use temporary file for puma config file
	bool _pumaconfig_tmp;
   
   // do weave the source files (no compiling or linking)
	bool _weave_only;
	
	// generate include files
	bool _gen_incl;
	
   // if include files are generated
	bool _gen_includes;
   
   // do only compile not link (but weave)
	bool _compile_only;

	// indicate wether dependency information should be printed out
	bool _make_dep;
	
	// keep woven source code  files
	bool _keep_woven;
	
	// assign all following options to the compiler
	bool _x_compiler;
	
	// list of gcc options which need a argument
	static  string _gcc_option_arg[];
	
	
public:
	AGxxConfig(ErrorStream &e,int argc,char **argv):_err(e),_argc(argc),_argv(argv){}
	
	~AGxxConfig(){}
		
	enum {
		AGOPT_COMPILE_ONLY=1,AGOPT_WEAVE_ONLY,AGOPT_GEN_CFG,AGOPT_OUTPUT,AGOPT_ACC,AGOPT_CC,
		AGOPT_HELP,AGOPT_KEEP_WOVEN, AGOPT_CONFIG_COMMAND,AGOPT_X_COMPILER,AGOPT_X_WEAVER,
		AGOPT_VERBOSE, AGOPT_VERSION, 
		// Ac++ options
		ACOPT, // default handling for AspectC++ options
		ACOPT_INCLUDE_FILES,ACOPT_ASPECT_HEADER,
		ACOPT_PROJ_PATH, ACOPT_PROJ_DESTINATION, ACOPT_CFG_FILE,
		ACOPT_PRE_INCLUDE, ACOPT_PRE_DEFINE, ACOPT_PRE_UNDEFINE,
		ACOPT_ALWAYS_INCLUDE
	};
	  

	
	
	// anaylze the arguments
	bool analyze();
   
   // print Options
	void printOptions();
	
	
	//
	// Methods for accesing private data
	//
	
	const bool gen_pumaconfig(){return _gen_pumaconfig;}
	void gen_pumaconfig(const bool b){_gen_pumaconfig = b;}

	const bool weave(){return _weave;}

	const bool compile(){return _compile;}
	
	const bool make_dep(){return _make_dep;}
	
	const bool link(){return _link;}
	
	const bool keep_woven(){return _keep_woven;}
	
	const bool gen_includes(){return _gen_includes;}
	
	const int nr_files(){return _nr_files;}
	
	const int verbose(){return _verbose;}
	
	OptionVec& optvec(){return _optvec;}
	
	FileCont& ah_files(){return _ah_files;}
	
	FileCont& proj_paths(){return _proj_path;}

	const string& pumaconfig_file(){return _pumaconfig_file;}
	void pumaconfig_file(const string& s){_pumaconfig_file=s;}
	
   const bool& pumaconfig_tmp(){return _pumaconfig_tmp;}

	const string& output_file(){return _output_file;}
	void output_file(const string& s){_output_file=s;}
	
	const string& acc_bin(){return _acc_bin;}
	
	const string& cc_bin(){return _cc_bin;}

	const string& dest_path(){return _dest_path;}
	
	string& config_command(){return _config_command;}
	
   //
	// Helper methods
	//
   
   static inline string& str_replace_all(string& input_str,const string search_str,const string replace_str)
   {
      string::size_type pos = input_str.find(search_str,0);
      while( pos != string::npos)
      {
         input_str.replace(pos,search_str.length(),replace_str);
         pos=input_str.find('"',pos+2);
      }
      return input_str;
   }
	
};	


#endif //__AGxxConfig_h__