Cache Xcode and SDK settings in .qmake.cache if it exists
The Xcode and SDK settings are expensive to resolve, as we're using system() calls to resolve them. We now try to detect the presence of a .qmake.cache file (and inform the user that creating one would be a good idea), and use the file to cache the various settings after resolving them. The Xcode logic had to be moved form xcode.conf as part of the mkspec, into default_pre/post.prf, so that we could cache() the resolved values. Task-number: QTBUG-30586 Change-Id: Ib5368cfee6f7e4a4a33f6be70d0e20d96896fe56 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
032befa819
commit
1308aa25fb
@ -1,10 +1,6 @@
|
||||
#
|
||||
# compiler settings for iOS clang compilers
|
||||
#
|
||||
# Depends on:
|
||||
#
|
||||
# QMAKE_XCODE_VERSION - set in xcode.conf
|
||||
#
|
||||
|
||||
# iOS build flags
|
||||
QMAKE_IOS_CFLAGS += -fvisibility=hidden -fpascal-strings -fmessage-length=0
|
||||
@ -24,9 +20,6 @@ QMAKE_IOS_CFLAGS += -Wno-missing-field-initializers -Wno-missing-prototype
|
||||
QMAKE_IOS_CXXFLAGS += -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors
|
||||
QMAKE_IOS_OBJ_CFLAGS += -Wno-deprecated-implementations -Wprotocol -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector
|
||||
|
||||
# Warn about unsupported (later than 4.5) Xcode versions
|
||||
!lessThan(QMAKE_XCODE_VERSION, "4.7"): warning("The version of Xcode installed on this system is not recognised - custom compiler settings may be necessary")
|
||||
|
||||
# Set build flags
|
||||
QMAKE_CFLAGS += $$QMAKE_IOS_CFLAGS
|
||||
QMAKE_CXXFLAGS += $$QMAKE_IOS_CFLAGS $$QMAKE_IOS_CXXFLAGS
|
||||
|
@ -26,7 +26,4 @@ QMAKE_LIBS_THREAD =
|
||||
QMAKE_AR = ar cq
|
||||
QMAKE_RANLIB = ranlib -s
|
||||
|
||||
# We rely on Xcode to build
|
||||
include(xcode.conf)
|
||||
|
||||
include(unix.conf)
|
||||
|
@ -1,21 +0,0 @@
|
||||
#
|
||||
# qmake configuration for Xcode
|
||||
#
|
||||
|
||||
# Get path of Xcode's Developer directory
|
||||
QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
|
||||
isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
|
||||
error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
|
||||
|
||||
# Make sure Xcode path is valid
|
||||
!exists($$QMAKE_XCODE_DEVELOPER_PATH): \
|
||||
error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
|
||||
|
||||
# Make sure Xcode is set up properly
|
||||
isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))): \
|
||||
error("Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.")
|
||||
|
||||
# Extract Xcode version using xcodebuild
|
||||
xcode_version = $$system("/usr/bin/xcodebuild -version")
|
||||
QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
|
||||
unset(xcode_version)
|
@ -2,3 +2,9 @@
|
||||
unset(MAKEFILE_GENERATOR)
|
||||
|
||||
load(default_pre)
|
||||
|
||||
# Check for supported Xcode versions
|
||||
lessThan(QMAKE_XCODE_VERSION, "4.3"): \
|
||||
error("This mkspec requires Xcode 4.3 or later")
|
||||
!lessThan(QMAKE_XCODE_VERSION, "4.7"): \
|
||||
warning("The version of Xcode installed on this system is not recognized - custom compiler settings may be necessary")
|
||||
|
@ -16,6 +16,14 @@ qt:!isEmpty(QT_CONFIG) {
|
||||
}
|
||||
}
|
||||
|
||||
isEmpty(_QMAKE_CACHE_) {
|
||||
warning("No .qmake.cache is present. This significantly slows down qmake with this makespec.")
|
||||
warning("Call 'cache()' in the top-level project file to rectify this problem.")
|
||||
} else {
|
||||
cache(QMAKE_XCODE_DEVELOPER_PATH)
|
||||
cache(QMAKE_XCODE_VERSION)
|
||||
}
|
||||
|
||||
# Ensure that we process sdk.prf first, as it will update QMAKE_CXX
|
||||
# and friends that other features/extra compilers may depend on.
|
||||
sdk: load(sdk)
|
||||
|
@ -1,3 +1,25 @@
|
||||
CONFIG = sdk rez $$CONFIG
|
||||
load(default_pre)
|
||||
|
||||
isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
|
||||
# Get path of Xcode's Developer directory
|
||||
QMAKE_XCODE_DEVELOPER_PATH = $$system("/usr/bin/xcode-select --print-path 2>/dev/null")
|
||||
isEmpty(QMAKE_XCODE_DEVELOPER_PATH): \
|
||||
error("Xcode path is not set. Please use xcode-select to choose Xcode installation path.")
|
||||
|
||||
# Make sure Xcode path is valid
|
||||
!exists($$QMAKE_XCODE_DEVELOPER_PATH): \
|
||||
error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
|
||||
|
||||
# Make sure Xcode is set up properly
|
||||
isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))): \
|
||||
error("Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.")
|
||||
}
|
||||
|
||||
isEmpty(QMAKE_XCODE_VERSION) {
|
||||
# Extract Xcode version using xcodebuild
|
||||
xcode_version = $$system("/usr/bin/xcodebuild -version")
|
||||
QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
|
||||
isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
|
||||
unset(xcode_version)
|
||||
}
|
||||
|
@ -5,8 +5,13 @@ isEmpty(QMAKE_MAC_SDK): \
|
||||
contains(QMAKE_MAC_SDK, .*/.*): \
|
||||
error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)")
|
||||
|
||||
QMAKE_MAC_SDK_PATH = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version Path 2>/dev/null")
|
||||
isEmpty(QMAKE_MAC_SDK_PATH): error("Could not resolve SDK path for \'$$QMAKE_MAC_SDK\'")
|
||||
isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path) {
|
||||
QMAKE_MAC_SDK_PATH = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version Path 2>/dev/null")
|
||||
isEmpty(QMAKE_MAC_SDK_PATH): error("Could not resolve SDK path for \'$$QMAKE_MAC_SDK\'")
|
||||
!isEmpty(_QMAKE_CACHE_): cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path, set, QMAKE_MAC_SDK_PATH)
|
||||
} else {
|
||||
QMAKE_MAC_SDK_PATH = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path)
|
||||
}
|
||||
|
||||
!equals(MAKEFILE_GENERATOR, XCODE) {
|
||||
QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
@ -21,6 +26,11 @@ QMAKE_INCDIR_OPENGL = $$sysrootified
|
||||
|
||||
# Resolve SDK version of various tools
|
||||
for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_LINK QMAKE_LINK_SHLIB)) {
|
||||
!isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.$${tool}) {
|
||||
$$tool = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.$${tool})
|
||||
next()
|
||||
}
|
||||
|
||||
value = $$eval($$tool)
|
||||
isEmpty(value): next()
|
||||
|
||||
@ -28,15 +38,21 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_
|
||||
isEmpty(sysrooted): next()
|
||||
|
||||
$$tool = $$sysrooted $$member(value, 1, -1)
|
||||
!isEmpty(_QMAKE_CACHE_): cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.$${tool}, set, $$tool)
|
||||
}
|
||||
|
||||
# We use xml as the output format instead of json since plutil on 10.6 does not have that option
|
||||
QMAKE_MAC_PLATFORM_NAME = $$system("/usr/bin/plutil -convert xml1 \"$$QMAKE_MAC_SDK_PATH/SDKSettings.plist\" -o - 2>/dev/null | " \
|
||||
"sed '/^<!DOCTYPE/d' | " \ # Don't look up http://www.apple.com/DTDs/PropertyList-1.0.dtd
|
||||
"PERL5LIB= xpath 'string(//key[.=\"PLATFORM_NAME\"]/following-sibling::*[1])' 2>/dev/null | " \
|
||||
"sed 's/.*Value: \\(.*\\)/\\1/'")
|
||||
isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name) {
|
||||
# We use xml as the output format instead of json since plutil on 10.6 does not have that option
|
||||
QMAKE_MAC_PLATFORM_NAME = $$system("/usr/bin/plutil -convert xml1 \"$$QMAKE_MAC_SDK_PATH/SDKSettings.plist\" -o - 2>/dev/null | " \
|
||||
"sed '/^<!DOCTYPE/d' | " \ # Don't look up http://www.apple.com/DTDs/PropertyList-1.0.dtd
|
||||
"PERL5LIB= xpath 'string(//key[.=\"PLATFORM_NAME\"]/following-sibling::*[1])' 2>/dev/null | " \
|
||||
"sed 's/.*Value: \\(.*\\)/\\1/'")
|
||||
|
||||
isEmpty(QMAKE_MAC_PLATFORM_NAME): error("Could not resolve platform name for SDK '$$QMAKE_MAC_SDK'")
|
||||
isEmpty(QMAKE_MAC_PLATFORM_NAME): error("Could not resolve platform name for SDK '$$QMAKE_MAC_SDK'")
|
||||
!isEmpty(_QMAKE_CACHE_): cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name, set, QMAKE_MAC_PLATFORM_NAME)
|
||||
} else {
|
||||
QMAKE_MAC_PLATFORM_NAME = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name)
|
||||
}
|
||||
|
||||
!equals(MAKEFILE_GENERATOR, XCODE) {
|
||||
# FIXME: Get the version_min_flag out of the platform's 'Native Build System.xcspec'
|
||||
|
@ -22,6 +22,4 @@ include(../../common/clang-mac.conf)
|
||||
include(../../common/ios/clang.conf)
|
||||
include(../../common/ios/qmake.conf)
|
||||
|
||||
lessThan(QMAKE_XCODE_VERSION, "4.3"): error("This mkspec requires Xcode 4.3 or later")
|
||||
|
||||
load(qt_config)
|
||||
|
Loading…
Reference in New Issue
Block a user