forked from qt-creator/qt-creator
ClangCodeModel: Fix qbs project file.
Works now again for the mainstream UNIX case (relying on llvm-config). Change-Id: Ia928c363a43f54ca56d5371e755c00f4f10fe76f Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
committed by
Joerg Bornemann
parent
60abd3f0a1
commit
fa46c278c2
@@ -1,5 +1,7 @@
|
|||||||
import qbs
|
import qbs
|
||||||
import qbs.File
|
import qbs.File
|
||||||
|
import qbs.Process
|
||||||
|
import QtcProcessOutputReader
|
||||||
|
|
||||||
QtcPlugin {
|
QtcPlugin {
|
||||||
name: "ClangCodeModel"
|
name: "ClangCodeModel"
|
||||||
@@ -11,14 +13,12 @@ QtcPlugin {
|
|||||||
Depends { name: "TextEditor" }
|
Depends { name: "TextEditor" }
|
||||||
Depends { name: "Utils" }
|
Depends { name: "Utils" }
|
||||||
|
|
||||||
property string llvmInstallDir: qbs.getEnv("LLVM_INSTALL_DIR")
|
property string llvmInstallDirFromEnv: qbs.getEnv("LLVM_INSTALL_DIR")
|
||||||
condition: llvmInstallDir && !llvmInstallDir.isEmpty
|
|
||||||
|
|
||||||
property bool clangCompletion: true
|
property bool clangCompletion: true
|
||||||
property bool clangHighlighting: true
|
property bool clangHighlighting: true
|
||||||
property bool clangIndexing: false
|
property bool clangIndexing: false
|
||||||
|
|
||||||
// Not used atm; we just rely on the LLVM_INSTALL_DIR environment variable.
|
|
||||||
property string llvmConfig: {
|
property string llvmConfig: {
|
||||||
var llvmConfigVariants = [
|
var llvmConfigVariants = [
|
||||||
"llvm-config", "llvm-config-3.2", "llvm-config-3.3", "llvm-config-3.4",
|
"llvm-config", "llvm-config-3.2", "llvm-config-3.3", "llvm-config-3.4",
|
||||||
@@ -26,10 +26,12 @@ QtcPlugin {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Prefer llvm-config* from LLVM_INSTALL_DIR
|
// Prefer llvm-config* from LLVM_INSTALL_DIR
|
||||||
for (var i = 0; i < llvmConfigVariants.length; ++i) {
|
if (llvmInstallDirFromEnv) {
|
||||||
var variant = llvmInstallDir + "/bin/" + llvmConfigVariants[i];
|
for (var i = 0; i < llvmConfigVariants.length; ++i) {
|
||||||
if (File.exists(variant))
|
var variant = llvmInstallDirFromEnv + "/bin/" + llvmConfigVariants[i];
|
||||||
return variant;
|
if (File.exists(variant))
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find llvm-config* in PATH
|
// Find llvm-config* in PATH
|
||||||
@@ -44,20 +46,17 @@ QtcPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback
|
return undefined;
|
||||||
return "llvm-config";
|
|
||||||
}
|
}
|
||||||
|
condition: llvmConfig
|
||||||
|
|
||||||
|
property string llvmIncludeDir: QtcProcessOutputReader.readOutput(llvmConfig, ["--includedir"])
|
||||||
|
property string llvmLibDir: QtcProcessOutputReader.readOutput(llvmConfig, ["--libdir"])
|
||||||
|
property string llvmVersion: QtcProcessOutputReader.readOutput(llvmConfig, ["--version"])
|
||||||
|
.replace(/(\d+\.\d+).*/, "$1")
|
||||||
|
|
||||||
property string llvmIncludeDir: llvmInstallDir + "/include"
|
|
||||||
cpp.includePaths: base.concat(llvmIncludeDir)
|
cpp.includePaths: base.concat(llvmIncludeDir)
|
||||||
|
cpp.libraryPaths: base.concat(llvmLibDir)
|
||||||
property stringList llvmLibDirs: {
|
|
||||||
var list = [llvmInstallDir + "/lib"];
|
|
||||||
if (qbs.targetOS.contains("windows"))
|
|
||||||
list.push(llvmInstallDir + "/bin");
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
cpp.libraryPaths: base.concat(llvmLibDirs)
|
|
||||||
cpp.rpaths: cpp.libraryPaths
|
cpp.rpaths: cpp.libraryPaths
|
||||||
|
|
||||||
property string llvmLib: "clang"
|
property string llvmLib: "clang"
|
||||||
@@ -65,6 +64,19 @@ QtcPlugin {
|
|||||||
? ["advapi32", "shell32"] : []
|
? ["advapi32", "shell32"] : []
|
||||||
cpp.dynamicLibraries: base.concat(llvmLib).concat(additionalLibraries)
|
cpp.dynamicLibraries: base.concat(llvmLib).concat(additionalLibraries)
|
||||||
|
|
||||||
|
cpp.defines: {
|
||||||
|
var defines = base;
|
||||||
|
defines.push('CLANG_VERSION="' + llvmVersion + '"');
|
||||||
|
defines.push('CLANG_RESOURCE_DIR="' + llvmLibDir + '/clang/' + llvmVersion + '/include"');
|
||||||
|
if (clangCompletion)
|
||||||
|
defines.push("CLANG_COMPLETION");
|
||||||
|
if (clangHighlighting)
|
||||||
|
defines.push("CLANG_HIGHLIGHTING");
|
||||||
|
if (clangIndexing)
|
||||||
|
defines.push("CLANG_INDEXING");
|
||||||
|
return defines;
|
||||||
|
}
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
name: "Completion support"
|
name: "Completion support"
|
||||||
condition: product.clangCompletion
|
condition: product.clangCompletion
|
||||||
|
Reference in New Issue
Block a user