summaryrefslogtreecommitdiff
path: root/qbs/modules/libclang/libclang.qbs
blob: 1d695a2c8d5da46f854506e4089411e01eb7a319 (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
import qbs
import qbs.Environment
import qbs.File
import qbs.Utilities
import QtcFunctions
import "functions.js" as ClangFunctions

Module {
    Probe {
        id: clangProbe

        property stringList hostOS: qbs.hostOS
        property stringList targetOS: qbs.targetOS

        property string llvmConfig
        property string llvmVersion
        property string llvmIncludeDir
        property string llvmLibDir
        property string llvmBinDir
        property stringList llvmLibs
        property stringList llvmToolingLibs
        property stringList llvmToolingDefines
        property stringList llvmToolingIncludes
        property stringList llvmToolingCxxFlags
        property stringList llvmFormattingLibs
        property string llvmBuildMode

        configure: {
            llvmConfig = ClangFunctions.llvmConfig(hostOS, QtcFunctions);
            llvmVersion = ClangFunctions.version(llvmConfig);
            llvmIncludeDir = ClangFunctions.includeDir(llvmConfig);
            llvmLibDir = ClangFunctions.libDir(llvmConfig);
            llvmBinDir = ClangFunctions.binDir(llvmConfig);
            llvmLibs = ClangFunctions.libraries(targetOS);
            llvmToolingLibs = ClangFunctions.toolingLibs(llvmConfig, targetOS);
            llvmBuildMode = ClangFunctions.buildMode(llvmConfig);
            var toolingParams = ClangFunctions.toolingParameters(llvmConfig);
            llvmToolingDefines = toolingParams.defines;
            llvmToolingIncludes = toolingParams.includes;
            llvmToolingCxxFlags = toolingParams.cxxFlags;
            llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, targetOS);
            found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
        }
    }

    property string llvmConfig: clangProbe.llvmConfig
    property string llvmVersion: clangProbe.llvmVersion
    property string llvmIncludeDir: clangProbe.llvmIncludeDir
    property string llvmLibDir: clangProbe.llvmLibDir
    property string llvmBinDir: clangProbe.llvmBinDir
    property stringList llvmLibs: clangProbe.llvmLibs
    property stringList llvmToolingLibs: clangProbe.llvmToolingLibs
    property stringList llvmFormattingLibs: clangProbe.llvmFormattingLibs
    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_ENABLE_CLANG_LIBTOOLING")

    validate: {
        if (!clangProbe.found) {
            console.warn("No usable libclang version found."
                         + " Set LLVM_INSTALL_DIR to build the Clang Code Model."
                         + " For details, see"
                         + " doc/src/editors/creator-only/creator-clang-codemodel.qdoc.");
            throw new Error();
        }
    }
}