File: AGxxConfig.h

package info (click to toggle)
aspectc%2B%2B 1%3A2.3%2Bgit20241211-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 18,148 kB
  • sloc: cpp: 110,334; ansic: 7,644; sh: 2,262; makefile: 1,344; pascal: 634; python: 402; xml: 349
file content (368 lines) | stat: -rw-r--r-- 6,492 bytes parent folder | download | duplicates (3)
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
// 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;

  // only let gcc print information
  bool _print_gcc_info;

  // 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[];

  // list of gcc options which only print information
  static string _gcc_option_info[];

  // run Aspect C++ without input files
  bool _run_acpp_without_input;

  // target triple from the ag++ command line (overrides value from g++)
  string _command_line_target_triple;


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_TARGET,
    AGOPT_X_COMPILER,
    AGOPT_X_WEAVER,
    AGOPT_VERBOSE,
    AGOPT_VERSION,
    // Ac++ options
    ACOPT, // default handling for AspectC++ options
    ACOPT_QUOTE_ARG, // default handling for AspectC++ options where the argument has to be quoted
    ACOPT_WITHOUT_INPUT, // default handling for AspectC++ options running without input files
    ACOPT_MATCH_POINTCUT_EXPR,
    ACOPT_INCLUDE_FILES,
    ACOPT_ASPECT_HEADER,
    ACOPT_PROJ_PATH,
    ACOPT_PROJ_DESTINATION,
    ACOPT_CFG_FILE,
    ACOPT_SYS_CFG_FILE,
    ACOPT_PRE_INCLUDE,
    ACOPT_PRE_DEFINE,
    ACOPT_PRE_UNDEFINE,
    ACOPT_PRE_ISYSROOT,
    ACOPT_PRE_FRAMEWORK, // macOS
    ACOPT_ALWAYS_INCLUDE,
    ACOPT_SYS_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;
  }

  const string&
  target_triple()
  {
    return _command_line_target_triple;
  }

  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;
  }

  const bool&
  run_acpp_without_input()
  {
    return _run_acpp_without_input;
  }

  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__