aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/imports/qbs/Probes/GccBinaryProbe.qbs
blob: 6ebaff8be27a13e7a759b53d4252ae67cdb08683 (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
import qbs.Environment
import qbs.FileInfo
import "path-probe.js" as PathProbeConfigure

BinaryProbe {
    // Inputs
    property string _compilerName
    property string _toolchainPrefix

    // Outputs
    property string tcPrefix

    platformSearchPaths: {
        var paths = base;
        if (qbs.targetOS.contains("windows") && qbs.hostOS.contains("windows"))
            paths.push(FileInfo.joinPaths(
                           Environment.getEnv("SystemDrive"), "MinGW", "bin"));
        return paths;
    }

    names: {
        var prefixes = [];
        if (_toolchainPrefix) {
            prefixes.push(_toolchainPrefix);
        } else {
            var arch = qbs.architecture;
            if (qbs.targetOS.contains("windows")) {
                if (!arch || arch === "x86") {
                    prefixes.push("mingw32-",
                                  "i686-w64-mingw32-",
                                  "i686-w64-mingw32.shared-",
                                  "i686-w64-mingw32.static-",
                                  "i686-mingw32-",
                                  "i586-mingw32msvc-");
                }
                if (!arch || arch === "x86_64") {
                    prefixes.push("x86_64-w64-mingw32-",
                                  "x86_64-w64-mingw32.shared-",
                                  "x86_64-w64-mingw32.static-",
                                  "amd64-mingw32msvc-");
                }
            }
        }
        return prefixes.map(function(prefix) {
            return prefix + _compilerName;
        }).concat([_compilerName]);
    }

    configure: {
        var result = PathProbeConfigure.configure(names, nameSuffixes, nameFilter, searchPaths,
                                                  pathSuffixes, platformSearchPaths, environmentPaths,
                                                  platformEnvironmentPaths, pathListSeparator);
        found = result.found;
        candidatePaths = result.candidatePaths;
        path = result.path;
        filePath = result.filePath;
        fileName = result.fileName;
        (nameSuffixes || [""]).forEach(function(suffix) {
            var end = _compilerName + suffix;
            if (fileName.endsWith(end))
                tcPrefix = fileName.slice(0, -end.length);
        });
    }
}