aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltyperegistrar/qmltypes.prf
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-11-07 16:47:26 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-11-08 14:51:35 +0100
commit9d89702ab26958dbd075de11041af0b230b1230b (patch)
tree778c65d55a51af6f856df5922fab23a4e59f3f6c /src/qmltyperegistrar/qmltypes.prf
parentee8589dd9a681a469511308345e4ef0b304aaaab (diff)
Move qmltyperegistrar into src
We want it to be available early in the build process. qmltyperegistrar will be required to build qml, quick, and various imports. Change-Id: I15b827cd4b322a2bcea2780eeedb8dbe132aa59a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar/qmltypes.prf')
-rw-r--r--src/qmltyperegistrar/qmltypes.prf86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/qmltyperegistrar/qmltypes.prf b/src/qmltyperegistrar/qmltypes.prf
new file mode 100644
index 0000000000..d8e826c671
--- /dev/null
+++ b/src/qmltyperegistrar/qmltypes.prf
@@ -0,0 +1,86 @@
+CONFIG += metatypes
+
+qtPrepareTool(QML_TYPEREGISTRAR, qmltyperegistrar)
+
+isEmpty(QML_IMPORT_VERSION): \
+ QML_IMPORT_VERSION = $$IMPORT_VERSION
+
+# from moc.prf
+isEmpty(QML_IMPORT_MAJOR_VERSION):!isEmpty(QML_IMPORT_VERSION): \
+ QML_IMPORT_MAJOR_VERSION = $$section(QML_IMPORT_VERSION, ., 0, 0)
+
+isEmpty(QML_IMPORT_MINOR_VERSION):!isEmpty(QML_IMPORT_VERSION): \
+ QML_IMPORT_MINOR_VERSION = $$section(QML_IMPORT_VERSION, ., 1, 1)
+
+isEmpty(QML_IMPORT_NAME):!isEmpty(TARGETPATH) {
+ QML_IMPORT_NAME = $$replace(TARGETPATH, "/", ".")
+ QML_IMPORT_NAME = $$replace(QML_IMPORT_NAME, .$${QML_IMPORT_MAJOR_VERSION}$, '')
+}
+
+isEmpty(QML_IMPORT_NAME) {
+ error("Need TARGET_PATH or QML_IMPORT_NAME in order to generate qml types.");
+}
+
+isEmpty(QML_IMPORT_MAJOR_VERSION) {
+ error("Need IMPORT_VERSION, QML_IMPORT_VERSION, or QML_IMPORT_MAJOR_VERSION in order to generate qml types.");
+}
+
+isEmpty(QML_IMPORT_MINOR_VERSION) {
+ QML_IMPORT_MINOR_VERSION = 0
+}
+
+isEmpty(QMLTYPES_FILENAME) {
+ plugin: QMLTYPES_FILENAME = $$OUT_PWD/plugins.qmltypes
+ else: QMLTYPES_FILENAME = $$OUT_PWD/$${TEMPLATE}.qmltypes
+}
+
+qt_module_deps = $$replace(QT, -private$, '')
+qt_module_deps += $$replace(QT_PRIVATE, -private$, '')
+qt_module_deps = $$replace(qt_module_deps, _private$, '')
+all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends")
+foreign_types =
+for(dep, all_qt_module_deps): \
+ foreign_types += $$[QT_INSTALL_LIBS]/metatypes/$$lower($$eval(QT.$${dep}.module))_metatypes.json
+
+QML_TYPEREGISTRAR_FLAGS = \
+ --generate-plugintypes=$$QMLTYPES_FILENAME \
+ --import-name=$$QML_IMPORT_NAME \
+ --major-version=$$QML_IMPORT_MAJOR_VERSION \
+ --minor-version=$$QML_IMPORT_MINOR_VERSION \
+ --foreign-types=$$join(foreign_types, ',')
+
+DEPENDENCIESFILE = $$_PRO_FILE_PWD_/dependencies.json
+exists($$DEPENDENCIESFILE): QML_TYPEREGISTRAR_FLAGS += --dependencies=$$DEPENDENCIESFILE
+
+!isEmpty(MODULE_PRIVATE_INCLUDES): QML_TYPEREGISTRAR_FLAGS += --private-includes
+
+METATYPES_JSON = $$lower($$basename(TARGET))_metatypes.json
+
+TYPEREGISTRATIONS = $$lower($$basename(TARGET))_qmltyperegistrations$${first(QMAKE_EXT_CPP)}
+
+qmltyperegistrar_compiler.CONFIG += combine
+qmltyperegistrar_compiler.commands = \
+ $$QML_TYPEREGISTRAR $$QML_TYPEREGISTRAR_FLAGS -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
+qmltyperegistrar_compiler.input = METATYPES_JSON
+qmltyperegistrar_compiler.output = $$TYPEREGISTRATIONS
+qmltyperegistrar_compiler.variable_out = SOURCES
+qmltyperegistrar_compiler.name = Automatic QML type registration
+qmltyperegistrar_compiler.dependency_type = TYPE_C
+
+qmltyperegistrar_qmltypes.input = METATYPES_JSON
+qmltyperegistrar_qmltypes.depends = $$TYPEREGISTRATIONS
+qmltyperegistrar_qmltypes.output = $$QMLTYPES_FILENAME
+qmltyperegistrar_qmltypes.CONFIG = no_link
+qmltyperegistrar_qmltypes.commands = $$escape_expand(\\n) # force creation of rule
+
+install_qmltypes {
+ isEmpty(QMLTYPES_INSTALL_DIR): \
+ QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/$$TARGETPATH
+ do_install.files = $$QMLTYPES_FILENAME
+ do_install.path = $$QMLTYPES_INSTALL_DIR
+ do_install.CONFIG += no_link
+ prefix_build: INSTALLS += do_install
+ else: COPIES += do_install
+}
+
+QMAKE_EXTRA_COMPILERS += qmltyperegistrar_compiler qmltyperegistrar_qmltypes