File indexing completed on 2024-05-12 04:39:39

0001 /*
0002     SPDX-FileCopyrightText: 2014 Sergey Kalinichev <kalinichev.so.0@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef ICOMPILER_H
0008 #define ICOMPILER_H
0009 
0010 #include <QString>
0011 #include <QSharedPointer>
0012 
0013 #include "../idefinesandincludesmanager.h"
0014 
0015 namespace Utils
0016 {
0017 enum LanguageType
0018 {
0019     C,
0020     Cpp,
0021     OpenCl,
0022     Cuda,
0023     ObjC,
0024     ObjCpp,
0025 
0026     Other
0027 };
0028 }
0029 
0030 /// An interface that represents a compiler. Compiler provides standard include directories and standard defined macros.
0031 class ICompiler
0032 {
0033 public:
0034     /**
0035      * @param name The user visible name
0036      * @param path path to the compiler
0037      * @param factoryName name of the factory that created this compiler
0038      * @param editable whether user can change the name and the path to the compiler (should be set to false for automatically detected compilers)
0039     **/
0040     ICompiler( const QString& name, const QString& path, const QString& factoryName, bool editable );
0041 
0042     /**
0043      * @param type Language type, must not be @ref Utils::Other.
0044      * @param arguments compiler command-line arguments
0045      * @return list of defined macros for the compiler
0046      */
0047     virtual KDevelop::Defines defines(Utils::LanguageType type, const QString& arguments) const = 0;
0048 
0049     /**
0050      * @param type Language type, must not be @ref Utils::Other.
0051      * @param arguments compiler command-line arguments
0052      * @return list of include directories for the compiler
0053      */
0054     virtual KDevelop::Path::List includes(Utils::LanguageType type, const QString& arguments) const = 0;
0055 
0056     void setPath( const QString &path );
0057 
0058     /// @return path to the compiler
0059     QString path() const;
0060 
0061     void setName( const QString &name );
0062 
0063     /// @return user visible name
0064     QString name() const;
0065 
0066     /// Indicates if the compiler name/path can be set manually
0067     bool editable() const;
0068 
0069     /// @return name of the factory that created this compiler
0070     QString factoryName() const;
0071 
0072     virtual ~ICompiler() = default;
0073 
0074 private:
0075     bool m_editable;
0076     QString m_name;
0077     QString m_path;
0078     QString m_factoryName;
0079 };
0080 
0081 using CompilerPointer = QSharedPointer<ICompiler>;
0082 
0083 Q_DECLARE_METATYPE(CompilerPointer)
0084 
0085 #endif // ICOMPILER_H