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 #include "compilerfactories.h"
0008 #include "compilerprovider.h"
0009 
0010 #include "gcclikecompiler.h"
0011 #include "msvccompiler.h"
0012 
0013 QString ClangFactory::name() const
0014 {
0015     return QStringLiteral("Clang");
0016 }
0017 
0018 bool ClangFactory::isSupported(const KDevelop::Path& path) const
0019 {
0020     const auto filename = path.lastPathSegment();
0021     return filename.contains(QLatin1String("clang")) && !filename.contains(QLatin1String("clang-cl"));
0022 }
0023 
0024 CompilerPointer ClangFactory::createCompiler(const QString& name, const QString& path, bool editable ) const
0025 {
0026     return CompilerPointer(new GccLikeCompiler(name, path, editable, this->name()));
0027 }
0028 
0029 void ClangFactory::registerDefaultCompilers(CompilerProvider* provider) const
0030 {
0031     const QString clang = QStringLiteral("clang");
0032 
0033     auto compiler = createCompiler(name(), clang, false);
0034     provider->registerCompiler(compiler);
0035 }
0036 
0037 QString GccFactory::name() const
0038 {
0039     return QStringLiteral("GCC");
0040 }
0041 
0042 bool GccFactory::isSupported(const KDevelop::Path& path) const
0043 {
0044     return path.lastPathSegment().contains(QLatin1String("gcc")) || path.lastPathSegment().contains(QLatin1String("g++"));
0045 }
0046 
0047 CompilerPointer GccFactory::createCompiler(const QString& name, const QString& path, bool editable ) const
0048 {
0049     return CompilerPointer(new GccLikeCompiler(name, path, editable, this->name()));
0050 }
0051 
0052 void GccFactory::registerDefaultCompilers(CompilerProvider* provider) const
0053 {
0054     const QString gcc = QStringLiteral("gcc");
0055 
0056     auto compiler = createCompiler(name(), gcc, false);
0057     provider->registerCompiler(compiler);
0058 }
0059 
0060 QString MsvcFactory::name() const
0061 {
0062     return QStringLiteral("MSVC");
0063 }
0064 
0065 CompilerPointer MsvcFactory::createCompiler(const QString& name, const QString& path, bool editable ) const
0066 {
0067    return CompilerPointer(new MsvcCompiler(name, path, editable, this->name()));
0068 }
0069 
0070 void MsvcFactory::registerDefaultCompilers(CompilerProvider* provider) const
0071 {
0072     provider->registerCompiler(createCompiler(name(), QStringLiteral("cl.exe"), false));
0073 }
0074 
0075 bool MsvcFactory::isSupported(const KDevelop::Path& path) const
0076 {
0077     return path.lastPathSegment() == QLatin1String("cl.exe") || path.lastPathSegment().contains(QLatin1String("clang-cl"));
0078 }