From 8fb1dbef9c6606b49371f4c7baa8a21419146990 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 19 Apr 2017 11:12:10 +0200 Subject: Move qmake files to standard locations The tools/qmake directory is a left over from webkit where qmake was but one of many buildsystems. This is not necessary for qtwebengine, so we can instead use the standard locations. Change-Id: I3d126d6627295b113b091f3eabeee25f1c1f6183 Reviewed-by: Kai Koehne Reviewed-by: Oswald Buddenhagen --- mkspecs/features/configure.prf | 213 ++++++++++++++++++++ mkspecs/features/default_pre.prf | 20 ++ mkspecs/features/functions.prf | 408 ++++++++++++++++++++++++++++++++++++++ mkspecs/features/gn_generator.prf | 244 +++++++++++++++++++++++ 4 files changed, 885 insertions(+) create mode 100644 mkspecs/features/configure.prf create mode 100644 mkspecs/features/default_pre.prf create mode 100644 mkspecs/features/functions.prf create mode 100644 mkspecs/features/gn_generator.prf (limited to 'mkspecs') diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf new file mode 100644 index 000000000..f60be817c --- /dev/null +++ b/mkspecs/features/configure.prf @@ -0,0 +1,213 @@ +# Load configure.prf from qtbase first +load(configure) +load(functions) + +defineTest(runConfigure) { + webengine_successfully_configured: return(true) + linux:contains(QT_CONFIG,no-pkg-config) { + skipBuild("pkg-config is required") + return(false) + } + # Ignore the cached config tests results in case they were not successful + CONFIG += recheck + #Override the config.tests path + QMAKE_CONFIG_TESTS_DIR = $$QTWEBENGINE_ROOT/config.tests + CONFIG_TESTS = $$files($$QMAKE_CONFIG_TESTS_DIR/*.pro, true) + log("Running configure tests$${EOL}") + for(test, CONFIG_TESTS) { + test = $$basename(test) + test ~= s/\\.pro$// + qtCompileTest($$test) + } + + isQtMinimum(5, 8) { + include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri) + QT_FOR_CONFIG += webengine-private + + qtConfig(pepper-plugins): WEBENGINE_CONFIG += use_pepper_plugins + qtConfig(printing-and-pdf): WEBENGINE_CONFIG += use_printing use_pdf + qtConfig(proprietary-codecs): WEBENGINE_CONFIG += use_proprietary_codecs + qtConfig(spellchecker): WEBENGINE_CONFIG += use_spellchecker + qtConfig(webrtc): WEBENGINE_CONFIG += use_webrtc + qtConfig(embedded): WEBENGINE_CONFIG += embedded_build + qtConfig(optimize_size): WEBENGINE_CONFIG += reduce_binary_size + qtConfig(system-webp): WEBENGINE_CONFIG += use_system_libwebp + else: WEBENGINE_CONFIG += use_bundled_libwebp + qtConfig(system-opus): WEBENGINE_CONFIG += use_system_opus + else: WEBENGINE_CONFIG += use_bundled_opus + qtConfig(system-ffmpeg): WEBENGINE_CONFIG += use_system_ffmpeg + else: WEBENGINE_CONFIG += use_bundled_ffmpeg + } else { + cross_compile: WEBENGINE_CONFIG += embedded_build reduce_binary_size + } + isQtMinimum(5, 9) { + qtConfig(appstore-compliant): WEBENGINE_CONFIG += use_appstore_compliant_code + } + + linux { + QT_FOR_CONFIG += gui-private + !config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)") + + REQUIRED_PACKAGES = dbus-1 fontconfig + !contains(WEBENGINE_CONFIG, embedded_build): qtConfig(xcb): REQUIRED_PACKAGES += libdrm xcomposite xcursor xi xrandr xtst + qtConfig(pulseaudio): REQUIRED_PACKAGES += libpulse + qtConfig(system-png): REQUIRED_PACKAGES += libpng + qtConfig(system-harfbuzz) { + packagesExist("\'harfbuzz >= 1.2.0\'"): WEBENGINE_CONFIG += use_system_harfbuzz + else: log("System harfbuzz is too old (min. version 1.2). Using Chromium's copy.$${EOL}") + } + qtConfig(glib) { + packagesExist("\'glib-2.0 >= 2.32.0\'"): WEBENGINE_CONFIG += use_glib + } + + for(package, $$list($$REQUIRED_PACKAGES)) { + !packagesExist($$package):skipBuild("Unmet dependency: $$package") + } + packagesExist(minizip, zlib): WEBENGINE_CONFIG += use_system_minizip use_system_zlib + else: log("System zlib or minizip not found. Using Chromium's copies.$${EOL}") + !isQtMinimum(5, 8) { + packagesExist(libwebp,libwebpdemux): WEBENGINE_CONFIG += use_system_libwebp use_system_libwebpdemux + else: log("System libwebp or libwebpdemux not found. Using Chromium's copies.$${EOL}") + packagesExist(opus): WEBENGINE_CONFIG += use_system_opus + else: log("System opus not found. Using Chromium's copy.$${EOL}") + } + packagesExist(libxml-2.0,libxslt) { + PKGCONFIG_LIBS_STATIC = $$system($$PKG_CONFIG --libs --static libxml-2.0) + contains(PKGCONFIG_LIBS_STATIC, -licuuc) { + WEBENGINE_CONFIG += use_system_libxslt use_system_libxml2 + } else { + log("System libxml2 is not configured with ICU. Using Chromium's copy.$${EOL}") + } + } + else: log("System libxml2 or libxslt not found. Using Chromium's copies.$${EOL}") + for(package, $$list("libevent jsoncpp protobuf")) { + packagesExist($$package): WEBENGINE_CONFIG += use_system_$$package + else { + log("System $$package not found. Using Chromium's copy.$${EOL}") + WEBENGINE_CONFIG += use_bundled_$$package + } + } + use?(system_protobuf) { + !system("which protoc > /dev/null") { + log("Protobuf compiler not found. Using Chromium's copy of protobuf.$${EOL}") + WEBENGINE_CONFIG -= use_system_protobuf + WEBENGINE_CONFIG += use_bundled_protobuf + } + } + config_libvpx: WEBENGINE_CONFIG += use_system_vpx + else { + log("Compatible system libvpx not found. Using Chromium's copy.$${EOL}") + WEBENGINE_CONFIG += use_bundled_libvpx + } + config_srtp: WEBENGINE_CONFIG += use_system_libsrtp + else { + log("System libsrtp not found. Using Chromium's copy.$${EOL}") + WEBENGINE_CONFIG += use_bundled_srtp + } + config_snappy: WEBENGINE_CONFIG += use_system_snappy + else { + log("System snappy not found. Using Chromium's copy.$${EOL}") + WEBENGINE_CONFIG += use_bundled_snappy + } + + !contains(WEBENGINE_CONFIG, embedded_build) { + packagesExist(nss): WEBENGINE_CONFIG += use_nss + else: log("System NSS not found, BoringSSL will be used.$${EOL}") + } + } + + win32 { + !config_winversion: skipBuild("Needs VS 2015 Update 3 with Cumulative Servicing Release or higher") + } + + isEmpty(skipBuildReason): { + cache(CONFIG, add, $$list(webengine_successfully_configured)) + !isEmpty(WEBENGINE_CONFIG) { + cache(WEBENGINE_CONFIG, add, $$list($$WEBENGINE_CONFIG)) + export(WEBENGINE_CONFIG) + } + # Set a global WEBENGINE_ARCH for the target architecture we can also read from option(host_build) + WEBENGINE_ARCH = $$QT_ARCH + cache(WEBENGINE_ARCH) + export(WEBENGINE_ARCH) + } + + unix:!darwin { + log("System library dependencies:$${EOL}") + use?(system_icu) { + packagesExist("icu-uc icu-i18n") { + log(" ICU ................................ Using system version$${EOL}") + } else { + log(" ICU ................................ System ICU not found$${EOL}") + skipBuild("Unmet dependencies: icu-uc, icu-i18n") + } + } else { + log(" ICU ................................ Using internal copy (Default, force system ICU with WEBENGINE_CONFIG+=use_system_icu)$${EOL}") + WEBENGINE_CONFIG += use_bundled_icu + } + !isQtMinimum(5, 8) { + use?(system_ffmpeg) { + packagesExist("libavcodec libavformat libavutil") { + packagesExist("libwebp, libwebpdemux, opus, \'vpx >= 1.4\'"){ + log(" FFMPEG ............................. Using system version$${EOL}") + } else { + log(" FFMPEG ............................. Conflicting FFMPEG dependencies$${EOL}") + skipBuild("Unmet dependencies: opus, vpx, libwebp, libwebpdemux") + } + } else { + log(" FFMPEG ............................. System FFMPEG not found$${EOL}") + skipBuild("Unmet dependencies: libavcodec, libavformat, libavutil") + } + } else { + log(" FFMPEG ............................. Using internal copy (Default, force system FFMPEG with WEBENGINE_CONFIG+=use_system_ffmpeg)$${EOL}") + WEBENGINE_CONFIG += use_bundled_ffmpeg + } + } + for(config, WEBENGINE_CONFIG) { + match = $$find(config, "^use_system_") + !isEmpty(match) { + use_system += $$replace(match, ^use_system_,) + } + match = $$find(config, "^use_bundled_") + !isEmpty(match) { + use_bundled += $$replace(match, ^use_bundled_,) + } + } + !isEmpty(use_system): log(" Optional system libraries used ..... $$use_system$${EOL}") + !isEmpty(use_bundled): log(" Optional bundled libraries used .... $$use_bundled$${EOL}") + } + log("Configurable features:$${EOL}") + use?(proprietary_codecs) { + log(" Proprietary codecs (H264, MP3) ..... Enabled$${EOL}") + } else { + log(" Proprietary codecs (H264, MP3) ..... Not enabled (Default, enable with WEBENGINE_CONFIG+=use_proprietary_codecs)$${EOL}") + } + qtHaveModule(positioning): { + log(" Geolocation ........................ Enabled$${EOL}") + } else { + log(" Geolocation ........................ Not enabled (Requires Qt Positioning module)$${EOL}") + } + unix:!darwin { + use?(nss) { + log(" Certificate handling ............... Using system NSS$${EOL}") + } else { + log(" Certificate handling ............... Using bundled BoringSSL$${EOL}") + } + } + osx { + use?(appstore_compliant_code) { + log(" Mac App Store Compliant ............ Enabled$${EOL}") + } else { + log(" Mac App Store Compliant ............ Not enabled (Default, enable with WEBENGINE_CONFIG+=use_appstore_compliant_code)$${EOL}") + } + use?(native_spellchecker) { + log("Native Spellchecker .............. Enabled$${EOL}") + } else { + log("Native Spellchecker .............. Not enabled (Default, enable with WEBENGINE_CONFIG+=use_native_spellchecker)$${EOL}") + } + !isMinOSXSDKVersion(10, 10, 3) { + log(" Force Touch API usage .............. Not enabled (Because the OS X SDK version to be used \"$${WEBENGINE_OSX_SDK_PRODUCT_VERSION}\" is lower than the required \"10.10.3\")$${EOL}") + } + } +} + diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf new file mode 100644 index 000000000..c7440fa7a --- /dev/null +++ b/mkspecs/features/default_pre.prf @@ -0,0 +1,20 @@ +QTWEBENGINEPROCESS_NAME_RELEASE = QtWebEngineProcess +debug_and_release { + QTWEBENGINEPROCESS_NAME_DEBUG = $$join(QTWEBENGINEPROCESS_NAME_RELEASE,,,d) +} else { + QTWEBENGINEPROCESS_NAME_DEBUG = $$QTWEBENGINEPROCESS_NAME_RELEASE +} +build_pass:CONFIG(debug, debug|release) { + QTWEBENGINEPROCESS_NAME = $$QTWEBENGINEPROCESS_NAME_DEBUG +} else { + QTWEBENGINEPROCESS_NAME = $$QTWEBENGINEPROCESS_NAME_RELEASE +} + +# Location of sync.profile +MODULE_BASE_DIR = $$QTWEBENGINE_ROOT + +EOL = $$escape_expand(\\n) + +# Call the original default_pre. +load(default_pre) +load(functions) 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) +} diff --git a/mkspecs/features/gn_generator.prf b/mkspecs/features/gn_generator.prf new file mode 100644 index 000000000..91c045cfa --- /dev/null +++ b/mkspecs/features/gn_generator.prf @@ -0,0 +1,244 @@ +load(moc) +load(resources) + +defineReplace(getTargetType) { + equals(TEMPLATE, "app"):return("executable") + equals(TEMPLATE, "lib") { + CONFIG(static): return("static_library") + return("shared_library") + } + return("none") +} + +defineReplace(filter_flag_values) { + value_to_check = $$1 + macos:equals(value_to_check, "$(EXPORT_ARCH_ARGS)") { + # EXPORT_ARCH_ARGS comes from qtbase/mkspecs/features/mac/default_post.prf which is a way + # to figure out the architectures to pass to the compiler at Makefile time. Because this + # variable expansion is not supported by GN, we filter it out. GN takes care of assigning + # the architecture itself. + return("") + } + return($$value_to_check) +} + +isEmpty(GN_FILE): GN_FILE = $$system_path($$_PRO_FILE_PWD_/BUILD.gn) +isEmpty(GN_RUN_BINARY_SCRIPT): GN_RUN_BINARY_SCRIPT = "//build/gn_run_binary.py" +isEmpty(GN_FIND_MOCABLES_SCRIPT): GN_FIND_MOCABLES_SCRIPT = "//build/gn_find_mocables.py" + +# MOC SETUP + +GN_CONTENTS += "moc_source_h_files = exec_script(\"$$GN_FIND_MOCABLES_SCRIPT\"," +GN_CONTENTS += " [ \"$$_PRO_FILE_PWD_\"," +for (headerfile, HEADERS): GN_CONTENTS += " \"$$GN_SRC_DIR/$$headerfile\"," +GN_CONTENTS += " ], \"list lines\", [\"$$system_path($$_PRO_FILE_)\"]"\ + ")" +GN_CONTENTS += "moc_source_cpp_files = exec_script(\"$$GN_FIND_MOCABLES_SCRIPT\"," +GN_CONTENTS += " [ \"$$_PRO_FILE_PWD_\"," +for (sourcefile, SOURCES): GN_CONTENTS += " \"$$GN_SRC_DIR/$$sourcefile\"," +GN_CONTENTS += " ], \"list lines\", [\"$$system_path($$_PRO_FILE_)\"]"\ + ")" + +DEFINES_LIST = $$join(DEFINES, " -D", "-D") +INCLUDE_LIST = $$join(INCLUDEPATH, " -I", "-I") + +# we don't generate a moc_predef file yet. +MOC_PREDEF_FILE = +MOC_COMMAND = $$clean_path($$mocCmdBase()) +MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(DEFINES)"), $$DEFINES_LIST) +MOC_COMMAND = $$replace(MOC_COMMAND, $$re_escape("$(INCPATH)"), $$INCLUDE_LIST) +MOC_COMMAND = $$eval($$list($$MOC_COMMAND)) + +GN_CONTENTS += "if (moc_source_h_files != []) {" +GN_CONTENTS += " action_foreach(\"generate_h_mocs\") {"\ + " script = \"$$GN_RUN_BINARY_SCRIPT\"" +GN_CONTENTS += " sources = moc_source_h_files" \ + " outputs = [ \"$target_gen_dir/.moc/moc_{{source_name_part}}.cpp\" ]" +GN_CONTENTS += " inputs = [ \"$$system_path($$_PRO_FILE_)\" ]" \ + " args = [" +for(token, MOC_COMMAND): GN_CONTENTS += " \"$$replace(token,\",\\\")\"," +GN_CONTENTS += " \"{{source}}\"," \ + " \"-o\"," \ + " rebase_path(\"$target_gen_dir/.moc/moc_{{source_name_part}}.cpp\")"\ + " ]" +GN_CONTENTS += " }" +GN_CONTENTS += "}" +GN_CONTENTS += "if (moc_source_cpp_files != []) {" +GN_CONTENTS += " action_foreach(\"generate_cpp_mocs\") {"\ + " script = \"$$GN_RUN_BINARY_SCRIPT\"" +GN_CONTENTS += " sources = moc_source_cpp_files" \ + " outputs = [ \"$target_gen_dir/.moc/{{source_name_part}}.moc\" ]" +GN_CONTENTS += " inputs = [ \"$$system_path($$_PRO_FILE_)\" ]" \ + " args = [" +for(token, MOC_COMMAND): GN_CONTENTS += " \"$$replace(token,\",\\\")\"," +GN_CONTENTS += " \"{{source}}\"," \ + " \"-o\"," \ + " rebase_path(\"$target_gen_dir/.moc/{{source_name_part}}.moc\")"\ + " ]" +GN_CONTENTS += " }" +GN_CONTENTS += "}" + +# RESOURCES SETUP + +CLEAN_QMAKE_RCC = $$clean_path($$QMAKE_RCC) + +GN_CONTENTS += "action_foreach(\"generate_resources\") {"\ + " script = \"$$GN_RUN_BINARY_SCRIPT\"" +GN_CONTENTS += " sources = [" +for (sourcefile, RESOURCES): GN_CONTENTS += " \"$$GN_SRC_DIR/$$sourcefile\"," +GN_CONTENTS += " ]" \ + " outputs = [ \"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\" ]" +GN_CONTENTS += " inputs = [ \"$$system_path($$_PRO_FILE_)\" ]" \ + " args = [" \ + " \"$$replace(CLEAN_QMAKE_RCC,\",\\\")\"," +for(resource_flag, $$QMAKE_RESOURCE_FLAGS): GN_CONTENTS += " \"$$resource_flag\"" +GN_CONTENTS += " \"-name\"," \ + " \"{{source_name_part}}\"," \ + " \"{{source}}\"," \ + " \"-o\"," \ + " rebase_path(\"$target_gen_dir/.rcc/qrc_{{source_name_part}}.cpp\")"\ + " ]" +GN_CONTENTS += "}" + +# TARGET SETUP + +TARGET_TYPE = $$getTargetType() + +GN_CONTENTS += "$${TARGET_TYPE}(\"$$TARGET\") {" +!isEmpty(GN_CREATE_PRI): GN_CONTENTS += " create_pri_file = $$GN_CREATE_PRI" +!isEmpty(GN_IMPORTS) { +for (imp, GN_IMPORTS): GN_CONTENTS += " import(\"$$imp\")" +} + +!isEmpty(QMAKE_CFLAGS) { + GN_CONTENTS += " cflags = [" + for(flag, QMAKE_CFLAGS): GN_CONTENTS += " \"$$filter_flag_values($$flag)\"," + GN_CONTENTS += " ]" +} + +!isEmpty(QMAKE_FRAMEWORKPATH) { + GN_CONTENTS += " cflags += [" + for(path, QMAKE_FRAMEWORKPATH): GN_CONTENTS += " \"-F$$path\"," + GN_CONTENTS += " ]" +} + +# Stop the barrage of unused variables warnings. +gcc|clang { + QMAKE_CXXFLAGS += "-Wno-unused-parameter" + QMAKE_CXXFLAGS += "-Wno-unused-variable" +} else:msvc { + QMAKE_CXXFLAGS += /wd4100 /wd4101 +} + +!isEmpty(QMAKE_CXXFLAGS) { + GN_CONTENTS += " cflags_cc = [" + for(flag, QMAKE_CXXFLAGS): GN_CONTENTS += " \"$$filter_flag_values($$flag)\"," + GN_CONTENTS += " ]" +} + +GN_CONTENTS += " if (!defined(defines)) {"\ + " defines = []"\ + " }" +GN_CONTENTS += " defines += [" +# Remove single quotes around function macro defines, so that GN doesn't escape them, thus breaking +# the macro. +# Also add a layer of escaping for double quotes. +for (define, DEFINES): { + define = $$replace(define,\",\\\") + define = $$replace(define,\',) + GN_CONTENTS += " \"$$define\"," +} +!isEmpty(QT_SYSROOT) { + !isEmpty(QMAKE_LIBDIR_EGL): + GN_CONTENTS += " \"QT_LIBDIR_EGL=\\\"$${QMAKE_DIR_SEP}$$relative_path($$QMAKE_LIBDIR_EGL, $$[QT_SYSROOT])\\\"\"," + !isEmpty(QMAKE_LIBDIR_OPENGL_ES2) + GN_CONTENTS += " \"QT_LIBDIR_GLES2=\\\"$${QMAKE_DIR_SEP}$$relative_path($$QMAKE_LIBDIR_OPENGL_ES2, $$[QT_SYSROOT])\\\"\"," +} else { + !isEmpty(QMAKE_LIBDIR_EGL): + GN_CONTENTS += " \"QT_LIBDIR_EGL=\\\"$$QMAKE_LIBDIR_EGL\\\"\"," + !isEmpty(QMAKE_LIBDIR_OPENGL_ES2) + GN_CONTENTS += " \"QT_LIBDIR_GLES2=\\\"$$QMAKE_LIBDIR_OPENGL_ES2\\\"\"," +} +GN_CONTENTS += " ]" + +# Source files to compile +GN_CONTENTS += " sources = [" +for (sourcefile, SOURCES): GN_CONTENTS += " \"$$GN_SRC_DIR/$$sourcefile\"," +for (headerfile, HEADERS): GN_CONTENTS += " \"$$GN_SRC_DIR/$$headerfile\"," +GN_CONTENTS += " ]" + +# Add Sources generated by rcc from qrc files. +!isEmpty(RESOURCES): GN_CONTENTS += " sources += get_target_outputs(\":generate_resources\")" + +GN_CONTENTS += " if (!defined(include_dirs)) {"\ + " include_dirs = []"\ + " }" +GN_CONTENTS += " include_dirs += [" +for (path, INCLUDEPATH): GN_CONTENTS += " \"$$path\"," +GN_CONTENTS += " rebase_path(\"$target_gen_dir/.moc/\")" +GN_CONTENTS += " ]" + +GN_CONTENTS += " if (!defined(ldflags)) {"\ + " ldflags = []"\ + " }" +GN_CONTENTS += " ldflags += [" +for (flag, QMAKE_LFLAGS): GN_CONTENTS += " \"$$filter_flag_values($$flag)\"," +for (flag, GN_FLAGS): GN_CONTENTS += " \"$$flag\"," +!isEmpty(QMAKE_RPATHDIR) { + for (rpath, QMAKE_RPATHDIR) { + macos: GN_CONTENTS += " \"-Wl,-rpath,$${rpath}\"," + else:unix: GN_CONTENTS += " \"-Wl,-rpath=$${rpath}\"," + } +} +!isEmpty(QMAKE_RPATHLINKDIR): GN_CONTENTS += " \"-Wl,-rpath-link=$${QMAKE_RPATHLINKDIR}\"," +GN_CONTENTS += " ]" + +GN_CONTENTS += " if (!defined(lib_dirs)) {"\ + " lib_dirs = []"\ + " }" +GN_CONTENTS += " lib_dirs += [" +lib_dirs = $$find(LIBS, ^-L.*) +lib_dirs = $$unique(lib_dirs) +for (lib_dir, lib_dirs): GN_CONTENTS += " \"$$replace(lib_dir, -L, )\"," +GN_CONTENTS += " ]" + +GN_CONTENTS += " if (!defined(libs)) {"\ + " libs = []"\ + " }" +GN_CONTENTS += " libs += [" +for (lib, GN_LIBS): GN_CONTENTS += " \"$$lib\"," +libs = $$find(LIBS, ^-l.*) +libs = $$unique(libs) +for (lib, libs): GN_CONTENTS += " \"$$replace(lib, -l, )\"," +GN_CONTENTS += " ]" + +GN_CONTENTS += " if (!defined(deps)) {"\ + " deps = []"\ + " }" +GN_CONTENTS += " deps += [" +!isEmpty(RESOURCES): GN_CONTENTS += " \":generate_resources\"," +GN_CONTENTS += " ]" +GN_CONTENTS += " if (moc_source_h_files != []) {" +GN_CONTENTS += " deps += [" +GN_CONTENTS += " \":generate_h_mocs\"," +GN_CONTENTS += " ]" +# Add moc output files to compile +GN_CONTENTS += " sources += get_target_outputs(\":generate_h_mocs\")" +GN_CONTENTS += " }" +GN_CONTENTS += " if (moc_source_cpp_files != []) {" +GN_CONTENTS += " deps += [" +GN_CONTENTS += " \":generate_cpp_mocs\"," +GN_CONTENTS += " ]" +GN_CONTENTS += " }" +GN_CONTENTS += "}" +!isEmpty(GN_INCLUDES) { + for (inc, GN_INCLUDES): GN_CONTENTS += $$cat($$inc,lines) +} + +build_pass|!debug_and_release: write_file($$GN_FILE, GN_CONTENTS) + +# The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary +TEMPLATE = aux +SOURCES = +HEADERS = +RESOURCES = -- cgit v1.2.3 From ce5d960aee8876fc3b879b98cf4699f3e131f4b7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 May 2017 10:32:23 +0200 Subject: Use qtbase optimize_size configure option The optimize-size configure option got landed generally in qtbase, so respond to that instead of doing our own. Change-Id: I8bfcf494a6f0d599bf375ae4ea73ce86ee02216b Reviewed-by: Oswald Buddenhagen Reviewed-by: Kai Koehne --- mkspecs/features/configure.prf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mkspecs') diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf index f60be817c..9b0be0140 100644 --- a/mkspecs/features/configure.prf +++ b/mkspecs/features/configure.prf @@ -30,7 +30,6 @@ defineTest(runConfigure) { qtConfig(spellchecker): WEBENGINE_CONFIG += use_spellchecker qtConfig(webrtc): WEBENGINE_CONFIG += use_webrtc qtConfig(embedded): WEBENGINE_CONFIG += embedded_build - qtConfig(optimize_size): WEBENGINE_CONFIG += reduce_binary_size qtConfig(system-webp): WEBENGINE_CONFIG += use_system_libwebp else: WEBENGINE_CONFIG += use_bundled_libwebp qtConfig(system-opus): WEBENGINE_CONFIG += use_system_opus @@ -42,6 +41,9 @@ defineTest(runConfigure) { } isQtMinimum(5, 9) { qtConfig(appstore-compliant): WEBENGINE_CONFIG += use_appstore_compliant_code + optimize_size: WEBENGINE_CONFIG += reduce_binary_size + } else { + qtConfig(embedded): WEBENGINE_CONFIG += reduce_binary_size } linux { -- cgit v1.2.3