From 3ed306772eb333fb4d9fa0b0a003c119e848ed58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 31 Aug 2018 11:43:24 +0200 Subject: macOS: Detect changes to the platform SDK and ask the user to deal with it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the SDK upgrade (or downgrade) may subtly and silently affect the resulting binary, or if it results in build breaks, the user won't know why. We limit it to applications for now, as that's the point where it's most important to catch the SDK upgrade, but technically we should also do this for intermediate libraries. Doing it for everything will likely incur a performance cost, so we skip that for now. Change-Id: I8a0604aad8b1e9fba99848ab8ab031c07fd50dc4 Reviewed-by: Morten Johan Sørvig --- mkspecs/features/mac/default_post.prf | 6 ++++++ mkspecs/features/mac/sdk.mk | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 mkspecs/features/mac/sdk.mk (limited to 'mkspecs') diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index c6eb7c5a2c..adc796f395 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -1,5 +1,11 @@ load(default_post) +# Detect changes to the platform SDK. Apps only for now +contains(TEMPLATE, .*app):!macx-xcode { + QMAKE_EXTRA_VARIABLES += QMAKE_MAC_SDK QMAKE_MAC_SDK_VERSION + QMAKE_EXTRA_INCLUDES += $$shell_quote($$PWD/sdk.mk) +} + !no_objective_c:CONFIG += objective_c qt { diff --git a/mkspecs/features/mac/sdk.mk b/mkspecs/features/mac/sdk.mk new file mode 100644 index 0000000000..a7c8268da5 --- /dev/null +++ b/mkspecs/features/mac/sdk.mk @@ -0,0 +1,12 @@ +CURRENT_MAC_SDK_VERSION := $(shell /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version) + +ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION)) + $(info The platform SDK has been changed from version $(EXPORT_QMAKE_MAC_SDK_VERSION) to version $(CURRENT_MAC_SDK_VERSION).) + $(info This requires a fresh build. Please wipe the build directory completely,) + $(info including any .qmake.stash and .qmake.cache files generated by qmake.) + # FIXME: Ideally this should be advertised as just running make distclean, or we + # should even do it automatically by having proper makefile dependencies between + # .qmake.stash and the SDK version, but as qmake doesn't seem to be consistent in + # how it deals with .qmake.stash as a dependency we need to defer that until later. + $(error ^) +endif -- cgit v1.2.3 From 4e4057460a0b27e4a8eff749fb284f61f245982e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 31 Aug 2018 12:33:08 +0200 Subject: macOS: Warn the user when using incompatible or untested platform SDKs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-70263 Change-Id: Ic946d1efc69ebb8ba65bbba956ed55ab7183957e Reviewed-by: Morten Johan Sørvig --- mkspecs/common/macx.conf | 2 ++ mkspecs/features/mac/default_post.prf | 40 +++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/common/macx.conf b/mkspecs/common/macx.conf index 4be0eb3c39..8f9eda10d7 100644 --- a/mkspecs/common/macx.conf +++ b/mkspecs/common/macx.conf @@ -5,6 +5,8 @@ QMAKE_PLATFORM += macos osx macx QMAKE_MAC_SDK = macosx +QT_MAC_SDK_VERSION_TESTED_WITH = 10.13 + device.sdk = macosx device.target = device device.dir_affix = $${device.sdk} diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index adc796f395..353fda41e6 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -1,9 +1,41 @@ load(default_post) -# Detect changes to the platform SDK. Apps only for now -contains(TEMPLATE, .*app):!macx-xcode { - QMAKE_EXTRA_VARIABLES += QMAKE_MAC_SDK QMAKE_MAC_SDK_VERSION - QMAKE_EXTRA_INCLUDES += $$shell_quote($$PWD/sdk.mk) +contains(TEMPLATE, .*app) { + !macx-xcode { + # Detect changes to the platform SDK + QMAKE_EXTRA_VARIABLES += QMAKE_MAC_SDK QMAKE_MAC_SDK_VERSION + QMAKE_EXTRA_INCLUDES += $$shell_quote($$PWD/sdk.mk) + } + + # Detect incompatible SDK versions + + !versionAtLeast(QMAKE_MAC_SDK_VERSION, $$QT_MAC_SDK_VERSION): \ + warning("Qt requires at least version $$QT_MAC_SDK_VERSION of the platform SDK," \ + "you're using $${QMAKE_MAC_SDK_VERSION}. Please upgrade.") + + !isEmpty(QT_MAC_SDK_VERSION_TESTED_WITH) { + # For Qt developers only + !isEmpty($$list($$(QT_MAC_SDK_NO_VERSION_CHECK))): \ + CONFIG += sdk_no_version_check + + !sdk_no_version_check:!versionAtMost(QMAKE_MAC_SDK_VERSION, $$QT_MAC_SDK_VERSION_TESTED_WITH) { + warning("Qt has only been tested with version $$QT_MAC_SDK_VERSION_TESTED_WITH"\ + "of the platform SDK, you're using $${QMAKE_MAC_SDK_VERSION}.") + warning("This is an unsupported configuration. You may experience build issues," \ + "and by using") + warning("the $$QMAKE_MAC_SDK_VERSION SDK you are opting in to new features" \ + "that Qt has not been prepared for.") + + isEqual(QMAKE_MAC_SDK_VERSION, 10.14): \ + warning("E.g., 10.14 enables dark mode and layer-backed views," \ + "which Qt $${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION} does not support.") + + warning("Please downgrade the SDK you use to build your app to version" \ + "$$QT_MAC_SDK_VERSION_TESTED_WITH, or configure") + warning("with CONFIG+=sdk_no_version_check when running qmake" \ + "to silence this warning.") + } + } } !no_objective_c:CONFIG += objective_c -- cgit v1.2.3