36
36
string AGxxConfig::_gcc_option_arg[] = {
37
"-aux-info","-print-prog-name=",
38
"-idirafter", "-include", "-imacros", "-iprefix",
39
"-iwithprefix", "-iwithprefixbefore", "-isystem",
40
"-B", "-l", "-I", "-L", "-specs=",
47
""/* terminate with empty string */
37
"-aux-info","-print-prog-name=",
38
"-idirafter", "-imacros", "-iprefix",
39
"-iwithprefix", "-iwithprefixbefore", "-isystem",
40
"-B", "-l", "-I", "-L", "-specs=",
47
""/* terminate with empty string */
50
50
// options for AC++ Compiler
51
51
static OptsParser::Option options[] = {
52
{ AGxxConfig::AGOPT_GEN_CFG, 0, "gen_config",
53
"\t" "Only generate Puma configuration file", OptsParser::AT_NONE },
54
{ AGxxConfig::AGOPT_WEAVE, 0, "weave_only",
55
"\t" "Weave only", OptsParser::AT_NONE },
56
{ AGxxConfig::AGOPT_COMPILE_ONLY, 'c', NULL,
57
"\t\t" "Compile only", OptsParser::AT_NONE },
58
{ AGxxConfig::AGOPT_KEEP_ACC,0, "keep_acc",
59
"\t" "Keep weaved source code files", OptsParser::AT_NONE },
60
{ AGxxConfig::AGOPT_CC, 0, "c_compiler",
61
"Path to C++ compiler", OptsParser::AT_MANDATORY },
62
{ AGxxConfig::AGOPT_ACC, 0, "ac_compiler",
63
"Path to AspectC++ compiler", OptsParser::AT_MANDATORY },
64
{ AGxxConfig::AGOPT_OUTPUT, 'o', "output",
65
"\t" "Name of the output file", OptsParser::AT_MANDATORY },
66
{ AGxxConfig::AGOPT_CONFIG_COMMAND,0, "config_command",
67
"Command which prints information about compiler", OptsParser::AT_MANDATORY },
68
{ AGxxConfig::AGOPT_X_COMPILER,0, "Xcompiler",
69
"\tIn case of doupt account following options as g++ options", OptsParser::AT_NONE },
70
{ AGxxConfig::AGOPT_X_WEAVER,0, "Xweaver",
71
"\t\tIn case of doupt account following options as ac++ options", OptsParser::AT_NONE },
72
{ AGxxConfig::AGOPT_HELP, 'h', "help",
73
"\t\t" "Print this help meassage", OptsParser::AT_NONE },
74
{ AGxxConfig::AGOPT_VERSION, 0, "version",
75
"\t" "\t" "Version information", OptsParser::AT_NONE },
76
{ AGxxConfig::AGOPT_VERBOSE, 'v', "verbose",
77
"Level of verbosity (0-9)", OptsParser::AT_OPTIONAL },
78
{ AGxxConfig::ACOPT_INCLUDE_FILES, 'i', "include_files",
79
"Generate manipulated header files", OptsParser::AT_NONE },
80
{ AGxxConfig::ACOPT_ASPECT_HEADER, 'a', "aspect_header",
81
"Name of aspect header file or '0'", OptsParser::AT_MANDATORY },
82
{ AGxxConfig::ACOPT, 'r', "repository",
83
"Name of the project repository", OptsParser::AT_MANDATORY },
84
{ AGxxConfig::ACOPT, 0, "problem_local_class",
85
"Back-end does not support local classes correctly", OptsParser::AT_NONE },
86
{ AGxxConfig::ACOPT, 0, "no_problem_local_class",
87
"Back-end supports local classes correctly", OptsParser::AT_NONE },
88
{ AGxxConfig::ACOPT, 0, "problem_spec_scope",
89
"Back-end does not support template specialization in non-namespace",OptsParser::AT_NONE },
90
{ AGxxConfig::ACOPT, 0, "no_problem_spec_scope",
91
"Back-end supports template specialization in non-namespace scope",OptsParser::AT_NONE },
92
{ AGxxConfig::ACOPT, 0, "warn_deprecated",
93
"\t" "Warn if deprecated syntax is used", OptsParser::AT_NONE },
94
{ AGxxConfig::ACOPT, 0, "no_warn_deprecated",
95
"Don't warn if deprecated syntax is used", OptsParser::AT_NONE },
96
{ AGxxConfig::ACOPT, 0, "warn_macro",
97
"\t" "Warn if a macro transformation had to be ignored", OptsParser::AT_NONE },
98
{ AGxxConfig::ACOPT, 0, "no_warn_macro",
99
"\t" "Don't warn if a macro transformation had to be ignored", OptsParser::AT_NONE },
100
{ AGxxConfig::ACOPT, 0,"no_line",
101
"\t\t" "Don't generate #line directives",OptsParser::AT_NONE },
102
{ AGxxConfig::ACOPT, 0,"real-instances",
103
"\t" "Perform full template analysis",OptsParser::AT_NONE },
104
{ AGxxConfig::ACOPT_PROJ_PATH, 'p', "path",
105
"\t" "Path to project source", OptsParser::AT_MANDATORY},
106
{ AGxxConfig::ACOPT_PROJ_DESTINATION, 'd', "dest",
107
"\t" "Path to destination for modified include files", OptsParser::AT_MANDATORY},
108
{ AGxxConfig::ACOPT_CFG_FILE, 0, "config",
109
"\t" "Full path to a config file", OptsParser::AT_MANDATORY},
110
{ AGxxConfig::ACOPT_PRE_INCLUDE, 'I', NULL,
111
"\t\t" "Add new include path", OptsParser::AT_MANDATORY},
112
{ AGxxConfig::ACOPT_PRE_DEFINE, 'D', NULL,
113
"\t\t" "Define a preprocessor macro", OptsParser::AT_MANDATORY},
114
{ AGxxConfig::ACOPT_PRE_UNDEFINE, 'U', NULL,
115
"\t\t" "Undefine a preprocessor macro", OptsParser::AT_MANDATORY},
116
{ AGxxConfig::ACOPT_ALWAYS_INCLUDE, 0, "include",
117
"\t" "Always include file", OptsParser::AT_MANDATORY},
118
{ AGxxConfig::ACOPT, 'k', "keywords",
119
"\t" "Allow AspectC++ keywords in normal project files", OptsParser::AT_NONE},
120
{ 0, 0, 0, 0, OptsParser::AT_NONE}
52
{ AGxxConfig::AGOPT_GEN_CFG, NULL, "gen_config",
53
"\t" "Only generate Puma configuration file", OptsParser::AT_NONE },
54
{ AGxxConfig::AGOPT_WEAVE_ONLY, NULL, "weave_only",
55
"\t" "Weave only", OptsParser::AT_NONE },
56
{ AGxxConfig::AGOPT_COMPILE_ONLY, "c", NULL,
57
"\t\t" "Compile only", OptsParser::AT_NONE },
58
{ AGxxConfig::AGOPT_KEEP_WOVEN,NULL, "keep_woven",
59
"\t" "Keep woven source code files", OptsParser::AT_NONE },
60
{ AGxxConfig::AGOPT_KEEP_WOVEN,NULL, "keep_acc",
61
"\t" "Deprecated. Use keep_woven instead", OptsParser::AT_NONE },
62
{ AGxxConfig::AGOPT_CC, NULL, "c_compiler",
63
"Path to C++ compiler", OptsParser::AT_MANDATORY },
64
{ AGxxConfig::AGOPT_ACC, NULL, "ac_compiler",
65
"Path to AspectC++ compiler", OptsParser::AT_MANDATORY },
66
{ AGxxConfig::AGOPT_OUTPUT, "o", "output",
67
"\t" "Name of the output file", OptsParser::AT_MANDATORY },
68
{ AGxxConfig::AGOPT_CONFIG_COMMAND,NULL, "config_command",
69
"Command which prints information about compiler", OptsParser::AT_MANDATORY },
70
{ AGxxConfig::AGOPT_X_COMPILER,NULL, "Xcompiler",
71
"\tIn case of doubt account following options as g++ options", OptsParser::AT_NONE },
72
{ AGxxConfig::AGOPT_X_WEAVER,NULL, "Xweaver",
73
"\t\tIn case of doubt account following options as ac++ options", OptsParser::AT_NONE },
74
{ AGxxConfig::AGOPT_HELP, "h", "help",
75
"\t\t" "Print this help meassage", OptsParser::AT_NONE },
76
{ AGxxConfig::AGOPT_VERSION, NULL, "version",
77
"\t" "\t" "Version information", OptsParser::AT_NONE },
78
{ AGxxConfig::AGOPT_VERBOSE, "v", "verbose",
79
"Level of verbosity (0-9)", OptsParser::AT_OPTIONAL },
80
{ AGxxConfig::ACOPT_INCLUDE_FILES, "i", "include_files",
81
"Generate manipulated header files", OptsParser::AT_NONE },
82
{ AGxxConfig::ACOPT_ASPECT_HEADER, "a", "aspect_header",
83
"Name of aspect header file or '0'", OptsParser::AT_MANDATORY },
84
{ AGxxConfig::ACOPT, "r", "repository",
85
"Name of the project repository", OptsParser::AT_MANDATORY },
86
{ AGxxConfig::ACOPT, NULL, "problem_local_class",
87
"Back-end does not support local classes correctly", OptsParser::AT_NONE },
88
{ AGxxConfig::ACOPT, NULL, "no_problem_local_class",
89
"Back-end supports local classes correctly", OptsParser::AT_NONE },
90
{ AGxxConfig::ACOPT, NULL, "problem_spec_scope",
91
"Back-end does not support template specialization in non-namespace",OptsParser::AT_NONE },
92
{ AGxxConfig::ACOPT, NULL, "no_problem_spec_scope",
93
"Back-end supports template specialization in non-namespace scope",OptsParser::AT_NONE },
94
{ AGxxConfig::ACOPT, NULL, "problem_force_inline",
95
"Back-end does not support forced inlining correctly", OptsParser::AT_NONE },
96
{ AGxxConfig::ACOPT, NULL, "no_problem_force_inline",
97
"Back-end supports forced inlining correctly", OptsParser::AT_NONE },
98
{ AGxxConfig::ACOPT, NULL, "warn_deprecated",
99
"\t" "Warn if deprecated syntax is used", OptsParser::AT_NONE },
100
{ AGxxConfig::ACOPT, NULL, "no_warn_deprecated",
101
"Don't warn if deprecated syntax is used", OptsParser::AT_NONE },
102
{ AGxxConfig::ACOPT, NULL, "warn_macro",
103
"\t" "Warn if a macro transformation had to be ignored", OptsParser::AT_NONE },
104
{ AGxxConfig::ACOPT, NULL, "no_warn_macro",
105
"\t" "Don't warn if a macro transformation had to be ignored", OptsParser::AT_NONE },
106
{ AGxxConfig::ACOPT, NULL,"no_line",
107
"\t\t" "Don't generate #line directives",OptsParser::AT_NONE },
108
{ AGxxConfig::ACOPT, NULL,"real-instances",
109
"\t" "Perform full template analysis",OptsParser::AT_NONE },
110
{ AGxxConfig::ACOPT_PROJ_PATH, "p", "path",
111
"\t" "Path to project source", OptsParser::AT_MANDATORY},
112
{ AGxxConfig::ACOPT_PROJ_DESTINATION, "d", "dest",
113
"\t" "Path to destination for modified include files", OptsParser::AT_MANDATORY},
114
{ AGxxConfig::ACOPT_CFG_FILE, NULL, "config",
115
"\t" "Full path to a config file", OptsParser::AT_MANDATORY},
116
{ AGxxConfig::ACOPT_PRE_INCLUDE, "I", NULL,
117
"\t\t" "Add new include path", OptsParser::AT_MANDATORY},
118
{ AGxxConfig::ACOPT_PRE_DEFINE, "D", NULL,
119
"\t\t" "Define a preprocessor macro", OptsParser::AT_MANDATORY},
120
{ AGxxConfig::ACOPT_PRE_UNDEFINE, "U", NULL,
121
"\t\t" "Undefine a preprocessor macro", OptsParser::AT_MANDATORY},
122
{ AGxxConfig::ACOPT_ALWAYS_INCLUDE, "include", "include",
123
"Always include file", OptsParser::AT_MANDATORY},
124
{ AGxxConfig::ACOPT, "k", "keywords",
125
"\t" "Allow AspectC++ keywords in normal project files", OptsParser::AT_NONE},
126
{ AGxxConfig::ACOPT, NULL, "dynamic",
127
"\t\t" "Prepare generated code for dynamic weaving", OptsParser::AT_NONE },
128
{ 0, 0, 0, 0, OptsParser::AT_NONE}
123
131
void AGxxConfig::usage() const
125
133
_err << "usage: ag++ [options] [file...]" << endMessage
126
<< " options are ..." << endMessage;
134
<< " options are ..." << endMessage;
127
135
for (int i = 0; options[i].number > 0; i++) {
129
if (options[i].key) _err << "-" << options[i].key;
130
if (options[i].key && options[i].name) _err << "|";
131
if (options[i].name) _err << "--" << options[i].name;
132
if (options[i].args) _err << " <arg>";
133
if (options[i].desc) _err << " \t" << options[i].desc;
138
bool AGxxConfig::analyzeGccOpt(OptsParser &op){
140
// option which should be analyzed
141
string opt=op.getOptionName()+op.getArgument();
143
// argument for this option
146
//check for -M/-MM option for generating dependency information
147
if (opt.compare("-M") == 0 || opt.compare("-MM") == 0 ){
148
_gen_pumaconfig=false;
152
_optvec.pushback(opt,OptionItem::OPT_GCC);
156
// check if option gets an argument
157
for(string* test_str=_gcc_option_arg;test_str->empty()==false;++test_str){
158
if( opt.compare(0,test_str->length(),*test_str) == 0){
160
// ok, it gets an argument
161
// check if the argument is appended to the option name
162
if ( opt.length() > test_str->length() ){
163
// extract the argument out of the option name
164
arg="\""+opt.substr(test_str->length())+"\"";
165
opt=opt.substr(0,test_str->length());
167
// check if there exist another option
168
if(op.getOption () != OptsParser::FINISH) {
169
// check if the next option is an argument (aka NOOPTION)
170
if(op.getResult() == OptsParser::NOOPTION){
171
arg="\""+op.getArgument()+"\"";
173
// the next option is NOT an argument
174
_err << sev_error << "G++ Option reqires argument: " ;
175
_err <<"'"<<opt.c_str() <<"'"<< endMessage;
179
// there is no option anymore
180
_err << sev_error << "G++ Option reqires argument: " ;
181
_err <<"'"<< opt.c_str() <<"'"<< endMessage;
187
_optvec.pushback(opt,arg,OptionItem::OPT_GCC);
194
bool AGxxConfig::analyze(){
197
// setup default values
198
_gen_pumaconfig=true;
212
OptsParser op(_argc,_argv,options);
214
// extract options/filenames out of command line arguments
215
while (op.getOption () != OptsParser::FINISH) {
216
// first parse options which do not interfere with g++
219
switch (op.getResult ()) {
222
_output_file=op.getArgument();
223
// we can not push '-o <filename>'
224
// into the options vector as afterwards the generation of the
225
// puma.config file fails
228
case AGOPT_COMPILE_ONLY :
231
_optvec.pushback("-c",OptionItem::OPT_GCC);
234
case AGOPT_X_COMPILER :
238
case AGOPT_X_WEAVER :
242
case ACOPT_CFG_FILE :
243
_puma_config=op.getArgument();
246
case ACOPT_PRE_DEFINE :
247
_optvec.pushback("-D","\""+op.getArgument()+"\"",OptionItem::OPT_ACC|OptionItem::OPT_GCC);
250
case ACOPT_PRE_UNDEFINE :
251
_optvec.pushback("-U",op.getArgument(),OptionItem::OPT_ACC|OptionItem::OPT_GCC);
254
case ACOPT_PRE_INCLUDE :
255
_optvec.pushback("-I","\""+op.getArgument()+"\"",OptionItem::OPT_ACC|OptionItem::OPT_GCC);
259
// command line arguments which are not accepted as options
260
// are recognized as filenames
261
case OptsParser::NOOPTION :
263
// if file is a c++ file weave it first.
264
if (regex::regExMatch("^.*\\.((C)|(c)|(cc)|(cp)|(cpp)|(cxx)|(c\\+\\+))$",op.getArgument().c_str()) ){
268
_optvec.pushback(op.getArgument(),OptionItem::OPT_FILE_ACC);
270
// when calling we have to pass the original path of this
271
// source dir as include path, as the '.acc' file to be
272
// compiled will probably not be generated in the same
274
string tmpStr=op.getArgument();
275
file::stripFilename(tmpStr);
279
_optvec.pushback("-I","\""+tmpStr+"\"",OptionItem::OPT_GCC);
281
_optvec.pushback(op.getArgument(),OptionItem::OPT_FILE_GCC);
287
// if _x_compiler is set to 'true' interprete
288
// options that are not handled within this
289
// 'switch-case' statement as gcc options.
290
if (_x_compiler == true){
291
if (analyzeGccOpt(op)==false){
298
// check if option is manually assigned to the compiler
300
switch (op.getResult ()) {
307
cout << "ag++ " << _VERSION <<" built: "<<__DATE__<< endl;
324
_acc_bin=op.getArgument();
328
_cc_bin=op.getArgument();
331
case AGOPT_KEEP_ACC :
335
case AGOPT_CONFIG_COMMAND :
336
_config_command=op.getArgument();
340
case ACOPT: // default handling for Aspect C++ options
341
_optvec.pushback(op.getOptionName(),op.getArgument(),OptionItem::OPT_ACC);
344
case ACOPT_INCLUDE_FILES :
352
_optvec.pushback("-v",op.getArgument(),OptionItem::OPT_ACC);
353
if (op.getArgument().empty ()){
357
_verbose = atoi (op.getArgument().c_str());
360
_optvec.pushback("-v",OptionItem::OPT_GCC);
364
case ACOPT_ASPECT_HEADER :
365
_ah_files.push_back(op.getArgument());
366
_optvec.pushback("-a","\""+op.getArgument()+"\"",OptionItem::OPT_ACC);
369
case ACOPT_PROJ_PATH :
370
_proj_path.push_back(op.getArgument());
371
_optvec.pushback("-p","\""+op.getArgument()+"\"",OptionItem::OPT_ACC);
374
case ACOPT_PROJ_DESTINATION :
375
_dest_path=op.getArgument();
376
// not pushed into the '_optvec' vector because:
377
// - destination path is only used in WTP mode
378
// - WTP mode is only used if --include_files is
382
case ACOPT_ALWAYS_INCLUDE :
383
_dest_path=op.getArgument();
384
_optvec.pushback("--include","\""+op.getArgument()+"\"",OptionItem::OPT_ACC);
385
_optvec.pushback("-include","\""+op.getArgument()+"\"",OptionItem::OPT_GCC);
389
case OptsParser::NOARG :
390
_err << sev_error << "Option reqires argument: " ;
391
_err <<"'"<<op.getOptionName().c_str() <<"'"<< endMessage;
394
case OptsParser::ERR :
395
_err << sev_error << " Parsing Options : ";
396
_err << "unspecified error at " ;
397
_err <<"'"<<op.getOptionName().c_str() << " " << op.getArgument().c_str() <<"'"<< endMessage;
400
// unknown options are recognized as g++ options
401
case OptsParser::UNKNOWN :
402
if (analyzeGccOpt(op)==false){
408
_err << sev_error << " Parsing Options : ";
409
_err << "option not handled by Ag++ " ;
410
_err <<"'"<<op.getOptionName().c_str() << " " << op.getArgument().c_str() <<"'"<< endMessage;
417
// if we are compiling for WIN32 target transform paths to dos
418
// format, bacause the shell(cmd.exe) can not handle unix
421
file::MakeDosPath(_acc_bin);
422
file::MakeDosPath(_cc_bin);
425
// if path to ac++ was not specified in options.
426
// get it from ARGV[0]
427
if(_acc_bin.empty()){
429
file::stripFilename(_acc_bin);
430
_acc_bin.append("ac++");
433
// if there was no project path specified
434
// take local directory ('.')
435
if(_proj_path.empty()){
436
_proj_path.push_back(".");
437
_optvec.pushback("-p",".",OptionItem::OPT_ACC);
445
if (_gen_includes==true && _dest_path.empty()){
446
_err << sev_error << "Need to specify a destination path in order "
447
<< "to generate modified include files" << endMessage;
451
// If weaving should be done check if there are any files in argument string
452
if(_nr_files == 0 && _weave && ! _gen_includes){
453
_err << sev_error << "No files found in arguments" << endMessage;
458
// If '--weave-only' and '-o' options are used with multiple files
459
// exit with an error
460
if( (! (_output_file.empty() || _compile) ) && _nr_files > 1 ){
461
_err << sev_error << "Cannot specify -o with --weave_only and multiple compilations"<<endMessage;
465
// If dependencies should be generated don't weave, compile, or generate a config file
466
if( (_weave || _link || _gen_pumaconfig) && _make_dep ){
467
_err << sev_error << "Invalid selection of options: can't (weave OR link OR generate a config file) AND create dependency information"<<endMessage;
474
void AGxxConfig::printOptions(){
475
VerboseMgr vm(cout,_verbose);
478
vm << "AG++ Configuration:" << endvm;
479
vm << " Create puma.config: " << _puma_config.empty() <<endvm;
480
vm << " Aspect C++ weaver: " << _acc_bin << endvm;
481
vm << " C++ compiler: " << _cc_bin << endvm;
482
vm << " Files: " << _optvec.getString(OptionItem::OPT_FILE) << endvm;
483
vm << " Options (G++): " << _optvec.getString(OptionItem::OPT_GCC) << endvm;
484
vm << " Options (AC++): " << _optvec.getString(OptionItem::OPT_ACC) << endvm;
485
vm << " Options (total): " << _optvec.getString() << endvm;
486
vm << " Weave: "<<_weave<<" Compile: "<< _compile<<" Link: "<<_link << endvm;
137
if (options[i].shortName) _err << "-" << options[i].shortName;
138
if (options[i].shortName && options[i].longName) _err << "|";
139
if (options[i].longName) _err << "--" << options[i].longName;
140
if (options[i].argType != OptsParser::AT_NONE) _err << " <arg>";
141
if (options[i].desc) _err << " \t" << options[i].desc;
146
bool AGxxConfig::parseGccOpt(OptsParser &op)
149
// option which should be analyzed
150
string opt=op.getOptionName()+op.getArgument();
152
// argument for this option
155
//check for -M/-MM option for generating dependency information
156
if (opt.compare("-M") == 0 || opt.compare("-MM") == 0 ){
158
_optvec.pushback(opt,OptionItem::OPT_GCC);
162
// check if option is in list of gcc options which require an option argument
163
for(string* test_str=_gcc_option_arg;test_str->empty()==false;++test_str){
164
if( opt.compare(0,test_str->length(),*test_str) == 0){
166
// option requires an argument
168
// check if the argument is appended to the option name
169
if ( opt.length() > test_str->length() ){
170
// extract the argument out of the option name
171
arg=" \""+opt.substr(test_str->length())+"\" ";
172
opt=opt.substr(0,test_str->length());
174
// check if there exist another option on command line
175
if(op.getRawOption () != OptsParser::FINISH) {
176
// append argument to string of arguments
177
arg=" \""+op.getArgument()+"\" ";
179
// there is no option anymore
180
_err << sev_error << "G++ Option reqires argument: " ;
181
_err <<"'"<< opt.c_str() <<"'"<< endMessage;
187
_optvec.pushback(opt,arg,OptionItem::OPT_GCC|OptionItem::OPT_CONFIG);
194
bool AGxxConfig::analyze()
198
// setup default values
199
_gen_pumaconfig=true;
207
_pumaconfig_tmp=true;
217
// parse Options received from command line
218
ret = parseOptions();
222
// analyze Options received from command line
223
ret = analyzeOptions();
230
bool AGxxConfig::parseOptions()
232
// use the PUMA option parser for parsing
233
OptsParser op(_argc,_argv,options);
235
// extract options/filenames out of command line arguments
236
while (op.getOption () != OptsParser::FINISH)
240
// first parse options which do not interfere with g++
243
switch (op.getResult ()) {
246
_output_file=op.getArgument();
247
_optvec.pushback("-o"," \""+op.getArgument()+"\" ",(OptionItem::OPT_GCC));
250
case AGOPT_COMPILE_ONLY :
252
_optvec.pushback("-c",OptionItem::OPT_GCC);
255
case AGOPT_X_COMPILER :
259
case AGOPT_X_WEAVER :
263
case ACOPT_CFG_FILE :
264
_pumaconfig_file=op.getArgument();
265
_pumaconfig_tmp=false;
268
case ACOPT_PRE_DEFINE :
270
string tmpStr=op.getArgument();
271
_optvec.pushback("-D"," \""+
272
str_replace_all(tmpStr,"\"","\\\"")+
274
(OptionItem::OPT_ACC|OptionItem::OPT_GCC));
278
case ACOPT_PRE_UNDEFINE :
279
_optvec.pushback("-U"," \""+op.getArgument()+"\" ",
280
(OptionItem::OPT_ACC|OptionItem::OPT_GCC));
283
case ACOPT_PRE_INCLUDE :
284
_optvec.pushback("-I"," \""+op.getArgument()+"\" ",
285
(OptionItem::OPT_ACC|OptionItem::OPT_GCC));
289
// command line arguments which are not accepted as options
290
// are recognized as filenames
291
case OptsParser::NOOPTION :
293
// if file is a c++ file weave it first.
294
if (regex::regExMatch("^.*\\.((C)|(c)|(cc)|(cp)|(cpp)|(cxx)|(c\\+\\+))$",op.getArgument().c_str()) )
296
_optvec.pushback(op.getArgument(),(OptionItem::OPT_ACC|OptionItem::OPT_FILE));
298
// when calling we have to pass the original path of this
299
// source dir as include path, as the '.acc' file to be
300
// compiled will probably not be generated in the same
302
string tmpStr=op.getArgument();
303
file::stripFilename(tmpStr);
308
_optvec.pushback("-I"," \""+tmpStr+"\" ",OptionItem::OPT_GCC);
310
_optvec.pushback(op.getArgument(),(OptionItem::OPT_GCC|OptionItem::OPT_FILE));
315
// if _x_compiler is set to 'true' interprete
316
// options that are not handled within the previous
317
// 'switch-case' statement as gcc options.
318
if (_x_compiler == true){
319
if (parseGccOpt(op)==false){
326
switch (op.getResult ()) {
333
cout << "ag++ " << _VERSION <<" built: "<<__DATE__<< endl;
338
_pumaconfig_tmp=false;
341
case AGOPT_WEAVE_ONLY :
347
_acc_bin=op.getArgument();
351
_cc_bin=op.getArgument();
354
case AGOPT_KEEP_WOVEN :
355
if(op.getOptionName() == "--keep_acc")
357
_err << sev_warning << "Usage of --keep_acc is deprecated use --keep_woven instead" << endMessage;
362
case AGOPT_CONFIG_COMMAND :
363
_config_command=op.getArgument();
367
case ACOPT: // default handling for Aspect C++ options
368
_optvec.pushback(op.getOptionName(),op.getArgument(),OptionItem::OPT_ACC);
371
case ACOPT_INCLUDE_FILES :
376
_optvec.pushback("-v",op.getArgument(),OptionItem::OPT_ACC);
377
if (op.getArgument().empty ()){
381
_verbose = atoi (op.getArgument().c_str());
384
_optvec.pushback("-v",OptionItem::OPT_GCC);
388
case ACOPT_ASPECT_HEADER :
389
_ah_files.push_back(op.getArgument());
390
_optvec.pushback("-a"," \""+op.getArgument()+"\" ",OptionItem::OPT_ACC);
393
case ACOPT_PROJ_PATH :
394
_proj_path.push_back(op.getArgument());
395
_optvec.pushback("-p"," \""+op.getArgument()+"\" ",OptionItem::OPT_ACC);
398
case ACOPT_PROJ_DESTINATION :
399
_dest_path=op.getArgument();
400
// not pushed into the '_optvec' vector because:
401
// - destination path is only used in WTP mode
402
// - WTP mode is only used if --include_files is
406
case ACOPT_ALWAYS_INCLUDE :
407
_dest_path=op.getArgument();
408
_optvec.pushback("--include"," \""+op.getArgument()+"\" ",OptionItem::OPT_ACC);
409
_optvec.pushback("-include"," \""+op.getArgument()+"\" ",OptionItem::OPT_GCC);
413
case OptsParser::NOARG :
414
_err << sev_error << "Option reqires argument: " ;
415
_err <<"'"<<op.getOptionName().c_str() <<"'"<< endMessage;
418
case OptsParser::ERR :
419
_err << sev_error << " Parsing Options : ";
420
_err << "unspecified error at " ;
421
_err <<"'"<<op.getOptionName().c_str() << " " << op.getArgument().c_str() <<"'"<< endMessage;
424
// unknown options are recognized as g++ options
425
case OptsParser::UNKNOWN :
426
if (parseGccOpt(op)==false){
432
_err << sev_error << " Parsing Options : ";
433
_err << "option not handled by Ag++ " ;
434
_err <<"'"<<op.getOptionName().c_str() << " " << op.getArgument().c_str() <<"'"<< endMessage;
442
bool AGxxConfig::analyzeOptions()
444
// if we are compiling for WIN32 target transform paths to dos
445
// format, bacause the shell(cmd.exe) can not handle unix
448
file::MakeDosPath(_acc_bin);
449
file::MakeDosPath(_cc_bin);
452
// if path to ac++ was not specified in options.
453
// get it from ARGV[0]
457
file::stripFilename(_acc_bin);
458
_acc_bin.append("ac++");
461
// if there was no project path specified
462
// take local directory ('.')
463
if(_proj_path.empty())
465
_proj_path.push_back(".");
466
_optvec.pushback("-p",".",OptionItem::OPT_ACC);
470
// check if puma config file shall be generated
471
if (_make_dep == true)
473
_gen_pumaconfig=false;
477
// check if source files shall be woven
478
if ((_make_dep == false) && (_nr_files > 0) || (_gen_includes == true))
483
// check if source files shall be translated
484
if ((_weave_only == false) && (_gen_includes == false) && (_nr_files > 0))
489
// check if source files shall be linked
490
if ((_weave_only == false) && (_gen_includes == false) && (_compile_only == false) && (_make_dep == false) && (_nr_files > 0) )
499
// if modified include files are NOT created and only a temporary
500
// puma configuration file is generated ag++ expects some input files
501
if ((_gen_includes==false) && (_pumaconfig_tmp == true) && (_nr_files==0))
503
_err << sev_error << "No input files"<< endMessage;
507
// If modified include files are created a destination
508
// path must be specified
509
if (_gen_includes==true && _dest_path.empty())
511
_err << sev_error << "Need to specify a destination path in order "
512
<< "to generate modified include files" << endMessage;
516
// If '--weave-only' and '-o' options are used with multiple files
517
// exit with an error
518
if((_weave_only == true) && (_output_file.empty() == false) && (_nr_files > 1))
520
_err << sev_error << "Cannot specify -o with --weave_only and multiple compilations"<<endMessage;
527
void AGxxConfig::printOptions()
529
VerboseMgr vm(cout,_verbose);
532
vm << "AG++ Configuration:" << endvm;
533
vm << " Aspect C++ weaver: " << _acc_bin << endvm;
534
vm << " C++ compiler: " << _cc_bin << endvm;
535
vm << " Files: " << _optvec.getString(OptionItem::OPT_FILE) << endvm;
536
vm << " Options (G++): " << _optvec.getString(OptionItem::OPT_GCC,OptionItem::OPT_FILE) << endvm;
537
vm << " Options (AC++): " << _optvec.getString(OptionItem::OPT_ACC,OptionItem::OPT_FILE) << endvm;
538
vm << " Options (total): " << _optvec.getString() << endvm;
539
vm << " PumaConfig: " <<_gen_pumaconfig<< " Weave: "<<_weave<<" Compile: "<< _compile<<" Link: "<<_link << endvm;