Static builds: Link QML plugins.

Run qmlimportscanner, add found plugins to the LIBS
line, generate qml_plugin_import.cpp.

Change-Id: I6c6b927cceb36fa2dc405ad698f26d20398b33c8
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
Morten Johan Sørvig 2013-09-10 16:25:32 +02:00 committed by The Qt Project
parent b7b2bdef15
commit 24b440fb54

View File

@ -73,6 +73,92 @@ wince*:static:gui {
QTLIB += qmenu_wce.res
}
# static builds: link qml import plugins into the app.
if(contains(QT, qml)|contains(QT_PRIVATE, qml)):contains(QT_CONFIG, static):contains(TEMPLATE, .*app):!host_build {
# run qmlimportscanner
qtPrepareTool(QMLIMPORTSCANNER, qmlimportscanner)
exists($$QMLIMPORTSCANNER) {
for (MODULE, QT_MODULES) {
PATH = $$eval(QT.$${MODULE}.qml)
!isEmpty(PATH): QMLPATHS += $$PATH
}
QMLPATHS = $$unique(QMLPATHS)
for (QMLPATH, QMLPATHS): \
IMPORTPATHS += -importPath $$QMLPATH
#message(run $$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
JSON = $$system($$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
} else {
error("qmlimportscanner is missing. Rebuild qtdeclarative/tools/qmlimportscanner.")
JSON = []
}
parseJson(JSON, IMPORTS)| error("Failed to parse qmlimportscanner output.")
!isEmpty(IMPORTS._KEYS_) {
# add import plugins to LIBS line
for (key, IMPORTS._KEYS_): {
PATH = $$eval(IMPORTS.$${key}.path)
PLUGIN = $$eval(IMPORTS.$${key}.plugin)
!isEmpty(PATH):!isEmpty(PLUGIN): LIBS *= -L$$PATH -l$$PLUGIN
}
# create qml_plugin_import.cpp
IMPORT_FILE_CONT = \
"// This file is autogenerated by qmake. It imports static plugin classes for" \
"// static plugins used by QML imports." \
"$${LITERAL_HASH}include <QtPlugin>"
for (key, IMPORTS._KEYS_) {
PLUGIN = $$eval(IMPORTS.$${key}.plugin)
CLASSNAME = $$eval(IMPORTS.$${key}.classname)
!isEmpty(PLUGIN) {
!isEmpty(CLASSNAME) {
!contains(ADDED_IMPORTS, $$PLUGIN) {
ADDED_IMPORTS += $$PLUGIN
IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$CLASSNAME)"
}
} else {
error("Plugin $$PLUGIN is missing a classname entry, please add one to the qmldir file.")
}
}
}
QML_IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_qml_plugin_import.cpp
write_file($$QML_IMPORT_CPP, IMPORT_FILE_CONT)|error("Aborting.")
SOURCES += $$QML_IMPORT_CPP
QMAKE_CLEAN += $$QML_IMPORT_CPP
# copy qml files. this part is platform spesific.
macx {
# copy to Contents/Resources in the bundle.
QmlImports.path = Contents/Resources/
QmlImports.files *= $$QMLPATHS
QMAKE_BUNDLE_DATA += QmlImports
# place qt.conf in Contents/Resources in the app bundle
QT_CONF_CONTENTS = \
"[Paths]" \
"Imports = Resources/qml" \
"Qml2Imports = Resources/qml"
QT_CONF = "$$OUT_PWD/$${TARGET}.app/Contents/Resources/qt.conf"
write_file($$QT_CONF, QT_CONF_CONTENTS)|error("Aborting.")
} else: ios {
# flat bundle layout (no Contents/Resources)
QmlImports.files *= $$QMLPATHS
QMAKE_BUNDLE_DATA += QmlImports
# write qt.conf to OUT_PWD and make xcode copy it via QMAKE_BUNDLE_DATA
QT_CONF_CONTENTS = \
"[Paths]" \
"Imports = qml" \
"Qml2Imports = qml"
QT_CONF = "$$OUT_PWD/qt.conf"
write_file($$QT_CONF, QT_CONF_CONTENTS)|error("Aborting.")
QtConf.files = $$QT_CONF
QMAKE_BUNDLE_DATA += QtConf
}
}
}
QT_PLUGIN_VERIFY = DEPLOYMENT_PLUGIN
contains(QT_CONFIG, static) {
QT_PLUGIN_VERIFY += QTPLUGIN