summaryrefslogtreecommitdiffstats
path: root/Tools/qmake/mkspecs/features/functions.prf
blob: 3699d6b71794ed299e27502360872be9520dc000 (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
EOL = $$escape_expand(\\n)

WEBKIT_SUBDIR = $$relative_path($$_PRO_FILE_PWD_, $$ROOT_WEBKIT_DIR)
QTBASE_DIR = $$ROOT_WEBKIT_DIR/../qtbase

defineReplace(staticLibPath) {
    lib_basename = $${QMAKE_PREFIX_STATICLIB}$${1}$$qtPlatformTargetSuffix()
    return($$ROOT_BUILD_DIR/lib/$${lib_basename}.$$QMAKE_EXTENSION_STATICLIB)
}

defineTest(isQtMinimum) {
    !equals(QT_MAJOR_VERSION, $$1): return(false)
    count(ARGS, 1, greaterThan) {
        lessThan(QT_MINOR_VERSION, $$2): return(false)
    }
    return(true)
}

!isQtMinimum(5, 8) {
    defineTest(qtConfig) {
        contains(QT_CONFIG, $$1): return(true)
        return(false)
    }
}

defineTest(isVersionAtLeast) {
    have_version = $$split(1, .)
    want_version = $$split(2, .)
    num_components = $$size(have_version)

    # FIXME: Off-by-one. Mostly harmless, but still replace it with 0..$$num_add($$num_digits, -1) when Qt 5.7 compatibility is dropped.
    for (i, 0..$$num_components) {
        have_component = $$member(have_version, $$i)
        want_component = $$member(want_version, $$i)
        greaterThan(have_component, $$want_component): return(true)
        lessThan(have_component, $$want_component): return(false)
    }
    return(true)
}

defineReplace(cmakeVersion) {
    cmake_version_output = $$system("cmake --version", lines)
    cmake_version_string = $$first(cmake_version_output)
    # Format is "cmake version X.Y.Z"
    cmake_version_words = $$split(cmake_version_string)
    return($$last(cmake_version_words))
}

defineReplace(appleSdkVersion) {
    return($$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null"))
}

defineTest(isPlatformSupported) {
    !qtHaveModule(widgets): skipBuild("QtWidgets module is required to build QtWebKit.")

    cross_compile: skipBuild("cross-compilation of QtWebKit with qmake is not supported yet")

    requiredPrograms = cmake gperf python perl bison ruby flex
    for(program, requiredPrograms): \
        !programExistsInPath($$program): \
            skipBuild("Missing $$program from PATH")

    cmake_version = $$cmakeVersion()
    !isVersionAtLeast($$cmake_version, "2.8.12") {
        skipBuild("Using cmake version $$cmake_version, but at least cmake 2.8.12 is required to build QtWebKit.")
    }

    win32 {
        winrt {
            skipBuild("WinRT is not supported.")
        }
        msvc {
            !isVersionAtLeast($$MSVC_VER, "14.0") {
                skipBuild("QtWebKit on Windows requires MSVC 2015.")
            }
            CONFIG(debug, debug|release):!contains(QMAKE_HOST.arch, x86_64) {
                # debug_and_release is built as release, see Tools/qmake/projects/run_cmake.pro
                !debug_and_release {
                    skipBuild("QtWebKit requires 64-bit MSVC toolchain for debug build")
                }
            }
        } else {
            isGCCVersionSupported()
        }
    } else: macos {
        # We require macOS 10.10 (darwin version 14.0.0) or newer
        darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0)
        lessThan(darwin_major_version, 14) {
            skipBuild("QtWebKit requires macOS version 10.10 or newer.")
        }
        sdk_version = $$appleSdkVersion()
        !isVersionAtLeast($$sdk_version, "10.10") {
            skipBuild("QtWebKit requires an macOS SDK version of 10.10 or newer. Current version is $${sdk_version}.")
        }
    } else {
        android: skipBuild("Android is not supported.")
        uikit: skipBuild("UIKit platforms are not supported.")
        qnx: skipBuild("QNX is not supported.")

        gcc:!clang: isGCCVersionSupported()
    }

    !contains(QT_CONFIG, c++11) {
        skipBuild("C++11 support is required in order to build QtWebKit.")
    }

    isRubyVersionSupported()

    isEmpty(skipBuildReason): return(true)
    return(false)
}

defineTest(isGCCVersionSupported) {
    gcc_version = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION}
    isVersionAtLeast($$gcc_version, "4.9"): return(true)
    skipBuild("Using gcc version $$gcc_version, but at least gcc version 4.9 is required to build QtWebKit.")
    return(false)
}

defineTest(isRubyVersionSupported) {
    ruby_version = $$system("ruby -e 'puts RUBY_VERSION'")
    isVersionAtLeast($$ruby_version, "1.9"): return(true)
    skipBuild("Using Ruby version $$ruby_version, but at least Ruby 1.9 is required to build QtWebKit.")
    return(false)
}

defineTest(programExistsInPath) {
    equals(QMAKE_HOST.os, Windows): program = $${1}.exe
    else: program = $$1

    PATH = $$(PATH)
    paths = $$split(PATH, $$QMAKE_DIRLIST_SEP)

    GNUTOOLS_DIR = $$ROOT_WEBKIT_DIR/../gnuwin32/bin
    exists($$GNUTOOLS_DIR): paths += $$GNUTOOLS_DIR

    for(p, paths): exists($$p/$$program): return(true)
    return(false)
}

defineTest(skipBuild) {
    skipBuildReason = "$$skipBuildReason$${EOL}    * $$1"
    export(skipBuildReason)
}