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

Change-Id: I4882be50c6b007715f7b281f95d111abc5cda62a
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Christian Kandeler
2017-09-29 15:04:05 +02:00
parent 640ba75dfb
commit 3bcbcfa626
8 changed files with 393 additions and 0 deletions

View File

@@ -14,6 +14,11 @@ function readOutput(executable, args)
return output; return output;
} }
function readListOutput(executable, args)
{
return readOutput(executable, args).split(/\s+/);
}
function isSuitableLLVMConfig(llvmConfigCandidate, qtcFunctions) function isSuitableLLVMConfig(llvmConfigCandidate, qtcFunctions)
{ {
if (File.exists(llvmConfigCandidate)) { if (File.exists(llvmConfigCandidate)) {
@@ -75,3 +80,66 @@ function libraries(targetOS)
{ {
return targetOS.contains("windows") ? ["libclang.lib", "advapi32.lib", "shell32.lib"] : ["clang"] 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"]);
}

View File

@@ -1,5 +1,7 @@
import qbs import qbs
import qbs.Environment
import qbs.File import qbs.File
import qbs.Utilities
import QtcFunctions import QtcFunctions
import "functions.js" as ClangFunctions import "functions.js" as ClangFunctions
@@ -12,6 +14,11 @@ Module {
property string llvmIncludeDir property string llvmIncludeDir
property string llvmLibDir property string llvmLibDir
property stringList llvmLibs property stringList llvmLibs
property stringList llvmToolingLibs
property stringList llvmToolingDefines
property stringList llvmToolingIncludes
property stringList llvmToolingCxxFlags
property string llvmBuildMode
configure: { configure: {
llvmConfig = ClangFunctions.llvmConfig(qbs, QtcFunctions); llvmConfig = ClangFunctions.llvmConfig(qbs, QtcFunctions);
@@ -19,6 +26,12 @@ Module {
llvmIncludeDir = ClangFunctions.includeDir(llvmConfig); llvmIncludeDir = ClangFunctions.includeDir(llvmConfig);
llvmLibDir = ClangFunctions.libDir(llvmConfig); llvmLibDir = ClangFunctions.libDir(llvmConfig);
llvmLibs = ClangFunctions.libraries(qbs.targetOS); 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")); found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
} }
} }
@@ -28,6 +41,17 @@ Module {
property string llvmIncludeDir: clangProbe.llvmIncludeDir property string llvmIncludeDir: clangProbe.llvmIncludeDir
property string llvmLibDir: clangProbe.llvmLibDir property string llvmLibDir: clangProbe.llvmLibDir
property stringList llvmLibs: clangProbe.llvmLibs 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: { validate: {
if (!clangProbe.found) { if (!clangProbe.found) {

View File

@@ -0,0 +1,48 @@
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",
]
}

View File

@@ -0,0 +1,80 @@
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",
]
}

View File

@@ -13,6 +13,8 @@ Project {
"bineditor/bineditor.qbs", "bineditor/bineditor.qbs",
"bookmarks/bookmarks.qbs", "bookmarks/bookmarks.qbs",
"clangcodemodel/clangcodemodel.qbs", "clangcodemodel/clangcodemodel.qbs",
"clangpchmanager/clangpchmanager.qbs",
"clangrefactoring/clangrefactoring.qbs",
"clangstaticanalyzer/clangstaticanalyzer.qbs", "clangstaticanalyzer/clangstaticanalyzer.qbs",
"classview/classview.qbs", "classview/classview.qbs",
"clearcase/clearcase.qbs", "clearcase/clearcase.qbs",

View File

@@ -0,0 +1,83 @@
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",
]
}
}

View File

@@ -0,0 +1,86 @@
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",
]
}
}

View File

@@ -5,6 +5,8 @@ Project {
references: [ references: [
"buildoutputparser/buildoutputparser.qbs", "buildoutputparser/buildoutputparser.qbs",
"clangbackend/clangbackend.qbs", "clangbackend/clangbackend.qbs",
"clangpchmanagerbackend/clangpchmanagerbackend.qbs",
"clangrefactoringbackend/clangrefactoringbackend.qbs",
"cplusplustools.qbs", "cplusplustools.qbs",
"qml2puppet/qml2puppet.qbs", "qml2puppet/qml2puppet.qbs",
"qtcdebugger/qtcdebugger.qbs", "qtcdebugger/qtcdebugger.qbs",