1 | /* Compiler handling for plugin |
2 | Copyright (C) 2014-2024 Free Software Foundation, Inc. |
3 | |
4 | This file is part of GCC. |
5 | |
6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free |
8 | Software Foundation; either version 3, or (at your option) any later |
9 | version. |
10 | |
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14 | for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ |
19 | |
20 | #ifndef CC1_PLUGIN_COMPILER_HH |
21 | #define CC1_PLUGIN_COMPILER_HH |
22 | |
23 | namespace cc1_plugin |
24 | { |
25 | |
26 | // Base class for compiler. |
27 | class compiler |
28 | { |
29 | public: |
30 | explicit compiler (bool v) |
31 | : verbose (v) |
32 | { |
33 | } |
34 | |
35 | virtual ~compiler () = default; |
36 | |
37 | // Find the compiler. BASE is the base name of the compiler, see |
38 | // compiler-name.hh. This sets COMPILER to the resulting path. |
39 | // Returns nullptr on success, or a malloc'd error string on |
40 | // failure. |
41 | virtual char *find (const char *base, std::string &compiler) const; |
42 | |
43 | void set_verbose (bool v) |
44 | { |
45 | verbose = v; |
46 | } |
47 | |
48 | protected: |
49 | bool verbose; |
50 | }; |
51 | |
52 | /* Compiler to set by set_triplet_regexp. */ |
53 | class compiler_triplet_regexp : public compiler |
54 | { |
55 | private: |
56 | std::string triplet_regexp_; |
57 | public: |
58 | |
59 | char *find (const char *base, std::string &compiler) const override; |
60 | |
61 | compiler_triplet_regexp (bool v, const char *triplet_regexp) |
62 | : compiler (v), triplet_regexp_ (triplet_regexp) |
63 | { |
64 | } |
65 | }; |
66 | |
67 | /* Compiler to set by set_driver_filename. */ |
68 | class compiler_driver_filename : public compiler |
69 | { |
70 | private: |
71 | std::string driver_filename_; |
72 | public: |
73 | char *find (const char *base, std::string &compiler) const override; |
74 | |
75 | compiler_driver_filename (bool v, const char *driver_filename) |
76 | : compiler (v), driver_filename_ (driver_filename) |
77 | { |
78 | } |
79 | }; |
80 | |
81 | } |
82 | |
83 | #endif // CC1_PLUGIN_COMPILER_HH |
84 | |