forked from qt-creator/qt-creator
Debugger: check for python when builing cdbext with qbs
Change-Id: Ife169124f9fcd885774cd39698281e9a64e4545b Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -2,6 +2,8 @@ import qbs
|
||||
import qbs.Environment
|
||||
import qbs.File
|
||||
import qbs.FileInfo
|
||||
import qbs.Process
|
||||
import qbs.Utilities
|
||||
|
||||
QtcLibrary {
|
||||
condition: qbs.toolchain.contains("msvc") && cdbPath
|
||||
@@ -45,11 +47,95 @@ QtcLibrary {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
cpp.includePaths: [FileInfo.joinPaths(cdbPath, "inc")]
|
||||
cpp.dynamicLibraries: [
|
||||
"user32.lib",
|
||||
FileInfo.joinPaths(cdbLibPath, "dbgeng.lib")
|
||||
]
|
||||
|
||||
property string pythonInstallDir: Environment.getEnv("PYTHON_INSTALL_DIR")
|
||||
|
||||
Probe {
|
||||
id: pythonDllProbe
|
||||
condition: product.condition
|
||||
property string pythonDir: pythonInstallDir // Input
|
||||
property string buildVariant: qbs.buildVariant // Input
|
||||
property string fileNamePrefix // Output
|
||||
configure: {
|
||||
function printWarning(msg) {
|
||||
console.warn(msg + " The python dumpers for cdb will not be available.");
|
||||
}
|
||||
|
||||
if (!pythonDir) {
|
||||
printWarning("PYTHON_INSTALL_DIR not set.");
|
||||
return;
|
||||
}
|
||||
if (!File.exists(pythonDir)) {
|
||||
printWarning("The provided python installation directory '" + pythonDir
|
||||
+ "' does not exist.");
|
||||
return;
|
||||
}
|
||||
var p = new Process();
|
||||
try {
|
||||
var pythonFilePath = FileInfo.joinPaths(pythonDir, "python.exe");
|
||||
p.exec(pythonFilePath, ["--version"], true);
|
||||
var output = p.readStdOut().trim();
|
||||
var magicPrefix = "Python ";
|
||||
if (!output.startsWith(magicPrefix)) {
|
||||
printWarning("Unexpected python output when checking for version: '"
|
||||
+ output + "'");
|
||||
return;
|
||||
}
|
||||
var versionNumberString = output.slice(magicPrefix.length);
|
||||
var versionNumbers = versionNumberString.split('.');
|
||||
if (versionNumbers.length < 2) {
|
||||
printWarning("Unexpected python output when checking for version: '"
|
||||
+ output + "'");
|
||||
return;
|
||||
}
|
||||
if (Utilities.versionCompare(versionNumberString, "3.5") < 0) {
|
||||
printWarning("The python installation at '" + pythonDir
|
||||
+ "' has version " + versionNumberString + ", but 3.5 or higher "
|
||||
+ "is required.");
|
||||
return;
|
||||
}
|
||||
found = true;
|
||||
fileNamePrefix = "python" + versionNumbers[0] + versionNumbers[1];
|
||||
if (buildVariant === "debug")
|
||||
fileNamePrefix += "_d"
|
||||
} finally {
|
||||
p.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "pythonDumper"
|
||||
condition: pythonDllProbe.found
|
||||
files: [
|
||||
"pycdbextmodule.cpp",
|
||||
"pycdbextmodule.h",
|
||||
"pyfield.cpp",
|
||||
"pyfield.h",
|
||||
"pystdoutredirect.cpp",
|
||||
"pystdoutredirect.h",
|
||||
"pytype.cpp",
|
||||
"pytype.h",
|
||||
"pyvalue.cpp",
|
||||
"pyvalue.h",
|
||||
]
|
||||
}
|
||||
|
||||
cpp.defines: ["WITH_PYTHON=1"]
|
||||
cpp.includePaths: {
|
||||
var paths = [FileInfo.joinPaths(cdbPath, "inc")];
|
||||
if (pythonDllProbe.found)
|
||||
paths.push(FileInfo.joinPaths(pythonInstallDir, "include"));
|
||||
return paths;
|
||||
}
|
||||
cpp.dynamicLibraries: {
|
||||
var libs = [ "user32.lib", FileInfo.joinPaths(cdbLibPath, "dbgeng.lib") ];
|
||||
if (pythonDllProbe.found)
|
||||
libs.push(FileInfo.joinPaths(pythonInstallDir, "libs",
|
||||
pythonDllProbe.fileNamePrefix + ".lib"));
|
||||
return libs;
|
||||
}
|
||||
cpp.linkerFlags: ["/DEF:" + FileInfo.toWindowsSeparators(
|
||||
FileInfo.joinPaths(product.sourceDirectory,
|
||||
"qtcreatorcdbext.def"))]
|
||||
@@ -61,6 +147,16 @@ QtcLibrary {
|
||||
dirName += "32";
|
||||
return FileInfo.joinPaths(qtc.libDirName, dirName);
|
||||
}
|
||||
|
||||
Group {
|
||||
condition: pythonDllProbe.found
|
||||
files: [FileInfo.joinPaths(pythonInstallDir, pythonDllProbe.fileNamePrefix + ".dll")]
|
||||
qbs.install: true
|
||||
qbs.installDir: installDir
|
||||
}
|
||||
|
||||
useNonGuiPchFile: false
|
||||
|
||||
files: [
|
||||
"common.cpp",
|
||||
"common.h",
|
||||
|
Reference in New Issue
Block a user