Use tools from the SDK's toolchain instead of the ones in /usr/bin
For Mac OS X we currently specify build tools without an absolute path, which means we end up using the ones in /usr/bin. This is wrong, we should be using the tools from the toolchain of the chosen SDK. For iOS we do specify an absolute path, by resolving the toolchain path in the iOS makespecs. To solve the situation on Mac OS X, we move the logic of resolving the toolchain path to sdk.prf, and share it between OSX and iOS. For configure we need to duplicate some of the logic from sdk.prf, as configure pulls out QMAKE_CC and QMAKE_CXX for running some initial tests and building qmake. The new macSDKify function also solves the issue of missing sysroot and deployment version in the flags. Change-Id: Ib1d239c9904cf3ccee5214b313cf6205869a1462 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
e9837f7938
commit
c45595d648
54
configure
vendored
54
configure
vendored
@ -226,12 +226,60 @@ getSingleQMakeVariable()
|
||||
echo "$2" | $AWK "/^($1)=/ { print substr(\$0, index(\$0, \"=\") + 1) }"
|
||||
}
|
||||
|
||||
macSDKify()
|
||||
{
|
||||
# Normally we take care of sysrootifying in sdk.prf, but configure extracts some
|
||||
# values before qmake is even built, so we have to duplicate the logic here.
|
||||
|
||||
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=$(xcodebuild -sdk $sdk -version Path 2>/dev/null)
|
||||
if [ -z "$sysroot" ]; then echo "Failed to resolve SDK path for '$sdk'" >&2; exit 1; fi
|
||||
|
||||
case "$sdk" in
|
||||
macosx*)
|
||||
version_min_flag="-mmacosx-version-min=$(getSingleQMakeVariable QMAKE_MACOSX_DEPLOYMENT_TARGET "$1")"
|
||||
;;
|
||||
iphoneos*)
|
||||
version_min_flag="-miphoneos-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
|
||||
;;
|
||||
iphonesimulator*)
|
||||
version_min_flag="-mios-simulator-version-min=$(getSingleQMakeVariable QMAKE_IOS_DEPLOYMENT_TARGET "$1")"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$1" | while read line; do
|
||||
case "$line" in
|
||||
QMAKE_CC=*|QMAKE_CXX=*|QMAKE_FIX_RPATH=*|QMAKE_AR=*|QMAKE_RANLIB=*|QMAKE_LINK=*|QMAKE_LINK_SHLIB=*)
|
||||
# Prefix tool with toolchain path
|
||||
var=$(echo "$line" | cut -d '=' -f 1)
|
||||
val=$(echo "$line" | cut -d '=' -f 2-)
|
||||
sdk_val=$(xcrun -sdk $sdk -find $(echo $val | cut -d ' ' -f 1))
|
||||
val=$(echo $sdk_val $(echo $val | cut -s -d ' ' -f 2-))
|
||||
echo "$var=$val"
|
||||
;;
|
||||
QMAKE_CFLAGS=*|QMAKE_CXXFLAGS=*|QMAKE_OBJECTIVE_CFLAGS=*)
|
||||
echo "$line -isysroot $sysroot $version_min_flag"
|
||||
;;
|
||||
QMAKE_LFLAGS=*)
|
||||
echo "$line -Wl,-syslibroot,$sysroot $version_min_flag"
|
||||
;;
|
||||
*)
|
||||
echo "$line"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# relies on $QMAKESPEC being set correctly. parses include statements in
|
||||
# qmake.conf and prints out the expanded file
|
||||
getQMakeConf()
|
||||
{
|
||||
if [ -z "$specvals" ]; then
|
||||
specvals=`expandQMakeConf "$QMAKESPEC/qmake.conf" | extractQMakeVariables "host_build"`
|
||||
if [ "$BUILD_ON_MAC" = "yes" ]; then specvals=$(macSDKify "$specvals"); fi
|
||||
fi
|
||||
getSingleQMakeVariable "$1" "$specvals"
|
||||
}
|
||||
@ -240,6 +288,7 @@ getXQMakeConf()
|
||||
{
|
||||
if [ -z "$xspecvals" ]; then
|
||||
xspecvals=`expandQMakeConf "$XQMAKESPEC/qmake.conf" | extractQMakeVariables "!host_build"`
|
||||
if [ "$BUILD_ON_MAC" = "yes" ]; then xspecvals=$(macSDKify "$xspecvals"); fi
|
||||
fi
|
||||
getSingleQMakeVariable "$1" "$xspecvals"
|
||||
}
|
||||
@ -3892,12 +3941,11 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
|
||||
EXEEXT=
|
||||
fi
|
||||
if [ "$BUILD_ON_MAC" = "yes" ]; then
|
||||
DEPLOYMENT_CFLAGS="-mmacosx-version-min=$(getQMakeConf QMAKE_MACOSX_DEPLOYMENT_TARGET)"
|
||||
echo "CARBON_LFLAGS =-framework ApplicationServices" >>"$mkfile"
|
||||
echo "CARBON_CFLAGS =-fconstant-cfstrings" >>"$mkfile"
|
||||
EXTRA_LFLAGS="$EXTRA_LFLAGS \$(CARBON_LFLAGS)"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $DEPLOYMENT_CFLAGS \$(CARBON_CFLAGS)"
|
||||
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $DEPLOYMENT_CFLAGS \$(CARBON_CFLAGS)"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS \$(CARBON_CFLAGS)"
|
||||
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(CARBON_CFLAGS)"
|
||||
EXTRA_OBJS="$EXTRA_OBJS \
|
||||
qsettings_mac.o \
|
||||
qcore_mac.o"
|
||||
|
@ -1,28 +1,20 @@
|
||||
#
|
||||
# Common build settings for all iOS configurations
|
||||
#
|
||||
# Depends on:
|
||||
#
|
||||
# QMAKE_XCODE_DEVELOPER_PATH - set in mkspecs/common/xcode.conf
|
||||
|
||||
QT_QPA_DEFAULT_PLATFORM = ios
|
||||
|
||||
QMAKE_XCODE_TOOLCHAIN_BIN_PATH = $$QMAKE_XCODE_DEVELOPER_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin
|
||||
|
||||
QMAKE_XCODE_CODE_SIGN_IDENTITY = "iPhone Developer"
|
||||
|
||||
# iOS build tools
|
||||
QMAKE_CC = $$QMAKE_XCODE_TOOLCHAIN_BIN_PATH/clang
|
||||
QMAKE_CXX = $$QMAKE_XCODE_TOOLCHAIN_BIN_PATH/clang++
|
||||
QMAKE_FIX_RPATH = $$QMAKE_XCODE_TOOLCHAIN_BIN_PATH/install_name_tool -id
|
||||
QMAKE_AR = $$QMAKE_XCODE_TOOLCHAIN_BIN_PATH/ar cq
|
||||
QMAKE_RANLIB = $$QMAKE_XCODE_TOOLCHAIN_BIN_PATH/ranlib -s
|
||||
QMAKE_CC = clang
|
||||
QMAKE_CXX = clang++
|
||||
QMAKE_FIX_RPATH = install_name_tool -id
|
||||
QMAKE_AR = ar cq
|
||||
QMAKE_RANLIB = ranlib -s
|
||||
QMAKE_LINK = $$QMAKE_CXX
|
||||
QMAKE_LINK_SHLIB = $$QMAKE_CXX
|
||||
|
||||
# Check that compiler is valid
|
||||
!exists($$QMAKE_CXX): error("The version of Xcode installed on this system does not include the clang compiler")
|
||||
|
||||
# Basic iOS frameworks needed for any GUI app
|
||||
QMAKE_LFLAGS += -framework Foundation -framework UIKit -framework QuartzCore -lz
|
||||
|
||||
|
@ -19,6 +19,15 @@ sysrootified =
|
||||
for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
|
||||
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)) {
|
||||
value = $$eval($$tool)
|
||||
isEmpty(value): next()
|
||||
|
||||
sysrooted = $$system("xcrun -sdk $$QMAKE_MAC_SDK -find $$first(value)")
|
||||
$$tool = $$sysrooted $$member(value, 1, -1)
|
||||
}
|
||||
|
||||
# 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("plutil -convert xml1 \"$$QMAKE_MAC_SDK_PATH/SDKSettings.plist\" -o - | " \
|
||||
"sed '/^<!DOCTYPE/d' | " \ # Don't look up http://www.apple.com/DTDs/PropertyList-1.0.dtd
|
||||
|
Loading…
Reference in New Issue
Block a user