summaryrefslogtreecommitdiffstats
path: root/tools/qmake/mkspecs/features/functions.prf
blob: a4abf458ce01ce365411608a40778733830ba193 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
defineTest(isPlatformSupported) {
  linux {
    !gcc:!clang {
      skipBuild("Qt WebEngine on Linux requires clang or GCC.")
      return(false)
    }
    gcc:!clang:!isGCCVersionSupported(): return(false)
  } else:win32 {
    winrt {
      skipBuild("WinRT is not supported.")
      return(false)
    }
    msvc {
      !equals(MSVC_VER, "12.0"):!equals(MSVC_VER, "14.0") {
        skipBuild("Qt WebEngine on Windows requires MSVC 2013 or MSVC 2015.")
        return(false)
      }
    } else {
      skipBuild("Qt WebEngine on Windows requires MSVC 2013 or MSVC 2015.")
      return(false)
    }
  } else:osx {
    lessThan(QMAKE_XCODE_VERSION, 5.1) {
      skipBuild("Using XCode version $$QMAKE_XCODE_VERSION, but at least version 5.1 is required to build Qt WebEngine.")
      return(false)
    }
    # We require OS X 10.9 (darwin version 13.0.0) or newer
    darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0)
    lessThan(darwin_major_version, 13) {
      skipBuild("Qt WebEngine requires OS X version 10.9 or newer.")
      return(false)
    }
  } else {
    skipBuild("Unknown platform. Qt WebEngine only supports Linux, Windows, and OS X.")
    return(false)
  }

  !contains(QT_CONFIG, c++11) {
    skipBuild("C++11 support is required in order to build chromium.")
    return(false)
  }
  static {
    skipBuild("Static builds of QtWebEngine aren't supported.")
    return(false)
  }
  !isPythonVersionSupported(): return(false)
  return(true)
}

defineTest(isPythonVersionSupported) {
    python_error_msg = "Python version 2 (2.7 or later) is required to build Qt WebEngine."
    python_major_version = $$system('python -c "import sys; print(sys.version_info[0])"')
    greaterThan(python_major_version, 2) {
        skipBuild("Python version 3 is not supported by Chromium.")
        skipBuild($$python_error_msg)
        return(false)
    }
    python_minor_version = $$system('python -c "import sys; print(sys.version_info[1])"')
    greaterThan(python_major_version, 1): greaterThan(python_minor_version, 6): return(true)
    skipBuild("Using Python version "$$python_major_version"."$$python_minor_version".")
    skipBuild($$python_error_msg)
    return(false)
}

defineTest(isGCCVersionSupported) {
  # The below will work for gcc 4.7 and up and also match gcc 5
  greaterThan(QT_GCC_MINOR_VERSION, 6):return(true)
  greaterThan(QT_GCC_MAJOR_VERSION, 4):return(true)
  skipBuild("Using gcc version "$$QT_GCC_MAJOR_VERSION"."$$QT_GCC_MINOR_VERSION", but at least gcc version 4.7 is required to build Qt WebEngine.")
  return(false)
}

defineTest(isQMLTestSupportApiEnabled) {
    contains(QT_CONFIG, private_tests): return(true) # enable for developer-build
    contains(QT_BUILD_PARTS, tests): return(true)
    contains(WEBENGINE_CONFIG, testsupport): return(true)
    return(false)
}

# Map to the correct target type for gyp
defineReplace(toGypTargetType) {
  equals(TEMPLATE, "app"):return("executable")
  equals(TEMPLATE, "lib") {
    CONFIG(static): return("static_library")
    return("shared_library")
  }
  return("none")
}

defineReplace(getConfigDir) {
  win32:contains(QMAKE_TARGET.arch, x86_64) {
      CONFIG(release, debug|release):return("Release_x64")
      return("Debug_x64")
  }

  CONFIG(release, debug|release):return("Release")
  return("Debug")
}

