summaryrefslogtreecommitdiffstats
path: root/mkspecs/macx-ios-clang
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-10-11 12:56:06 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-14 17:28:48 +0200
commit401510dbbec40b5c6350bb8a9be3ab92292dbc3b (patch)
tree2f5d9b85b0570cf90814ad88018e0ee54ef46588 /mkspecs/macx-ios-clang
parent17ebcd2b4690f73c8fd2332b0ba55b3ee3e2e8bb (diff)
iOS: Move qmake features out of the generic features and into the makespec
As they are closely tied to the macx-ios-clang mkspec and can't be shared. Change-Id: Icb59304cc1e4be12732f50175f3f84be289300c2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'mkspecs/macx-ios-clang')
-rw-r--r--mkspecs/macx-ios-clang/features/default_post.prf85
-rw-r--r--mkspecs/macx-ios-clang/features/default_pre.prf9
-rw-r--r--mkspecs/macx-ios-clang/features/qt.prf75
3 files changed, 169 insertions, 0 deletions
diff --git a/mkspecs/macx-ios-clang/features/default_post.prf b/mkspecs/macx-ios-clang/features/default_post.prf
new file mode 100644
index 0000000000..a61db3daea
--- /dev/null
+++ b/mkspecs/macx-ios-clang/features/default_post.prf
@@ -0,0 +1,85 @@
+
+equals(TEMPLATE, app) {
+
+ # If the application uses Qt, it needs to be an application bundle
+ # to be able to deploy and run on iOS. The only exception to this
+ # is if you're working with a jailbroken device and can run the
+ # resulting binary from the console/over SSH, but that's not a
+ # use-case we care about, so no need to complicate the logic.
+ qt: CONFIG *= app_bundle
+
+ # Application bundles require building through Xcode
+ app_bundle:!macx-xcode {
+ # For Qt applications we want Xcode project files as the generated output,
+ # but since qmake doesn't handle the transition between makefiles and Xcode
+ # project files (which happens when using subdirs), we create a wrapper
+ # makefile that takes care of generating the Xcode project, and allows
+ # building by calling out to xcodebuild.
+ TEMPLATE = aux
+
+ CONFIG -= have_target qt staticlib dll
+ SOURCES =
+ RESOURCES =
+ INSTALLS =
+
+ TARGET_XCODE_PROJECT_DIR = $${TARGET}.xcodeproj
+
+ system("cd $$system_quote($$OUT_PWD) && $${QMAKE_QMAKE} $$system_quote($$_PRO_FILE_) -spec macx-xcode")
+
+ # We use xcodebuild to do the actual build, but filter out the verbose
+ # output that shows all environment variables for each build step.
+ xcodebuild_build.commands = "@bash -o pipefail -c 'xcodebuild | grep -v setenv'"
+ QMAKE_EXTRA_TARGETS += xcodebuild_build
+ all.depends = xcodebuild_build
+ QMAKE_EXTRA_TARGETS += all
+
+ # We do the same for the clean action
+ xcodebuild_clean.commands = "@xcodebuild clean"
+ QMAKE_EXTRA_TARGETS += xcodebuild_clean
+ clean.depends = xcodebuild_clean
+ QMAKE_EXTRA_TARGETS += clean
+
+ # And distclean
+ xcodebuild_distclean.commands = "$(DEL_FILE) -R $$TARGET_XCODE_PROJECT_DIR"
+ QMAKE_EXTRA_TARGETS += xcodebuild_distclean
+ distclean.depends = xcodebuild_distclean
+ QMAKE_EXTRA_TARGETS += distclean
+ }
+}
+
+macx-xcode {
+ ios_device_family.name = TARGETED_DEVICE_FAMILY
+ ios_device_family.value = $$QMAKE_IOS_TARGETED_DEVICE_FAMILY
+ QMAKE_MAC_XCODE_SETTINGS += ios_device_family
+}
+
+isEmpty(QT_ARCH) {
+ # The iPhoneOS and iPhoneSimulator targets share the same toolchain,
+ # so when configure runs the arch tests it passes the correct sysroot,
+ # but we fail to pick up the architecture since we're not passing -arch
+ # yet. Xcode does not seem to have a way to run the shared toolchain
+ # in a way that will automatically do this (for example xcrun -sdk).
+ contains(QMAKE_MAC_SDK, iphoneos.*): QT_ARCH = arm
+ else: QT_ARCH = i386 # Simulator
+}
+
+# Be more specific about which architecture we're targeting
+equals(QT_ARCH, arm): \
+ actual_archs = armv7
+else: \
+ actual_archs = $$QT_ARCH
+
+macx-xcode {
+ QMAKE_XCODE_ARCHS = $$actual_archs
+} else {
+ for(arch, actual_archs): \
+ arch_flags += -arch $$arch
+
+ QMAKE_CFLAGS += $$arch_flags
+ QMAKE_CXXFLAGS += $$arch_flags
+ QMAKE_OBJECTIVE_CFLAGS += $$arch_flags
+ QMAKE_LFLAGS += $$arch_flags
+}
+unset(actual_archs)
+
+load(default_post)
diff --git a/mkspecs/macx-ios-clang/features/default_pre.prf b/mkspecs/macx-ios-clang/features/default_pre.prf
new file mode 100644
index 0000000000..de5a9170d7
--- /dev/null
+++ b/mkspecs/macx-ios-clang/features/default_pre.prf
@@ -0,0 +1,9 @@
+
+load(default_pre)
+
+# Check for supported Xcode versions
+lessThan(QMAKE_XCODE_VERSION, "4.3"): \
+ error("This mkspec requires Xcode 4.3 or later")
+!contains(QMAKE_XCODE_VERSION, ^(4\\.[3456]|5\\.[0])$): \
+ warning("The version of Xcode installed on this system ($$QMAKE_XCODE_VERSION)" \
+ "has not been tested fully - custom compiler settings may be necessary")
diff --git a/mkspecs/macx-ios-clang/features/qt.prf b/mkspecs/macx-ios-clang/features/qt.prf
new file mode 100644
index 0000000000..9fa882c99f
--- /dev/null
+++ b/mkspecs/macx-ios-clang/features/qt.prf
@@ -0,0 +1,75 @@
+
+equals(TEMPLATE, app):contains(QT, gui(-private)?) {
+ !macx-xcode: \
+ error("Linking the iOS platform plugin requires bulding through Xcode")
+
+ LIBS *= -L$$[QT_INSTALL_PLUGINS/get]/platforms
+
+ lib_name = qios
+ lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/lib$${lib_name}$$qtPlatformTargetSuffix()
+ LIBS += -l$${lib_name}$$qtPlatformTargetSuffix() $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS)
+
+ # By marking qt_registerPlatformPlugin as undefined, we ensure that
+ # the plugin.o translation unit is considered for inclusion in
+ # the final binary, which in turn ensures that the plugin's
+ # static initializer is included and run.
+ QMAKE_LFLAGS += -u _qt_registerPlatformPlugin
+
+ # We do link and dependency resolution for the platform plugin
+ # manually, since we know we always need the plugin, so we don't
+ # need to generate an import for it.
+ CONFIG -= import_qpa_plugin
+
+ !no_main_wrapper {
+ # Instead of messing with the user's main function we go the other
+ # way and change the application entry point to call our main wrapper.
+ # This entry point is the 'start' symbol, provided by crt1.o, so we
+ # make a copy of the file and rename the '_main' unresolved symbol
+ # to our wrapper function, '_qtmn', injecting ourselves into the app
+ # startup. Once Apple starts shipping the LLVM linker (lld) we may
+ # get rid of this step completely and just pass -e _qtmn to the
+ # linker, taking advantage of the new LC_MAIN load command.
+
+ # We know that iOS 3.1 and up uses crt1.3.1.o (technically not
+ # true for simulator, but the SDK has a symlink to the correct file).
+ original_crt_path = "$(SDK_DIR)/usr/lib/crt1.3.1.o"
+
+ xcode_objects_path = "$(OBJECT_FILE_DIR_$(CURRENT_VARIANT))/$(CURRENT_ARCH)"
+ custom_crt_filename = "crt1_qt.o"
+ custom_crt_path = "$$xcode_objects_path/$$custom_crt_filename"
+
+ EOC = $$escape_expand(\\n\\t)
+ create_custom_crt.commands = \
+ # Copy original crt1 to build directory
+ "$$QMAKE_COPY_FILE $$original_crt_path $$custom_crt_path $$EOC" \
+ # And rename all occurrences of _main to _qtmn
+ "strings -t d - $${custom_crt_path}" \
+ "| sed -n 's/^\\([0-9]\\{1,\\}\\) _main\$\$/\1/p'" \
+ "| while read offset; do" \
+ "printf '_qtmn'" \
+ "| dd of=$${custom_crt_path} bs=1 seek=\$\$offset conv=notrunc >/dev/null 2>&1" \
+ "; done"
+ create_custom_crt.depends = $$original_crt_path
+ create_custom_crt.target = $$custom_crt_path
+ preprocess.depends = create_custom_crt
+ QMAKE_EXTRA_TARGETS += create_custom_crt preprocess
+
+ clean_custom_crt.commands = "$$QMAKE_DEL_FILE $$custom_crt_path"
+ preprocess_clean.depends += clean_custom_crt
+ QMAKE_EXTRA_TARGETS += clean_custom_crt preprocess_clean
+
+ # Prevent usage of new LC_MAIN load command, which skips start/crt1
+ # and calls main from the loader. We rely on injecting into start.
+ QMAKE_LFLAGS += -Wl,-no_new_main
+
+ # Explicitly link against our modified crt1 object
+ QMAKE_LFLAGS += -nostartfiles -l$${custom_crt_filename}
+
+ # Workaround for QMAKE_PBX_LIBPATHS mangling the Xcode variables
+ lib_search_path.name = LIBRARY_SEARCH_PATHS
+ lib_search_path.value = $$xcode_objects_path
+ QMAKE_MAC_XCODE_SETTINGS += lib_search_path
+ }
+}
+
+load(qt)