From 9daeb6fe9d35b10ed739ea0a0566533524ffd532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 11 Feb 2016 13:30:53 +0100 Subject: [PATCH] Generalize iOS simulator and device exclusive build Preparation for Apple tvOS support, which shares a lot with the iOS platform. Change-Id: I543d936b9973a60139889da2a3d4948914e9c2b2 Reviewed-by: Oswald Buddenhagen --- configure | 2 +- mkspecs/common/ios.conf | 12 ++++ mkspecs/features/mac/sdk.prf | 58 ++++++++----------- mkspecs/features/qt_functions.prf | 5 +- .../macx-ios-clang/features/default_post.prf | 10 ++-- .../macx-ios-clang/features/default_pre.prf | 8 +-- mkspecs/macx-ios-clang/features/qt_config.prf | 2 +- .../features/resolve_config.prf | 28 +++++---- mkspecs/macx-ios-clang/features/sdk.prf | 37 ++++++------ 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/configure b/configure index 121031e6fa..b790ceda41 100755 --- a/configure +++ b/configure @@ -3426,7 +3426,7 @@ if [ "$XPLATFORM_IOS" = "yes" ]; then # Otherwise we build a joined simulator and device build, which is the default. if [ -z "$OPT_MAC_SDK" ]; then QT_CONFIG="$QT_CONFIG build_all" - QTCONFIG_CONFIG="$QTCONFIG_CONFIG iphonesimulator_and_iphoneos" + QTCONFIG_CONFIG="$QTCONFIG_CONFIG simulator_and_device" fi fi diff --git a/mkspecs/common/ios.conf b/mkspecs/common/ios.conf index 67705faf44..f8f810d4f0 100644 --- a/mkspecs/common/ios.conf +++ b/mkspecs/common/ios.conf @@ -5,4 +5,16 @@ QMAKE_PLATFORM += ios QMAKE_MAC_SDK = iphoneos +simulator.sdk = iphonesimulator +simulator.target = $${simulator.sdk} +simulator.dir_affix = $${simulator.sdk} +simulator.CONFIG = $${simulator.sdk} +simulator.deployment_identifier = ios-simulator + +device.sdk = iphoneos +device.target = $${device.sdk} +device.dir_affix = $${device.sdk} +device.CONFIG = $${device.sdk} +device.deployment_identifier = $${device.sdk} + include(mac.conf) diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf index 210843bd94..46ed51deb4 100644 --- a/mkspecs/features/mac/sdk.prf +++ b/mkspecs/features/mac/sdk.prf @@ -5,29 +5,24 @@ isEmpty(QMAKE_MAC_SDK): \ contains(QMAKE_MAC_SDK, .*/.*): \ error("QMAKE_MAC_SDK can only contain short-form SDK names (eg. macosx, iphoneos)") -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\'") - cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path, set stash, QMAKE_MAC_SDK_PATH) -} else { - QMAKE_MAC_SDK_PATH = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path) +defineReplace(xcodeSDKInfo) { + info = $$1 + 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\'") + cache(QMAKE_MAC_SDK.$${sdk}.$${info}, set stash, QMAKE_MAC_SDK.$${sdk}.$${info}) + } + + return($$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.$${info})) } -isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path) { - QMAKE_MAC_SDK_PLATFORM_PATH = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version PlatformPath 2>/dev/null") - isEmpty(QMAKE_MAC_SDK_PLATFORM_PATH): error("Could not resolve SDK platform path for \'$$QMAKE_MAC_SDK\'") - cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path, set stash, QMAKE_MAC_SDK_PLATFORM_PATH) -} else { - QMAKE_MAC_SDK_PLATFORM_PATH = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_path) -} - -isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.version) { - QMAKE_MAC_SDK_VERSION = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version SDKVersion 2>/dev/null") - isEmpty(QMAKE_MAC_SDK_VERSION): error("Could not resolve SDK version for \'$$QMAKE_MAC_SDK\'") - cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.version, set stash, QMAKE_MAC_SDK_VERSION) -} else { - QMAKE_MAC_SDK_VERSION = $$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.version) -} +QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path) +QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath) +QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion) !equals(MAKEFILE_GENERATOR, XCODE) { QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH @@ -59,22 +54,17 @@ for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_FIX_RPATH QMAKE_AR QMAKE_RANLIB QMAKE_ cache($$tool_variable, set stash, $$tool) } -isEmpty(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name) { - QMAKE_MAC_PLATFORM_NAME = $$system("/usr/libexec/PlistBuddy -c 'print DefaultProperties:PLATFORM_NAME' $$QMAKE_MAC_SDK_PATH/SDKSettings.plist 2>/dev/null") - isEmpty(QMAKE_MAC_PLATFORM_NAME): error("Could not resolve platform name for SDK '$$QMAKE_MAC_SDK'") - cache(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.platform_name, set stash, 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' - version_identifier = $$replace(QMAKE_MAC_PLATFORM_NAME, iphonesimulator, ios-simulator) - - ios:!host_build: \ + ios:!host_buildĀ { + simulator: \ + version_identifier = $$simulator.deployment_identifier + else: \ + version_identifier = $$device.deployment_identifier deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET - else: \ + } else: osx { + version_identifier = macosx deployment_target = $$QMAKE_MACOSX_DEPLOYMENT_TARGET + } version_min_flag = -m$${version_identifier}-version-min=$$deployment_target QMAKE_CFLAGS += $$version_min_flag diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 88467e89ba..0046cce9ad 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -1,6 +1,7 @@ + defineReplace(qtPlatformTargetSuffix) { - ios:CONFIG(iphonesimulator, iphonesimulator|iphoneos): \ - suffix = _iphonesimulator + ios:CONFIG(simulator, simulator|device): \ + suffix = _$${simulator.sdk} else: \ suffix = diff --git a/mkspecs/macx-ios-clang/features/default_post.prf b/mkspecs/macx-ios-clang/features/default_post.prf index 40e7a893de..e5c78a0ea4 100644 --- a/mkspecs/macx-ios-clang/features/default_post.prf +++ b/mkspecs/macx-ios-clang/features/default_post.prf @@ -63,12 +63,12 @@ macx-xcode { } macx-xcode { - arch_iphoneos.name = "ARCHS[sdk=iphoneos*]" - arch_iphoneos.value = $$QMAKE_IOS_DEVICE_ARCHS - arch_iphonesimulator.name = "ARCHS[sdk=iphonesimulator*]" - arch_iphonesimulator.value = $$QMAKE_IOS_SIMULATOR_ARCHS + arch_device.name = "ARCHS[sdk=$${device.sdk}*]" + arch_device.value = $$QMAKE_IOS_DEVICE_ARCHS + arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]" + arch_simulator.value = $$QMAKE_IOS_SIMULATOR_ARCHS - QMAKE_MAC_XCODE_SETTINGS += arch_iphoneos arch_iphonesimulator + QMAKE_MAC_XCODE_SETTINGS += arch_device arch_simulator QMAKE_XCODE_ARCHS = $$QMAKE_IOS_DEVICE_ARCHS $$QMAKE_IOS_SIMULATOR_ARCHS only_active_arch.name = ONLY_ACTIVE_ARCH diff --git a/mkspecs/macx-ios-clang/features/default_pre.prf b/mkspecs/macx-ios-clang/features/default_pre.prf index dfede454b5..a857c49007 100644 --- a/mkspecs/macx-ios-clang/features/default_pre.prf +++ b/mkspecs/macx-ios-clang/features/default_pre.prf @@ -2,15 +2,15 @@ load(default_pre) # In case Qt was built for a specific SDK -!iphonesimulator_and_iphoneos:contains(QMAKE_MAC_SDK, ^iphonesimulator.*): \ - CONFIG += iphonesimulator +!simulator_and_device:contains(QMAKE_MAC_SDK, ^$${simulator.sdk}.*): \ + CONFIG += simulator $${simulator.sdk} # Check for supported Xcode versions lessThan(QMAKE_XCODE_VERSION, "4.3"): \ error("This mkspec requires Xcode 4.3 or later") -iphonesimulator_and_iphoneos:iphonesimulator { - # For a iphonesimulator_and_iphoneos build all the config tests +simulator_and_device:iphonesimulator { + # For a simulator_and_device build all the config tests # are based on the iPhoneOS ARM SDK, but we know that the simulator # is i386 and that we support SSE/SSE2. QT_ARCH = i386 diff --git a/mkspecs/macx-ios-clang/features/qt_config.prf b/mkspecs/macx-ios-clang/features/qt_config.prf index d1a1a36933..d746cba9d9 100644 --- a/mkspecs/macx-ios-clang/features/qt_config.prf +++ b/mkspecs/macx-ios-clang/features/qt_config.prf @@ -5,7 +5,7 @@ isEmpty(QT_ARCH) { # means we fail to pass -arch to the compiler, resulting in broke tests. # As the Xcode toolchain doesn't seem to have a way to auto-detect the # arch based on the SDK, we have to hard-code the arch for configure. - contains(QMAKE_MAC_SDK, iphoneos.*): \ + contains(QMAKE_MAC_SDK, $${device.sdk}.*): \ QT_ARCH = arm else: \ # Simulator QT_ARCH = i386 diff --git a/mkspecs/macx-ios-clang/features/resolve_config.prf b/mkspecs/macx-ios-clang/features/resolve_config.prf index d1d3e8ca39..38d6c74ccb 100644 --- a/mkspecs/macx-ios-clang/features/resolve_config.prf +++ b/mkspecs/macx-ios-clang/features/resolve_config.prf @@ -3,37 +3,35 @@ xcodebuild { # Xcode project files always support both Debug and Release configurations # and iOS device and simulator targets, so we make sure the wrapper-makefile # also does. - CONFIG += debug_and_release iphonesimulator_and_iphoneos + CONFIG += debug_and_release simulator_and_device } load(resolve_config) -CONFIG(iphonesimulator, iphonesimulator|iphoneos): \ - CONFIG -= iphoneos +CONFIG(simulator, simulator|device): \ + CONFIG -= device $${device.CONFIG} else: \ - CONFIG -= iphonesimulator + CONFIG -= simulator $${simulator.CONFIG} macx-xcode { # There is no way to genereate Xcode projects that are limited to either - # simulator or device builds, so iphonesimulator_and_iphoneos is always + # simulator or device builds, so simulator_and_device is always # effectivly active, even if the user disabled it explicitly. # The Xcode generator doesn't support multiple BUILDS though (exclusive # builds), so we have to manually set up the simulator suffix. - library_suffix_iphonesimulator.name = "$${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING}[sdk=iphonesimulator*]" - library_suffix_iphonesimulator.value = "_iphonesimulator$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})" - QMAKE_MAC_XCODE_SETTINGS += library_suffix_iphonesimulator + library_suffix_simulator.name = "$${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING}[sdk=$${simulator.sdk}*]" + library_suffix_simulator.value = "_$${simulator.sdk}$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})" + QMAKE_MAC_XCODE_SETTINGS += library_suffix_simulator CONFIG *= xcode_dynamic_library_suffix } else { - iphonesimulator.name = Simulator - iphoneos.name = Device - addExclusiveBuilds(iphonesimulator, iphoneos) + addExclusiveBuilds(simulator, device) } equals(TEMPLATE, subdirs) { # Prevent recursion into host_builds for(subdir, SUBDIRS) { contains($${subdir}.CONFIG, host_build) { - $${subdir}.CONFIG += no_iphoneos_target no_iphonesimulator_target + $${subdir}.CONFIG += no_$${simulator.target}_target no_$${device.target}_target # Other targets which we do want to recurse into may depend on this target, # for example corelib depends on moc, rcc, bootstrap, etc, and other libs @@ -56,9 +54,9 @@ equals(TEMPLATE, subdirs) { target ~= s,[^a-zA-Z0-9_],-, - $${target}-iphonesimulator.depends = $$target - $${target}-iphoneos.depends = $$target - QMAKE_EXTRA_TARGETS += $${target}-iphonesimulator $${target}-iphoneos + $${target}-$${simulator.target}.depends = $$target + $${target}-$${device.target}.depends = $$target + QMAKE_EXTRA_TARGETS += $${target}-$${simulator.target} $${target}-$${device.target} } } } diff --git a/mkspecs/macx-ios-clang/features/sdk.prf b/mkspecs/macx-ios-clang/features/sdk.prf index 32fcbb7289..11d684687c 100644 --- a/mkspecs/macx-ios-clang/features/sdk.prf +++ b/mkspecs/macx-ios-clang/features/sdk.prf @@ -1,13 +1,14 @@ -# In case the user sets the SDK manually -contains(QMAKE_MAC_SDK, ^iphonesimulator.*) { - iphonesimulator_and_iphoneos: \ - error("iOS simulator is handled automatically for iphonesimulator_and_iphoneos") - CONFIG += iphonesimulator +# In case the user sets the SDK manually +contains(QMAKE_MAC_SDK, ^$${simulator.sdk}.*) { + simulator_and_device: \ + error("iOS simulator is handled automatically for simulator_and_device") + + CONFIG += simulator $${simulator.sdk} } -iphonesimulator_and_iphoneos:iphonesimulator: \ - QMAKE_MAC_SDK ~= s,^iphoneos,iphonesimulator, +simulator_and_device:simulator: \ + QMAKE_MAC_SDK ~= s,^$${device.sdk},$${simulator.sdk}, load(sdk) @@ -15,19 +16,17 @@ lessThan(QMAKE_MAC_SDK_VERSION, "8.0"): \ error("Current $$QMAKE_MAC_SDK SDK version ($$QMAKE_MAC_SDK_VERSION) is too old. Please upgrade Xcode.") macx-xcode { - sdk_path_iphoneos.name = "QMAKE_MAC_SDK_PATH[sdk=iphoneos*]" - sdk_path_iphoneos.value = $$QMAKE_MAC_SDK_PATH - QMAKE_MAC_SDK_PATH ~= s,iPhoneOS,iPhoneSimulator, - sdk_path_iphonesimulator.name = "QMAKE_MAC_SDK_PATH[sdk=iphonesimulator*]" - sdk_path_iphonesimulator.value = $$QMAKE_MAC_SDK_PATH - QMAKE_MAC_XCODE_SETTINGS += sdk_path_iphoneos sdk_path_iphonesimulator + sdk_path_device.name = "QMAKE_MAC_SDK_PATH[sdk=$${device.sdk}*]" + sdk_path_device.value = $$xcodeSDKInfo(Path, $${device.sdk}) + sdk_path_simulator.name = "QMAKE_MAC_SDK_PATH[sdk=$${simulator.sdk}*]" + sdk_path_simulator.value = $$xcodeSDKInfo(Path, $${simulator.sdk}) + QMAKE_MAC_XCODE_SETTINGS += sdk_path_device sdk_path_simulator QMAKE_MAC_SDK_PATH = "$(QMAKE_MAC_SDK_PATH)" - sdk_platform_path_iphoneos.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=iphoneos*]" - sdk_platform_path_iphoneos.value = $$QMAKE_MAC_SDK_PLATFORM_PATH - QMAKE_MAC_SDK_PLATFORM_PATH ~= s,iPhoneOS,iPhoneSimulator, - sdk_platform_path_iphonesimulator.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=iphonesimulator*]" - sdk_platform_path_iphonesimulator.value = $$QMAKE_MAC_SDK_PLATFORM_PATH - QMAKE_MAC_XCODE_SETTINGS += sdk_platform_path_iphoneos sdk_platform_path_iphonesimulator + sdk_platform_path_device.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=$${device.sdk}*]" + sdk_platform_path_device.value = $$xcodeSDKInfo(PlatformPath, $${device.sdk}) + sdk_platform_path_simulator.name = "QMAKE_MAC_SDK_PLATFORM_PATH[sdk=$${simulator.sdk}*]" + sdk_platform_path_simulator.value = $$xcodeSDKInfo(PlatformPath, $${simulator.sdk}) + QMAKE_MAC_XCODE_SETTINGS += sdk_platform_path_device sdk_platform_path_simulator QMAKE_MAC_SDK_PLATFORM_PATH = "$(QMAKE_MAC_SDK_PLATFORM_PATH)" }