File: qmltypes.prf

package info (click to toggle)
qtdeclarative-opensource-src 5.15.2%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 259,220 kB
  • sloc: javascript: 512,396; cpp: 493,894; xml: 8,892; python: 3,304; ansic: 2,764; sh: 206; makefile: 59; php: 27
file content (112 lines) | stat: -rw-r--r-- 4,229 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
}

TARGET_BASENAME = $$lower($$basename(TARGET))
TARGET_BASENAME ~= s/\s/_/g

isEmpty(QMLTYPES_FILENAME) {
    plugin: QMLTYPES_FILENAME = plugins.qmltypes
    else: QMLTYPES_FILENAME = $${TARGET_BASENAME}.qmltypes
}

qt_module_deps = $$replace(QT, -private$, '')
qt_module_deps += $$replace(QT_PRIVATE, -private$, '')
qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends")
qt_module_deps = $$replace(qt_module_deps, _private$, '')
qt_module_deps = $$unique(qt_module_deps)

for(dep, qt_module_deps) {
    METATYPES_FILENAME = $$lower($$eval(QT.$${dep}.module))_metatypes.json
    INSTALLED_METATYPES = $$[QT_INSTALL_LIBS]/metatypes/$$METATYPES_FILENAME
    isEmpty(MODULE_BASE_OUTDIR) {
        QML_FOREIGN_METATYPES += $$INSTALLED_METATYPES
    } else {
        MODULE_BASE_METATYPES = $$MODULE_BASE_OUTDIR/lib/metatypes/$$METATYPES_FILENAME
        exists($$MODULE_BASE_METATYPES): QML_FOREIGN_METATYPES += $$MODULE_BASE_METATYPES
        else: QML_FOREIGN_METATYPES += $$INSTALLED_METATYPES
    }
}


QML_TYPEREGISTRAR_FLAGS = \
    --generate-qmltypes=$$QMLTYPES_FILENAME \
    --import-name=$$QML_IMPORT_NAME \
    --major-version=$$QML_IMPORT_MAJOR_VERSION \
    --minor-version=$$QML_IMPORT_MINOR_VERSION \
    --foreign-types=$$join(QML_FOREIGN_METATYPES, ',')

DEPENDENCIESFILE = $$_PRO_FILE_PWD_/dependencies.json
exists($$DEPENDENCIESFILE): QML_TYPEREGISTRAR_FLAGS += --dependencies=$$DEPENDENCIESFILE

!isEmpty(MODULE_PRIVATE_INCLUDES): QML_TYPEREGISTRAR_FLAGS += --private-includes

METATYPES_JSON = $${TARGET_BASENAME}_metatypes.json

TYPEREGISTRATIONS = $${TARGET_BASENAME}_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 {
    INSTALL_QML_FILES = false

    android {
        build_pass {
            isEmpty(ANDROID_ABIS): ANDROID_ABIS = $$ALL_ANDROID_ABIS
            ABI = $$first(ANDROID_ABIS)
            equals(ABI,  $$QT_ARCH): INSTALL_QML_FILES = true
        }
    } else: !debug_and_release|!build_all|CONFIG(release, debug|release): INSTALL_QML_FILES = true

    equals(INSTALL_QML_FILES, true) {
        isEmpty(QMLTYPES_INSTALL_DIR): \
            QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/$$TARGETPATH
        do_install_qmltypes.files = $$OUT_PWD/$$QMLTYPES_FILENAME
        do_install_qmltypes.path = $$QMLTYPES_INSTALL_DIR
        do_install_qmltypes.CONFIG += no_check_exist
        prefix_build: INSTALLS += do_install_qmltypes
        else: COPIES += do_install_qmltypes
    }
}

QMAKE_EXTRA_COMPILERS += qmltyperegistrar_compiler qmltyperegistrar_qmltypes