32f34ddbe1
This approach is similar to the earlier apprach of defining main=qt_main when building the user's sources, but uses the linker to rename the symbol instead, which is less fragile than using the preprocessor. To keep the hybrid usecase unaffected by our wrapper logic we declare both our main wrapper and a fallback qt_main as weak symbols, which ensures that when the user's application links in our plugin the real main/qt_main provided by the user is preferred over our weak symbols. Change-Id: Ic76f3ba8932430c4b13a1d3a40b8ed2322fe5eea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
50 lines
2.3 KiB
Plaintext
50 lines
2.3 KiB
Plaintext
|
|
equals(TEMPLATE, app):contains(QT, gui(-private)?) {
|
|
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 {
|
|
# We use ld to rename the _main symbol to _qt_main, so that we don't get a symbol clash
|
|
# with the _main we provide that calls UIApplicationMain. We need to make a copy of the
|
|
# original object file, as ld will not copy over DWARF debug information to the output
|
|
# file. Instead, it will inject a reference back to the original object file, so when
|
|
# Xcode runs dsymutil to make the final dSYM file it will still find the debug info
|
|
# for the object file that provided the original _main. This back-reference has the
|
|
# interesting side-effect of the debug information still referring to the original
|
|
# symbol name, so stack-traces will show both our wrapper main and the original
|
|
# user main as 'main', and adding a symbolic breakpoint for 'main' will break on
|
|
# both functions. Although a bit weird, it's a good thing, as the user will still be
|
|
# able to add symbolic breakpoints for 'main', not caring that the symbol is actually
|
|
# called 'qt_main' now.
|
|
|
|
isEmpty(OBJECTS_DIR): \
|
|
OBJECTS_DIR = .
|
|
|
|
!isEmpty(QMAKE_PRE_LINK): \
|
|
QMAKE_PRE_LINK += ";"
|
|
|
|
QMAKE_PRE_LINK += \
|
|
"for f in $(find $${OBJECTS_DIR} -name '*.o'); do" \
|
|
"(nm $f | grep -q 'T _main' && cp $f $f.original" \
|
|
"&& ld -r -alias _main _qt_main -unexported_symbol _main $f.original -o $f)" \
|
|
"|| true" \
|
|
"; done"
|
|
}
|
|
}
|
|
|
|
load(qt)
|