defineReplace(getChromiumSrcDir) {
  git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
  # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
  isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
  return($$git_chromium_src_dir)
}

defineReplace(extractCFlag) {
    CFLAGS = $$QMAKE_CC $$QMAKE_CFLAGS
    OPTION = $$find(CFLAGS, $$1)
    OPTION = $$split(OPTION, =)
    return ($$member(OPTION, 1))
}

defineReplace(findMocables) {
  mocables = $$system("$$system_path(python $$QTWEBENGINE_ROOT/tools/buildscripts/find-mocables $$_PRO_FILE_PWD_ $$1)")
  mocables = $$replace(mocables, $$re_escape($$system_path($${_PRO_FILE_PWD_}/)), '')
  return($$mocables)
}

defineReplace(findIncludedMocFiles) {
  return($$system("$$system_path(python $$QTWEBENGINE_ROOT/tools/buildscripts/find-included-moc-files $$_PRO_FILE_PWD_ $$1)"))
}

defineReplace(mocOutput) {
  out = $$1
  # The order is important, since the output of the second replace would end up accidentaly transformed by the first one
  for(ext, $$list($${QMAKE_EXT_CPP})): \
      out = $$replace(out, ^(.*)($$re_escape($${ext})), $${QMAKE_CPP_MOD_MOC}\\1$${QMAKE_EXT_CPP_MOC})
  for(ext, $$list($${QMAKE_EXT_H})): \
      out = $$replace(out, ^(.*)($$re_escape($${ext})), $${QMAKE_H_MOD_MOC}\\1$${first(QMAKE_EXT_CPP)})
  return($$out)
}

defineReplace(rccOutput) {
  out = $$1
  out = $$replace(out, .qrc, .cpp)
  out = $$join(out, qrc_, qrc_)
  return($$out)
}

defineReplace(rccExternFunc) {
  out = $$1
  out = $$replace(out, .qrc, )
  return($$out)
}

defineReplace(which) {
  out = $$1
  win32 {
    command = $$split(out, " ")
    executable = $$first(command)
    # Return the first match only
    out = $$system("((for /f \"usebackq delims=\" %i in (`where $$executable 2^> NUL`) do @if not defined _endwhich (@echo %i & set _endwhich=true)) & set _endwhich=)")
    isEmpty(out) {
      message($$executable not found)
      out = $$executable
    }
    for(arg, command): !equals(arg, $$executable): out += $$arg
  } else:unix {
    command = $$split(out, " ")
    executable = $$first(command)
    out = $$system("which $$executable 2>/dev/null")
    isEmpty(out) {
      message($$executable not found)
      out = $$executable
    }
    for(arg, command): !equals(arg, $$executable): out += $$arg
  }
  return($$out)
}

defineTest(use?) {
    contains(WEBENGINE_CONFIG, use_$$lower($$1)): return(true)
    return(false)
}

defineReplace(findOrBuildNinja) {
  # If NINJA_PATH env var is set, prefer that.
  # Fallback to locating our own bootstrapped ninja.
  out = $(NINJA_PATH)
  !exists($$out) {
    src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")

    out = $$shadowed($$absolute_path("ninja/ninja", "$$src_3rd_party_dir"))
    win32: out = $${out}.exe

    out = $$system_path($$out)
    # If we did not find ninja, then we bootstrap it.
    !exists($$out) {
      # If we are making a shadow build, copy the ninja sources to the build directory.
      !equals(PWD, $${OUT_PWD}) {
        log("Build directory is different from source directory - copying ninja sources to the build tree...")
        shadow_3rd_party_path = $$system_path($$shadowed($$src_3rd_party_dir))

        !exists($$dirname(out)): mkpath($$dirname(out))
        copy_dir_files {
          system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$dirname(out))")
        } else {
          system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$shadow_3rd_party_path)")
        }
      }
      system("cd $$system_quote($$dirname(out)) && python configure.py --bootstrap")
    }
  }
  return($$out)
}

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