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 <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2016-02-11 13:30:53 +01:00
parent 7f48655fb8
commit 9daeb6fe9d
9 changed files with 81 additions and 81 deletions

2
configure vendored
View File

@ -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

View File

@ -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)

View File

@ -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})
}
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)
return($$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.$${info}))
}
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: \
deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
ios:!host_build {
simulator: \
version_identifier = $$simulator.deployment_identifier
else: \
version_identifier = $$device.deployment_identifier
deployment_target = $$QMAKE_IOS_DEPLOYMENT_TARGET
} 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

View File

@ -1,6 +1,7 @@
defineReplace(qtPlatformTargetSuffix) {
ios:CONFIG(iphonesimulator, iphonesimulator|iphoneos): \
suffix = _iphonesimulator
ios:CONFIG(simulator, simulator|device): \
suffix = _$${simulator.sdk}
else: \
suffix =

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}
}
}
}

View File

@ -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)"
}