summaryrefslogtreecommitdiff
path: root/mkspecs/features/ivigenerator.prf
blob: fcbd729a491aaf900dec9a280c85d7a7f1a41c53 (plain)
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
# Custom compiler for qface:
#
# Example input:
#   QFACE_SOURCES += my.foo.qface [required]
#   QFACE_MODULE_NAME = my_module_name
#   QFACE_FORMAT = frontend (or backend, simulator... -- defaults to "frontend")
#   QFACE_OUTPUT_DIR = my_output_dir (defaults to current build dir)
#

isEmpty(QFACE_FORMAT): QFACE_FORMAT = frontend
isEmpty(QFACE_OUTPUT_DIR): QFACE_OUTPUT_DIR = $$OUT_PWD
isEmpty(QFACE_SOURCES): error("QFACE_SOURCES must be set!")

!contains(QFACE_SOURCES, .+\\.qface$) {
    error("Invalid qface file provided: The file needs to end with .qface")
}

QFACE_PWD = $$dirname(QFACE_SOURCES)
QFACE_ABS_PWD = $$absolute_path($$QFACE_PWD, $$_PRO_FILE_PWD_)
QFACE_FILE = $$basename(QFACE_SOURCES)
QFACE_BASE_NAME = $$replace(QFACE_FILE, .qface, )
QFACE_YAML = $$QFACE_ABS_PWD/$${QFACE_BASE_NAME}.yaml
isEmpty(QFACE_MODULE_NAME): QFACE_MODULE_NAME = $$QFACE_BASE_NAME

# Detect whether we are using the feature inside the qtivi repository
isEmpty(QTIVI_BUILD_ROOT): VIRTUALENV_PATH = $$[QT_HOST_BINS]/ivigenerator/qtivi_qface_virtualenv
else: VIRTUALENV_PATH = $$QTIVI_BUILD_ROOT/src/tools/ivigenerator/qtivi_qface_virtualenv

isEmpty(QTIVI_ROOT): IVI_GENERATOR_PATH = $$[QT_HOST_BINS]/ivigenerator
else: IVI_GENERATOR_PATH = $$QTIVI_ROOT/src/tools/ivigenerator

win32: VIRTUALENV_ACTIVATION =  $$VIRTUALENV_PATH/Scripts/activate &&
else: VIRTUALENV_ACTIVATION = . $$VIRTUALENV_PATH/bin/activate &&
IVI_GENERATOR = $$VIRTUALENV_ACTIVATION python $$IVI_GENERATOR_PATH/generate.py

# TODO make this work with multiple input files, or only support one QFACE_SOURCE
qface_sources.output = $$QFACE_OUTPUT_DIR/$${QFACE_MODULE_NAME}.pri
qface_sources.commands = $$IVI_GENERATOR -f $$QFACE_FORMAT ${QMAKE_FILE_NAME} $$QFACE_OUTPUT_DIR
qface_sources.input = QFACE_SOURCES
qface_sources.depends = $$IVI_GENERATOR_PATH/generate.py
qface_sources.CONFIG += target_predeps no_link

# Add all templates of the generator format as dependency
QFACE_TEMPLATE_PWD = $$IVI_GENERATOR_PATH/templates_$${QFACE_FORMAT}
exists($$QFACE_TEMPLATE_PWD) {
    qface_sources.depends += $$files($${QFACE_TEMPLATE_PWD}/*)
}

# Add the configuration yaml as dependency and to other files
exists($$QFACE_YAML) {
    qface_sources.depends += $$QFACE_YAML
    OTHER_FILES += $$QFACE_YAML
}

# Reevaluate the Makefile after the generation has finished
Makefile.target = $$MAKEFILE
# The relative_path is needed here as qmake will use a relative_path for the output files
# when using a QMAKE_EXTRA_COMPILER
Makefile.depends = $$relative_path($$qface_sources.output, $$OUT_PWD)

# Make the qmake_all target work for usage inside QtCreator
# Because of the Makefile target the generator is called before the actual Makefile
# is evaluated. This is a problem if the virtualenv is not created yet.
# In this case we create the target with a dependency to the forceRebuild file.
# This file is created during the qmake run and updated once the virtualenv is ready
# and will then cause a rerun of qmake
!isEmpty(QTIVI_ROOT):!exists($$VIRTUALENV_PATH): {
    Makefile.depends = $$shadowed($$IVI_GENERATOR_PATH)/forceRebuild
}

# After the generation, this should exists and qmake can create the correct build tree
exists($$qface_sources.output) {
    include($$qface_sources.output)
}

QMAKE_EXTRA_COMPILERS += qface_sources
QMAKE_EXTRA_TARGETS += Makefile