qbs build: Introduce libclang module.

This is The Right Way to detect libclang. Using a Probe will also
slightly improve performance in qbs 1.6 due to the result caching.

Change-Id: I063a8d108d02b620dda2df75dd8c014c84f27ec7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Christian Kandeler
2016-06-16 12:11:22 +02:00
parent 1ce258d710
commit 31258ec555
5 changed files with 68 additions and 49 deletions

View File

@@ -1,8 +1,5 @@
import qbs
import qbs.File
import QtcClangInstallation as Clang
import QtcFunctions
import QtcProcessOutputReader
import qbs.FileInfo
QtcPlugin {
name: "ClangCodeModel"
@@ -14,24 +11,22 @@ QtcPlugin {
Depends { name: "TextEditor" }
Depends { name: "Utils" }
Depends { name: "ClangBackEndIpc" }
Depends { name: "libclang"; required: false }
pluginTestDepends: [
"CppEditor",
"QmakeProjectManager",
]
property string llvmConfig: Clang.llvmConfig(qbs, QtcFunctions, QtcProcessOutputReader)
property string llvmIncludeDir: Clang.includeDir(llvmConfig, QtcProcessOutputReader)
property string llvmLibDir: Clang.libDir(llvmConfig, QtcProcessOutputReader)
property string llvmVersion: Clang.version(llvmConfig, QtcProcessOutputReader)
condition: llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"))
condition: libclang.present
cpp.defines: {
var defines = base;
// The following defines are used to determine the clang include path for intrinsics.
defines.push('CLANG_VERSION="' + llvmVersion + '"');
defines.push('CLANG_RESOURCE_DIR="' + llvmLibDir + '/clang/' + llvmVersion + '/include"');
defines.push('CLANG_VERSION="' + libclang.llvmVersion + '"');
var resourceDir = FileInfo.joinPaths(libclang.llvmLibDir, "clang", libclang.llvmVersion,
"include");
defines.push('CLANG_RESOURCE_DIR="' + resourceDir + '"');
return defines;
}