Commit 3bcbcfa6 authored by Christian Kandeler's avatar Christian Kandeler

Add qbs project files for some clang-related tools and plugins

Change-Id: I4882be50c6b007715f7b281f95d111abc5cda62a
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
Reviewed-by: Oswald Buddenhagen's avatarOswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Jake Petroules's avatarJake Petroules <jake.petroules@qt.io>
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 640ba75d
......@@ -14,6 +14,11 @@ function readOutput(executable, args)
return output;
}
function readListOutput(executable, args)
{
return readOutput(executable, args).split(/\s+/);
}
function isSuitableLLVMConfig(llvmConfigCandidate, qtcFunctions)
{
if (File.exists(llvmConfigCandidate)) {
......@@ -75,3 +80,66 @@ function libraries(targetOS)
{
return targetOS.contains("windows") ? ["libclang.lib", "advapi32.lib", "shell32.lib"] : ["clang"]
}
function toolingLibs(llvmConfig, targetOS)
{
var fixedList = [
"clangTooling",
"clangFrontend",
"clangIndex",
"clangParse",
"clangSerialization",
"clangSema",
"clangEdit",
"clangAnalysis",
"clangDriver",
"clangDynamicASTMatchers",
"clangASTMatchers",
"clangToolingCore",
"clangAST",
"clangLex",
"clangBasic",
];
if (targetOS.contains("windows"))
fixedList.push("version");
var dynamicList = readListOutput(llvmConfig, ["--libs"])
.concat(readListOutput(llvmConfig, ["--system-libs"]));
return fixedList.concat(dynamicList.map(function(s) {
return s.startsWith("-l") ? s.slice(2) : s;
}));
}
function toolingParameters(llvmConfig)
{
var params = {
defines: [],
includes: [],
cxxFlags: [],
};
var allCxxFlags = readListOutput(llvmConfig, ["--cxxflags"]);
for (var i = 0; i < allCxxFlags.length; ++i) {
var flag = allCxxFlags[i];
if (flag.startsWith("-D") || flag.startsWith("/D")) {
params.defines.push(flag.slice(2));
continue;
}
if (flag.startsWith("-I") || flag.startsWith("/I")) {
params.includes.push(flag.slice(2));
continue;
}
if (!flag.startsWith("-std") && !flag.startsWith("-O") && !flag.startsWith("/O")
&& !flag.startsWith("-march")
&& !flag.startsWith("/EH") && flag !== "-fno-exceptions"
&& flag !== "/W4" && flag !== "-Werror=date-time"
&& flag !== "-Wcovered-switch-default" && flag !== "-fPIC" && flag !== "-pedantic"
&& flag !== "-Wstring-conversion" && flag !== "-gsplit-dwarf") {
params.cxxFlags.push(flag);
}
}
return params;
}
function buildMode(llvmConfig)
{
return readOutput(llvmConfig, ["--build-mode"]);
}
import qbs
import qbs.Environment
import qbs.File
import qbs.Utilities
import QtcFunctions
import "functions.js" as ClangFunctions
......@@ -12,6 +14,11 @@ Module {
property string llvmIncludeDir
property string llvmLibDir
property stringList llvmLibs
property stringList llvmToolingLibs
property stringList llvmToolingDefines
property stringList llvmToolingIncludes
property stringList llvmToolingCxxFlags
property string llvmBuildMode
configure: {
llvmConfig = ClangFunctions.llvmConfig(qbs, QtcFunctions);
......@@ -19,6 +26,12 @@ Module {
llvmIncludeDir = ClangFunctions.includeDir(llvmConfig);
llvmLibDir = ClangFunctions.libDir(llvmConfig);
llvmLibs = ClangFunctions.libraries(qbs.targetOS);
llvmToolingLibs = ClangFunctions.toolingLibs(llvmConfig, qbs.targetOS);
llvmBuildMode = ClangFunctions.buildMode(llvmConfig);
var toolingParams = ClangFunctions.toolingParameters(llvmConfig);
llvmToolingDefines = toolingParams.defines;
llvmToolingIncludes = toolingParams.includes;
llvmToolingCxxFlags = toolingParams.cxxFlags;
found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
}
}
......@@ -28,6 +41,17 @@ Module {
property string llvmIncludeDir: clangProbe.llvmIncludeDir
property string llvmLibDir: clangProbe.llvmLibDir
property stringList llvmLibs: clangProbe.llvmLibs
property stringList llvmToolingLibs: clangProbe.llvmToolingLibs
property string llvmBuildMode: clangProbe.llvmBuildMode
property bool llvmBuildModeMatches: qbs.buildVariant === llvmBuildMode.toLowerCase()
property stringList llvmToolingDefines: clangProbe.llvmToolingDefines
property stringList llvmToolingIncludes: clangProbe.llvmToolingIncludes.filter(function(incl) {
return incl != llvmIncludeDir;
})
property stringList llvmToolingCxxFlags: clangProbe.llvmToolingCxxFlags
property bool toolingEnabled: !Environment.getEnv("QTC_NO_CLANG_LIBTOOLING")
&& Utilities.versionCompare(llvmVersion, "3.9") > 0
&& Utilities.versionCompare(llvmVersion, "4") < 0
validate: {
if (!clangProbe.found) {
......
import qbs
import qbs.FileInfo
QtcPlugin {
name: "ClangPchManager"
Depends { name: "libclang"; required: false }
condition: libclang.present && libclang.toolingEnabled
Depends { name: "ClangSupport" }
Depends { name: "Utils" }
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "ProjectExplorer" }
cpp.defines: {
var defines = base;
defines.push("CLANGPCHMANAGER_LIB");
// The following defines are used to determine the clang include path for intrinsics.
defines.push('CLANG_VERSION="' + libclang.llvmVersion + '"');
var resourceDir = FileInfo.joinPaths(libclang.llvmLibDir, "clang", libclang.llvmVersion,
"include");
defines.push('CLANG_RESOURCE_DIR="' + resourceDir + '"');
return defines;
}
cpp.includePaths: ["."]
files: [
"clangpchmanagerplugin.cpp",
"clangpchmanagerplugin.h",
"clangpchmanager_global.h",
"pchmanagerclient.cpp",
"pchmanagerclient.h",
"pchmanagernotifierinterface.cpp",
"pchmanagernotifierinterface.h",
"pchmanagerconnectionclient.cpp",
"pchmanagerconnectionclient.h",
"pchmanagerprojectupdater.cpp",
"pchmanagerprojectupdater.h",
"projectupdater.cpp",
"projectupdater.h",
"qtcreatorprojectupdater.cpp",
"qtcreatorprojectupdater.h",
]
}
import qbs
import qbs.FileInfo
QtcPlugin {
name: "ClangRefactoring"
Depends { name: "libclang"; required: false }
condition: libclang.present && libclang.toolingEnabled
Depends { name: "ClangSupport" }
Depends { name: "Utils" }
Depends { name: "ClangPchManager" }
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
cpp.defines: {
var defines = base;
defines.push("CLANGPCHMANAGER_LIB");
// The following defines are used to determine the clang include path for intrinsics.
defines.push('CLANG_VERSION="' + libclang.llvmVersion + '"');
var resourceDir = FileInfo.joinPaths(libclang.llvmLibDir, "clang", libclang.llvmVersion,
"include");
defines.push('CLANG_RESOURCE_DIR="' + resourceDir + '"');
return defines;
}
cpp.includePaths: ["."]
files: [
"baseclangquerytexteditorwidget.cpp",
"baseclangquerytexteditorwidget.h",
"clangqueryexamplehighlighter.cpp",
"clangqueryexamplehighlighter.h",
"clangqueryexamplehighlightmarker.h",
"clangqueryexampletexteditorwidget.cpp",
"clangqueryexampletexteditorwidget.h",
"clangqueryhighlighter.cpp",
"clangqueryhighlighter.h",
"clangqueryhighlightmarker.h",
"clangqueryhoverhandler.cpp",
"clangqueryhoverhandler.h",
"clangqueryprojectsfindfilter.cpp",
"clangqueryprojectsfindfilter.h",
"clangqueryprojectsfindfilter.ui",
"clangqueryprojectsfindfilterwidget.cpp",
"clangqueryprojectsfindfilterwidget.h",
"clangquerytexteditorwidget.cpp",
"clangquerytexteditorwidget.h",
"clangrefactoringplugin.cpp",
"clangrefactoringplugin.h",
"projectpartutilities.cpp",
"projectpartutilities.h",
"qtcreatorclangqueryfindfilter.cpp",
"qtcreatorclangqueryfindfilter.h",
"qtcreatorsearch.cpp",
"qtcreatorsearch.h",
"qtcreatorsearchhandle.cpp",
"qtcreatorsearchhandle.h",
"querysqlitestatementfactory.h",
"refactoringclient.cpp",
"refactoringclient.h",
"refactoringconnectionclient.cpp",
"refactoringconnectionclient.h",
"refactoringengine.cpp",
"refactoringengine.h",
"refactoringprojectupdater.cpp",
"refactoringprojectupdater.h",
"searchhandle.cpp",
"searchhandle.h",
"searchinterface.cpp",
"searchinterface.h",
"sourcelocations.h",
"symbolquery.cpp",
"symbolquery.h",
]
}
......@@ -13,6 +13,8 @@ Project {
"bineditor/bineditor.qbs",
"bookmarks/bookmarks.qbs",
"clangcodemodel/clangcodemodel.qbs",
"clangpchmanager/clangpchmanager.qbs",
"clangrefactoring/clangrefactoring.qbs",
"clangstaticanalyzer/clangstaticanalyzer.qbs",
"classview/classview.qbs",
"clearcase/clearcase.qbs",
......
import qbs
import qbs.FileInfo
QtcTool {
name: "clangpchmanagerbackend"
Depends { name: "libclang"; required: false }
condition: libclang.present
&& libclang.toolingEnabled
&& (!qbs.targetOS.contains("windows") || libclang.llvmBuildModeMatches)
Depends { name: "ClangSupport" }
Depends { name: "Qt.network" }
cpp.cxxFlags: base.concat(libclang.llvmToolingCxxFlags)
cpp.defines: {
var list = base.concat(libclang.llvmToolingDefines);
list.push('CLANG_COMPILER_PATH="'
+ FileInfo.joinPaths(FileInfo.path(libclang.llvmConfig), "clang") + '"');
return list;
}
cpp.includePaths: base.concat(libclang.llvmIncludeDir).concat(libclang.llvmToolingIncludes)
.concat(["source", "../clangrefactoringbackend/source"])
cpp.libraryPaths: base.concat(libclang.llvmLibDir)
cpp.dynamicLibraries: base.concat(libclang.llvmToolingLibs)
Properties {
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos")
cpp.rpaths: base.concat(libclang.llvmLibDir)
}
files: [
"clangpchmanagerbackendmain.cpp",
]
Group {
prefix: "source/"
files: [
"changedfilepathcompressor.h",
"clangpathwatcherinterface.cpp",
"clangpathwatcherinterface.h",
"clangpathwatchernotifier.cpp",
"clangpathwatchernotifier.h",
"clangpathwatcher.cpp",
"clangpathwatcher.h",
"clangpchmanagerbackend_global.h",
"collectincludesaction.h",
"collectincludespreprocessorcallbacks.h",
"collectincludestoolaction.h",
"environment.h",
"idpaths.cpp",
"idpaths.h",
"includecollector.cpp",
"includecollector.h",
"pchcreatorinterface.cpp",
"pchcreatorinterface.h",
"pchcreator.cpp",
"pchcreator.h",
"pchgenerator.h",
"pchgeneratorinterface.cpp",
"pchgeneratorinterface.h",
"pchgeneratornotifierinterface.cpp",
"pchgeneratornotifierinterface.h",
"pchmanagerserver.cpp",
"pchmanagerserver.h",
"pchnotcreatederror.h",
"projectpartsinterface.cpp",
"projectpartsinterface.h",
"projectparts.cpp",
"projectparts.h",
]
}
Group {
name: "sources from clangrefactoring"
prefix: "../clangrefactoringbackend/source/"
files: [
"clangtool.cpp",
"refactoringcompilationdatabase.cpp",
]
}
}
import qbs
import qbs.FileInfo
QtcTool {
name: "clangrefactoringbackend"
Depends { name: "libclang"; required: false }
condition: libclang.present
&& libclang.toolingEnabled
&& (!qbs.targetOS.contains("windows") || libclang.llvmBuildModeMatches)
Depends { name: "ClangSupport" }
Depends { name: "Qt.network" }
cpp.cxxFlags: base.concat(libclang.llvmToolingCxxFlags)
cpp.defines: base.concat(libclang.llvmToolingDefines)
cpp.includePaths: base.concat(libclang.llvmIncludeDir).concat(libclang.llvmToolingIncludes)
.concat(["source"])
cpp.libraryPaths: base.concat(libclang.llvmLibDir)
cpp.dynamicLibraries: base.concat(libclang.llvmToolingLibs)
Properties {
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos")
cpp.rpaths: base.concat(libclang.llvmLibDir)
}
files: [
"clangrefactoringbackendmain.cpp",
]
Group {
prefix: "source/"
files: [
"clangquery.cpp",
"clangquerygatherer.cpp",
"clangquerygatherer.h",
"clangquery.h",
"clangrefactoringbackend_global.h",
"clangtool.cpp",
"clangtool.h",
"collectmacrossourcefilecallbacks.cpp",
"collectmacrossourcefilecallbacks.h",
"collectsymbolsaction.cpp",
"collectsymbolsaction.h",
"collectsymbolsastvisitor.h",
"collectsymbolsconsumer.h",
"findcursorusr.h",
"findlocationsofusrs.h",
"findusrforcursoraction.cpp",
"findusrforcursoraction.h",
"locationsourcefilecallbacks.cpp",
"locationsourcefilecallbacks.h",
"macropreprocessorcallbacks.cpp",
"macropreprocessorcallbacks.h",
"refactoringcompilationdatabase.cpp",
"refactoringcompilationdatabase.h",
"refactoringserver.cpp",
"refactoringserver.h",
"sourcelocationentry.cpp",
"sourcelocationentry.h",
"sourcelocationsutils.h",
"sourcerangeextractor.cpp",
"sourcerangeextractor.h",
"sourcerangefilter.cpp",
"sourcerangefilter.h",
"storagesqlitestatementfactory.h",
"symbolentry.cpp",
"symbolentry.h",
"symbolfinder.cpp",
"symbolfinder.h",
"symbolindexer.cpp",
"symbolindexer.h",
"symbolindexing.cpp",
"symbolindexing.h",
"symbolindexinginterface.h",
"symbollocationfinderaction.cpp",
"symbollocationfinderaction.h",
"symbolscollector.cpp",
"symbolscollector.h",
"symbolscollectorinterface.h",
"symbolstorage.cpp",
"symbolstorage.h",
"symbolstorageinterface.h",
]
}
}
......@@ -5,6 +5,8 @@ Project {
references: [
"buildoutputparser/buildoutputparser.qbs",
"clangbackend/clangbackend.qbs",
"clangpchmanagerbackend/clangpchmanagerbackend.qbs",
"clangrefactoringbackend/clangrefactoringbackend.qbs",
"cplusplustools.qbs",
"qml2puppet/qml2puppet.qbs",
"qtcdebugger/qtcdebugger.qbs",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment