aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qtcreatorcdbext/qtcreatorcdbext.qbs
blob: 91e91bc8514a5c5acc98d2bea0f1d32d8158c433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import qbs
import qbs.Environment
import qbs.File
import qbs.FileInfo
import qbs.Process
import qbs.Utilities

QtcLibrary {
    condition: qbs.toolchain.contains("msvc")
    name: "qtcreatorcdbext"
    targetName: name

    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;
                }
                var pythonMinVersion = "3.8";
                if (Utilities.versionCompare(versionNumberString, pythonMinVersion) < 0) {
                    printWarning("The python installation at '" + pythonDir
                                 + "' has version " + versionNumberString + ", but "
                                 + pythonMinVersion + " 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",
        ]
    }

    Properties {
        condition: pythonDllProbe.found
        cpp.defines: ["WITH_PYTHON=1", "PY_SSIZE_T_CLEAN"]
    }
    cpp.includePaths: {
        if (pythonDllProbe.found)
            return [ FileInfo.joinPaths(pythonInstallDir, "include") ];
        return [ ];
    }
    cpp.dynamicLibraries: {
        var libs = [ "user32.lib", "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"))]
    installDir: {
        var dirName = name;
        if (qbs.architecture.contains("x86_64"))
            dirName += "64";
        else
            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",
        "containers.cpp",
        "containers.h",
        "eventcallback.cpp",
        "eventcallback.h",
        "extensioncontext.cpp",
        "extensioncontext.h",
        "gdbmihelpers.cpp",
        "gdbmihelpers.h",
        "iinterfacepointer.h",
        "knowntype.h",
        "outputcallback.cpp",
        "outputcallback.h",
        "qtcreatorcdbextension.cpp",
        "stringutils.cpp",
        "stringutils.h",
        "symbolgroup.cpp",
        "symbolgroup.h",
        "symbolgroupnode.cpp",
        "symbolgroupnode.h",
        "symbolgroupvalue.cpp",
        "symbolgroupvalue.h",
    ]
}