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