summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/functions.prf
diff options
context:
space:
mode:
Diffstat (limited to 'mkspecs/features/functions.prf')
-rw-r--r--mkspecs/features/functions.prf408
1 files changed, 408 insertions, 0 deletions
diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
new file mode 100644
index 000000000..eb421f8b5
--- /dev/null
+++ b/mkspecs/features/functions.prf
@@ -0,0 +1,408 @@
+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(isMinMSVCVersion) {
+ actual = $$split(MSVC_VER, .)
+ actual_major = $$member(actual, 0)
+ actual_minor = $$member(actual, 1)
+ requested_major = $$1
+ requested_minor = $$2
+ lessThan(actual_major, $$requested_major): return(false)
+ greaterThan(actual_major, $$requested_major): return(true)
+ lessThan(actual_minor, $$requested_minor): return(false)
+ return(true)
+}
+
+defineTest(isPlatformSupported) {
+ QT_FOR_CONFIG += gui-private
+ 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 {
+ !isMinMSVCVersion(14, 0) {
+ skipBuild("Qt WebEngine on Windows requires MSVC 2015 Update 2 or later.")
+ return(false)
+ }
+ } else {
+ skipBuild("Qt WebEngine on Windows requires MSVC 2015 Update 2 or later.")
+ return(false)
+ }
+ isBuildingOnWin32() {
+ skipBuild("Qt WebEngine on Windows must be built on a 64-bit machine.")
+ }
+ !isMinWinSDKVersion(10, 10586): {
+ skipBuild("Qt WebEngine on Windows requires a Windows SDK version 10.0.10586 or newer.")
+ 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.0 (darwin version 14.0.0) or newer
+ darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0)
+ lessThan(darwin_major_version, 14) {
+ skipBuild("Qt WebEngine requires OS X version 10.10 or newer.")
+ return(false)
+ }
+ !isMinOSXSDKVersion(10, 10): {
+ skipBuild("Qt WebEngine requires an OS X SDK version of 10.10 or newer. Current version is $${WEBENGINE_OSX_SDK_PRODUCT_VERSION}.")
+ 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)
+ }
+ qtConfig(mirclient) {
+ skipBuild("Mir is not yet supported as graphics backend for Qt WebEngine.")
+ return(false)
+ }
+ static {
+ skipBuild("Static builds of QtWebEngine aren't supported.")
+ return(false)
+ }
+ !isArchSupported(): return(false)
+ isSanitizerEnabled():!isSanitizerSupported():!forceSanitizerBuild(): return(false)
+ return(true)
+}
+
+defineTest(isArchSupported) {
+ contains(QT_ARCH, "i386")|contains(QT_ARCH, "x86_64"): return(true)
+ contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true)
+ contains(QT_ARCH, "mips")|contains(QT_ARCH, "mips64"): return(true)
+
+ skipBuild("QtWebEngine can only be built for x86, x86-64, ARM, Aarch64, MIPSel, and MIPS64 architectures.")
+ return(false)
+}
+
+defineTest(isSanitizerEnabled) {
+ sanitize_address|sanitize_memory|sanitize_undefined|sanitize_thread: return(true)
+ return(false)
+}
+
+defineTest(forceSanitizerBuild) {
+ contains(WEBENGINE_CONFIG, force_sanitizer_build): return(true)
+ skipBuild("Chosen sanitizer configuration is not supported. Use WEBENGINE_CONFIG+=force_sanitizer_build to force build with the chosen sanitizer configuration.")
+ return(false)
+}
+
+defineTest(isSanitizerSupported) {
+ sanitizer_combo_supported = true
+ sanitize_address {
+ asan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux() {
+ asan_supported = true
+ } else:macos:isSanitizerSupportedOnMacOS() {
+ asan_supported = true
+ }
+ !$$asan_supported {
+ sanitizer_combo_supported = false
+ warning("An address sanitizer-enabled Qt WebEngine build can only be built on Linux or macOS using Clang and libc++.")
+ }
+ }
+
+ sanitize_memory {
+ sanitizer_combo_supported = false
+ warning("A memory sanitizer-enabled Qt WebEngine build is not supported.")
+ }
+
+ sanitize_undefined {
+ ubsan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux():CONFIG(release, debug|release):!debug_and_release {
+ ubsan_supported = true
+ }
+ !$$ubsan_supported {
+ sanitizer_combo_supported = false
+ warning("An undefined behavior sanitizer-enabled Qt WebEngine build can only be built on Linux using Clang and libc++ in release mode.")
+ }
+ }
+
+ sanitize_thread {
+ tsan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux() {
+ tsan_supported = true
+ }
+ !$$tsan_supported {
+ sanitizer_combo_supported = false
+ warning("A thread sanitizer-enabled Qt WebEngine build can only be built on Linux using Clang and libc++.")
+ }
+ }
+
+ $$sanitizer_combo_supported: return(true)
+ return(false)
+}
+
+defineTest(isSanitizerSupportedOnLinux) {
+ isSanitizerLinuxClangVersionSupported(): return(true)
+ return(false)
+}
+
+defineTest(isSanitizerSupportedOnMacOS) {
+ isEmpty(QT_APPLE_CLANG_MAJOR_VERSION) {
+ QTWEBENGINE_CLANG_IS_APPLE = false
+ } else {
+ QTWEBENGINE_CLANG_IS_APPLE = true
+ }
+ $$QTWEBENGINE_CLANG_IS_APPLE:isSanitizerMacOSAppleClangVersionSupported(): return(true)
+ else:isSanitizerMacOSClangVersionSupported(): return(true)
+ return(false)
+}
+
+defineTest(isSanitizerMacOSAppleClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from Apple Clang version 7.3.0+.
+ greaterThan(QT_APPLE_CLANG_MAJOR_VERSION, 7): return(true)
+ greaterThan(QT_APPLE_CLANG_MINOR_VERSION, 2): return(true)
+
+ warning("Using Apple Clang version $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}.$${QT_APPLE_CLANG_PATCH_VERSION}, but at least Apple Clang version 7.3.0 is required to build a sanitizer-enabled Qt WebEngine.")
+ return(false)
+}
+
+defineTest(isSanitizerMacOSClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from non-apple Clang version 3.7+.
+ greaterThan(QT_CLANG_MAJOR_VERSION, 3): return(true)
+ greaterThan(QT_CLANG_MINOR_VERSION, 6): return(true)
+
+ warning("Using Clang version $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.")
+ return(false)
+}
+
+defineTest(isSanitizerLinuxClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from Clang version 3.7+.
+ greaterThan(QT_CLANG_MAJOR_VERSION, 3): return(true)
+ greaterThan(QT_CLANG_MINOR_VERSION, 6): return(true)
+
+ warning("Using Clang version $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.")
+ 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(isDeveloperBuild) {
+ qtConfig(private_tests): return(true) # enabled for developer-build
+ return(false)
+}
+
+defineTest(isQMLTestSupportApiEnabled) {
+ isDeveloperBuild(): return(true)
+ contains(QT_BUILD_PARTS, tests): return(true)
+ contains(WEBENGINE_CONFIG, testsupport): return(true)
+ return(false)
+}
+
+defineTest(isBuildingOnWin32) {
+ # The check below is ugly, but necessary, as it seems to be the only reliable way to detect if the host
+ # architecture is 32 bit. QMAKE_HOST.arch does not work as it returns the architecture that the toolchain
+ # is building for, not the system's actual architecture.
+ PROGRAM_FILES_X86 = $$(ProgramW6432)
+ isEmpty(PROGRAM_FILES_X86): return(true)
+ return(false)
+}
+
+defineTest(isMinOSXSDKVersion) {
+ requested_major = $$1
+ requested_minor = $$2
+ requested_patch = $$3
+ isEmpty(requested_patch): requested_patch = 0
+ WEBENGINE_OSX_SDK_PRODUCT_VERSION = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null")
+ export(WEBENGINE_OSX_SDK_PRODUCT_VERSION)
+ isEmpty(WEBENGINE_OSX_SDK_PRODUCT_VERSION) {
+ skipBuild("Could not resolve SDK product version for \'$$QMAKE_MAC_SDK\'.")
+ return(false)
+ }
+ major_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 0, 0)
+ minor_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 1, 1)
+ patch_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 2, 2)
+ isEmpty(patch_version): patch_version = 0
+
+ greaterThan(major_version, $$requested_major):return(true)
+ equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true)
+ equals(major_version, $$requested_major):equals(minor_version, $$requested_minor):!lessThan(patch_version, $$requested_patch):return(true)
+
+ return(false)
+}
+
+defineTest(isMinWinSDKVersion) {
+ requested_major = $$1
+ requested_minor = $$2
+ WIN_SDK_VERSION = $$(WindowsSDKVersion)
+
+ isEmpty(WIN_SDK_VERSION)|equals(WIN_SDK_VERSION, "\\") {
+ skipBuild("Could not detect Windows SDK version (\'WindowsSDKVersion\' environment variable is not set).")
+ return(false)
+ }
+
+ # major.0.minor
+ major_version = $$section(WIN_SDK_VERSION, ., 0, 0)
+ minor_version = $$section(WIN_SDK_VERSION, ., 2, 2)
+
+ greaterThan(major_version, $$requested_major):return(true)
+ equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true)
+ equals(major_version, $$requested_major):equals(minor_version, $$requested_minor)::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) {
+ exists($$QTWEBENGINE_ROOT/.git): 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(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)
+}
+
+# Returns the unquoted path to the python executable.
+defineReplace(pythonPath) {
+ isEmpty(QMAKE_PYTHON2) {
+ # Fallback for building QtWebEngine with Qt < 5.8
+ QMAKE_PYTHON2 = python
+ }
+ return($$QMAKE_PYTHON2)
+}
+
+# Returns the python executable for use with shell / make targets.
+defineReplace(pythonPathForShell) {
+ return($$shell_quote($$shell_path($$pythonPath())))
+}
+
+# Returns the python executable for use with $$system()
+defineReplace(pythonPathForSystem) {
+ return($$system_quote($$system_path($$pythonPath())))
+}
+
+defineReplace(ninjaPath) {
+ src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
+ out = $$shadowed($$absolute_path(ninja/ninja, $$src_3rd_party_dir))
+ win32: out = $${out}.exe
+ return($$out)
+}
+
+defineReplace(gnPath) {
+ src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
+ out = $$shadowed($$absolute_path(chromium/tools/gn/out/Release/gn, $$src_3rd_party_dir))
+
+ win32: out = $${out}.exe
+ return($$out)
+}
+
+defineReplace(gnArgs) {
+ linux {
+ contains(WEBENGINE_CONFIG, embedded_build): include($$QTWEBENGINE_ROOT/src/core/config/embedded_linux.pri)
+ else: include($$QTWEBENGINE_ROOT/src/core/config/desktop_linux.pri)
+ }
+ macos: include($$QTWEBENGINE_ROOT/src/core/config/mac_osx.pri)
+ win32: include($$QTWEBENGINE_ROOT/src/core/config/windows.pri)
+ isEmpty(gn_args): error(No gn_args found please make sure you have valid configuration.)
+ return($$gn_args)
+}
+
+defineReplace(gnArch) {
+ qtArch = $$1
+ contains(qtArch, "i386"): return(x86)
+ contains(qtArch, "x86_64"): return(x64)
+ contains(qtArch, "arm"): return(arm)
+ contains(qtArch, "arm64"): return(arm64)
+ contains(qtArch, "mips"): return(mipsel)
+ contains(qtArch, "mips64"): return(mips64el)
+ return(unknown)
+}
+
+defineReplace(gnOS) {
+ macos: return(mac)
+ win32: return(win)
+ linux: return(linux)
+ error(Unsupported platform)
+ return(unknown)
+}
+
+defineTest(skipBuild) {
+ skipBuildReason = "$$skipBuildReason $${EOL}$$1"
+ export(skipBuildReason)
+}