Skip to content

Commit

Permalink
macOS: Detect changes to the platform SDK and ask the user to deal wi…
Browse files Browse the repository at this point in the history
…th it

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 <[email protected]>
  • Loading branch information
torarnv committed Aug 31, 2018
1 parent 5b6eb8e commit 3ed3067
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mkspecs/features/mac/default_post.prf
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions mkspecs/features/mac/sdk.mk
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3ed3067

Please sign in to comment.