use clang/clang++ instead of gcc/g++

This commit is contained in:
Roy Qu 2022-04-27 11:24:40 +08:00
parent ec53ea19a3
commit 2459bee049
3 changed files with 41 additions and 8 deletions

View File

@ -1923,12 +1923,17 @@ static void addExistingDirectory(QStringList& dirs, const QString& directory) {
void Settings::CompilerSet::setProperties(const QString &binDir) void Settings::CompilerSet::setProperties(const QString &binDir)
{ {
if (!fileExists(binDir,GCC_PROGRAM)) QString cc_prog;
if (fileExists(binDir, CLANG_PROGRAM))
cc_prog = CLANG_PROGRAM;
else if (fileExists(binDir,GCC_PROGRAM))
cc_prog = GCC_PROGRAM;
else
return; return;
// Obtain version number and compiler distro etc // Obtain version number and compiler distro etc
QStringList arguments; QStringList arguments;
arguments.append("-v"); arguments.append("-v");
QByteArray output = getCompilerOutput(binDir,GCC_PROGRAM,arguments); QByteArray output = getCompilerOutput(binDir,cc_prog,arguments);
//Target //Target
QByteArray targetStr = "Target: "; QByteArray targetStr = "Target: ";
@ -2010,7 +2015,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
// Obtain compiler target // Obtain compiler target
arguments.clear(); arguments.clear();
arguments.append("-dumpmachine"); arguments.append("-dumpmachine");
mDumpMachine = getCompilerOutput(binDir, GCC_PROGRAM, arguments); mDumpMachine = getCompilerOutput(binDir, cc_prog, arguments);
// Add the default directories // Add the default directories
addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin"); addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin");
@ -2052,10 +2057,25 @@ void Settings::CompilerSet::setDefines() {
void Settings::CompilerSet::setExecutables() void Settings::CompilerSet::setExecutables()
{ {
mCCompiler = findProgramInBinDirs(GCC_PROGRAM); if (mCompilerType == COMPILER_CLANG) {
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM); mCCompiler = findProgramInBinDirs(CLANG_PROGRAM);
mDebugger = findProgramInBinDirs(GDB_PROGRAM); mCppCompiler = findProgramInBinDirs(CLANG_CPP_PROGRAM);
mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM); mDebugger = findProgramInBinDirs(GDB_PROGRAM);
mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM);
if (mCCompiler.isEmpty())
mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
if (mCppCompiler.isEmpty())
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM);
if (mDebugger.isEmpty())
mDebugger = findProgramInBinDirs(GDB_PROGRAM);
if (mDebugServer.isEmpty())
mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM);
} else {
mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM);
mDebugger = findProgramInBinDirs(GDB_PROGRAM);
mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM);
}
mMake = findProgramInBinDirs(MAKE_PROGRAM); mMake = findProgramInBinDirs(MAKE_PROGRAM);
mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM); mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM);
mProfiler = findProgramInBinDirs(GPROF_PROGRAM); mProfiler = findProgramInBinDirs(GPROF_PROGRAM);
@ -2556,7 +2576,7 @@ bool Settings::CompilerSets::addSets(const QString &folder)
{ {
if (!directoryExists(folder)) if (!directoryExists(folder))
return false; return false;
if (!fileExists(includeTrailingPathDelimiter(folder)+GCC_PROGRAM)) { if (!fileExists(folder, GCC_PROGRAM) && !fileExists(folder, CLANG_PROGRAM)) {
return false; return false;
} }
// Default, release profile // Default, release profile

View File

@ -32,6 +32,9 @@
#define CLEAN_PROGRAM "del /q /f" #define CLEAN_PROGRAM "del /q /f"
#define CPP_PROGRAM "cpp.exe" #define CPP_PROGRAM "cpp.exe"
#define GIT_PROGRAM "git.exe" #define GIT_PROGRAM "git.exe"
#define CLANG_PROGRAM "clang.exe"
#define CLANG_CPP_PROGRAM "clang++.exe"
#define LLDB_MI_PROGRAM "lldb-mi.exe"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#define GCC_PROGRAM "gcc" #define GCC_PROGRAM "gcc"
#define GPP_PROGRAM "g++" #define GPP_PROGRAM "g++"
@ -44,6 +47,9 @@
#define CLEAN_PROGRAM "rm -rf" #define CLEAN_PROGRAM "rm -rf"
#define CPP_PROGRAM "cpp" #define CPP_PROGRAM "cpp"
#define GIT_PROGRAM "git" #define GIT_PROGRAM "git"
#define CLANG_PROGRAM "clang"
#define CLANG_CPP_PROGRAM "clang++"
#define LLDB_MI_PROGRAM "lldb-mi"
#else #else
#error "Only support windows and linux now!" #error "Only support windows and linux now!"
#endif #endif

View File

@ -28,6 +28,13 @@ rm -rf bin/llvm-bitcode-strip.exe
rm -rf bin/llvm-install-name-tool.exe rm -rf bin/llvm-install-name-tool.exe
rm -rf bin/llvm-objcopy.exe rm -rf bin/llvm-objcopy.exe
rm -rf bin/llvm-strip.exe rm -rf bin/llvm-strip.exe
rm -rf bin/sqlite3_analyzer.exe
rm -rf bin/sqldiff.exe
rm -rf bin/dbhash.exe
rm -rf bin/glewinfo.exe
rm -rf bin/diagtool.exe
rm -rf bin/FileCheck.exe
rm -rf bin/KillTheDoctor.exe
rm -rf lib/libclang*.a rm -rf lib/libclang*.a
rm -rf lib/libLLVM*.a rm -rf lib/libLLVM*.a