From 2459bee049f5a46cf60c95ab75a24183be574711 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 27 Apr 2022 11:24:40 +0800 Subject: [PATCH] use clang/clang++ instead of gcc/g++ --- RedPandaIDE/settings.cpp | 36 ++++++++++++++++++++++++++++-------- RedPandaIDE/systemconsts.h | 6 ++++++ windows/prepare_clang.sh | 7 +++++++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index da573c60..56b2209b 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1923,12 +1923,17 @@ static void addExistingDirectory(QStringList& dirs, const QString& directory) { 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; // Obtain version number and compiler distro etc QStringList arguments; arguments.append("-v"); - QByteArray output = getCompilerOutput(binDir,GCC_PROGRAM,arguments); + QByteArray output = getCompilerOutput(binDir,cc_prog,arguments); //Target QByteArray targetStr = "Target: "; @@ -2010,7 +2015,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir) // Obtain compiler target arguments.clear(); arguments.append("-dumpmachine"); - mDumpMachine = getCompilerOutput(binDir, GCC_PROGRAM, arguments); + mDumpMachine = getCompilerOutput(binDir, cc_prog, arguments); // Add the default directories addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin"); @@ -2052,10 +2057,25 @@ void Settings::CompilerSet::setDefines() { void Settings::CompilerSet::setExecutables() { - mCCompiler = findProgramInBinDirs(GCC_PROGRAM); - mCppCompiler = findProgramInBinDirs(GPP_PROGRAM); - mDebugger = findProgramInBinDirs(GDB_PROGRAM); - mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM); + if (mCompilerType == COMPILER_CLANG) { + mCCompiler = findProgramInBinDirs(CLANG_PROGRAM); + mCppCompiler = findProgramInBinDirs(CLANG_CPP_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); mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM); mProfiler = findProgramInBinDirs(GPROF_PROGRAM); @@ -2556,7 +2576,7 @@ bool Settings::CompilerSets::addSets(const QString &folder) { if (!directoryExists(folder)) return false; - if (!fileExists(includeTrailingPathDelimiter(folder)+GCC_PROGRAM)) { + if (!fileExists(folder, GCC_PROGRAM) && !fileExists(folder, CLANG_PROGRAM)) { return false; } // Default, release profile diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 667817f5..a7c1ddec 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -32,6 +32,9 @@ #define CLEAN_PROGRAM "del /q /f" #define CPP_PROGRAM "cpp.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) #define GCC_PROGRAM "gcc" #define GPP_PROGRAM "g++" @@ -44,6 +47,9 @@ #define CLEAN_PROGRAM "rm -rf" #define CPP_PROGRAM "cpp" #define GIT_PROGRAM "git" +#define CLANG_PROGRAM "clang" +#define CLANG_CPP_PROGRAM "clang++" +#define LLDB_MI_PROGRAM "lldb-mi" #else #error "Only support windows and linux now!" #endif diff --git a/windows/prepare_clang.sh b/windows/prepare_clang.sh index d146cbef..f6f25c42 100644 --- a/windows/prepare_clang.sh +++ b/windows/prepare_clang.sh @@ -28,6 +28,13 @@ rm -rf bin/llvm-bitcode-strip.exe rm -rf bin/llvm-install-name-tool.exe rm -rf bin/llvm-objcopy.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/libLLVM*.a