Allow using Xcode Command Line Tools to build Qt

Some users don't want to download the full Xcode installation which can
weigh upwards of 5 GB download and 20 GB installed.

[ChangeLog][macOS / iOS] Qt can now be built using just the Xcode
Command Line Tools, without needing to install the full Xcode IDE.

Task-number: QTBUG-35928
Task-number: QTBUG-41908
Change-Id: I6d13c9a03ab9087b3ab56e8547f53f0cc2806c7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Jake Petroules 2017-06-07 16:42:47 -07:00
parent 3c89c71da5
commit fa7626713b
6 changed files with 53 additions and 30 deletions

17
configure vendored
View File

@ -234,7 +234,7 @@ macSDKify()
sdk=$(getSingleQMakeVariable "QMAKE_MAC_SDK" "$1")
if [ -z "$sdk" ]; then echo "QMAKE_MAC_SDK must be set when building on Mac" >&2; exit 1; fi
sysroot=$(/usr/bin/xcodebuild -sdk $sdk -version Path 2>/dev/null)
sysroot=$(/usr/bin/xcrun --sdk $sdk --show-sdk-path 2>/dev/null)
if [ -z "$sysroot" ]; then echo "Failed to resolve SDK path for '$sdk'" >&2; exit 1; fi
case "$sdk" in
@ -322,20 +322,25 @@ fi
if [ "$BUILD_ON_MAC" = "yes" ]; then
if ! /usr/bin/xcode-select --print-path >/dev/null 2>&1; then
echo >&2
echo " No Xcode is selected. Use xcode-select -switch to choose an Xcode" >&2
echo " version. See the xcode-select man page for more information." >&2
echo " No Xcode selected. Please install Xcode via the App Store, " >&2
echo " or the command line developer tools via xcode-select --install, " >&2
echo " and use xcode-select --switch to choose the right installation. " >&2
echo " See the xcode-select man page for more information." >&2
echo >&2
exit 2
fi
if ! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then
# In the else case we are probably using a Command Line Tools installation
if /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then
if ! /usr/bin/xcrun xcodebuild -license check 2>/dev/null; then
echo >&2
echo " Xcode not set up properly. You may need to confirm the license" >&2
echo " agreement by running /usr/bin/xcodebuild without arguments." >&2
echo " Xcode setup not complete. You need to confirm the license" >&2
echo " agreement by running 'sudo xcrun xcodebuild -license accept'." >&2
echo >&2
exit 2
fi
fi
fi
#-----------------------------------------------------------------------------
# Qt version detection

View File

@ -183,6 +183,7 @@ macx-xcode {
}
cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
!isEmpty(QMAKE_XCODE_VERSION): \
cache(QMAKE_XCODE_VERSION, stash)
QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()

View File

@ -10,19 +10,24 @@ isEmpty(QMAKE_XCODE_DEVELOPER_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 xcodebuild 2>/dev/null"))): \
error("Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.")
}
isEmpty(QMAKE_XCODEBUILD_PATH): \
QMAKE_XCODEBUILD_PATH = $$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")
!isEmpty(QMAKE_XCODEBUILD_PATH) {
# Make sure Xcode is set up properly
!system("/usr/bin/xcrun xcodebuild -license check 2>/dev/null"): \
error("Xcode not set up properly. You need to confirm the license agreement by running 'sudo xcrun xcodebuild -license accept'.")
isEmpty(QMAKE_XCODE_VERSION) {
# Extract Xcode version using xcodebuild
xcode_version = $$system("/usr/bin/xcodebuild -version")
xcode_version = $$system("/usr/bin/xcrun xcodebuild -version")
QMAKE_XCODE_VERSION = $$member(xcode_version, 1)
isEmpty(QMAKE_XCODE_VERSION): error("Could not resolve Xcode version.")
unset(xcode_version)
}
}
isEmpty(QMAKE_TARGET_BUNDLE_PREFIX) {
QMAKE_XCODE_PREFERENCES_FILE = $$(HOME)/Library/Preferences/com.apple.dt.Xcode.plist

View File

@ -7,13 +7,22 @@ contains(QMAKE_MAC_SDK, .*/.*): \
defineReplace(xcodeSDKInfo) {
info = $$1
equals(info, "Path"): \
info = --show-sdk-path
equals(info, "PlatformPath"): \
info = --show-sdk-platform-path
equals(info, "SDKVersion"): \
info = --show-sdk-version
sdk = $$2
isEmpty(sdk): \
sdk = $$QMAKE_MAC_SDK
isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}) {
QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcodebuild -sdk $$sdk -version $$info 2>/dev/null")
isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}): error("Could not resolve SDK $$info for \'$$sdk\'")
QMAKE_MAC_SDK.$${sdk}.$${info} = $$system("/usr/bin/xcrun --sdk $$sdk $$info 2>/dev/null")
# --show-sdk-platform-path won't work for Command Line Tools; this is fine
# only used by the XCTest backend to testlib
isEmpty(QMAKE_MAC_SDK.$${sdk}.$${info}):if(!isEmpty(QMAKE_XCODEBUILD_PATH)|!equals(info, "--show-sdk-platform-path")): \
error("Could not resolve SDK $$info for \'$$sdk\'")
cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info})
}

View File

@ -2,5 +2,6 @@ equals(TEMPLATE, app) {
load(sdk)
# Make the XCTest framework available. This is normally handled automatically
# by Xcode based on heuristics, but we need to explicitly link to XCTest.
!isEmpty(QMAKE_MAC_SDK_PLATFORM_PATH): \
QMAKE_LFLAGS += -F$${QMAKE_MAC_SDK_PLATFORM_PATH}/Developer/Library/Frameworks -weak_framework XCTest
}

View File

@ -88,6 +88,7 @@ mac {
LIBS += -framework Foundation
load(sdk)
!isEmpty(QMAKE_MAC_SDK_PLATFORM_PATH) {
platform_dev_frameworks_path = $${QMAKE_MAC_SDK_PLATFORM_PATH}/Developer/Library/Frameworks
# We can't put this path into LIBS (so that it propagates to the prl file), as we
@ -98,6 +99,7 @@ mac {
MODULE_CONFIG += xctest
}
}
}
# Exclude these headers from the clean check if their dependencies aren't
# being built