From fa7626713b3a943609453459190e16c49d61dfd3 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 7 Jun 2017 16:42:47 -0700 Subject: 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 Reviewed-by: Jake Petroules --- mkspecs/features/mac/default_post.prf | 3 ++- mkspecs/features/mac/default_pre.prf | 25 +++++++++++++++---------- mkspecs/features/mac/sdk.prf | 13 +++++++++++-- mkspecs/features/xctest.prf | 3 ++- 4 files changed, 30 insertions(+), 14 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 395ac34001..e645ba5803 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -183,6 +183,7 @@ macx-xcode { } cache(QMAKE_XCODE_DEVELOPER_PATH, stash) -cache(QMAKE_XCODE_VERSION, stash) +!isEmpty(QMAKE_XCODE_VERSION): \ + cache(QMAKE_XCODE_VERSION, stash) QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix() diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf index e21e749ee9..44636f2288 100644 --- a/mkspecs/features/mac/default_pre.prf +++ b/mkspecs/features/mac/default_pre.prf @@ -10,18 +10,23 @@ 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_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) +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/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) { diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index 68ab7e4053..3f6dc076ca 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -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}) } diff --git a/mkspecs/features/xctest.prf b/mkspecs/features/xctest.prf index 4b84682df7..4ee504f0ad 100644 --- a/mkspecs/features/xctest.prf +++ b/mkspecs/features/xctest.prf @@ -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. - QMAKE_LFLAGS += -F$${QMAKE_MAC_SDK_PLATFORM_PATH}/Developer/Library/Frameworks -weak_framework XCTest + !isEmpty(QMAKE_MAC_SDK_PLATFORM_PATH): \ + QMAKE_LFLAGS += -F$${QMAKE_MAC_SDK_PLATFORM_PATH}/Developer/Library/Frameworks -weak_framework XCTest } -- cgit v1.2.3