build rules moved to qskqvg.prf

This commit is contained in:
Uwe Rathmann 2020-05-23 19:29:20 +02:00
parent 495c91ce33
commit 64f4207153
5 changed files with 115 additions and 145 deletions

View File

@ -1,4 +1,4 @@
CONFIG += qskexample
CONFIG += qskexample qskqvg
HEADERS += \
ButtonBar.h \
@ -23,11 +23,11 @@ SOURCES += \
SpeedometerSkinlet.cpp \
SpeedometerDisplay.cpp
QRCFILES += \
RESOURCES += \
images.qrc
IMGSOURCES = \
images/background.jpg
QVGRESOURCES += \
qvgfiles.qrc
SVGSOURCES = \
images/car.svg \
@ -47,76 +47,3 @@ SVGSOURCES = \
images/plane.svg \
images/train.svg \
images/user.svg
###########
# The rcc file includes the precompiled SVGs and so we need to build
# rules for running svg2qvg, when a SVG has changed into the Makefile
# before running rccgen.
# While this would be an easy one in Makefile syntax it is a nightmare
# with qmake.
# TODO: we should at least offer some sort of *.pri file to help with
# writing application project files.
###########
# Convert path to shell path, otherwise it fails on Windows.
SVG2QVG=$$shell_path($${QSK_OUT_ROOT}/tools/bin/svg2qvg)
svg2qvg.name = SVG compiler
svg2qvg.input = SVGSOURCES
svg2qvg.output = qvg/${QMAKE_FILE_BASE}.qvg
svg2qvg.variable_out =
svg2qvg.commands += ($$sprintf($${QMAKE_MKDIR_CMD}, qvg)) && $${SVG2QVG} ${QMAKE_FILE_IN} $${svg2qvg.output}
imgcpy.name = Image copy
imgcpy.input = IMGSOURCES
imgcpy.output = images/${QMAKE_FILE_BASE}.jpg
imgcpy.variable_out =
imgcpy.commands += ($$sprintf( $${QMAKE_MKDIR_CMD}, images)) && $${QMAKE_COPY} ${QMAKE_FILE_IN} $${imgcpy.output}
rccgen.name = RCC compiler
rccgen.input = QRCFILES
rccgen.output = $${RCC_DIR}/qrc_${QMAKE_FILE_BASE}.cpp
rccgen.variable_out = SOURCES
rccgen.commands += ($$sprintf($${QMAKE_MKDIR_CMD}, $${RCC_DIR}))
!equals( OUT_PWD, $${PWD} ) {
# Paths inside a qrc file are always relative to the path of the
# qrc file itself. So in case of shadow builds we need to copy the
# qrc file into the shadow directory as the included qvg files
# are generated locally.
QRC_SHADOW_CLONE = $$shell_path($${OUT_PWD}/${QMAKE_FILE_BASE}_shadow.qrc)
rccgen.commands += && $${QMAKE_COPY} ${QMAKE_FILE_IN} $${QRC_SHADOW_CLONE}
# Use shell_path again to prevent from path error under Windows
rccgen.commands += && $$shell_path($$dirname(QMAKE_QMAKE)/rcc) $${QRC_SHADOW_CLONE} -o ${QMAKE_FILE_OUT}
rccgen.commands += && $${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE}
rccgen.depends += $${IMGSOURCES}
QMAKE_EXTRA_COMPILERS += imgcpy
}
else {
rccgen.commands += && $$dirname(QMAKE_QMAKE)/rcc ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
}
# We would like to define a dependency for "svg2qvg.variable_out" -
# but how to do this ? As long as we don't have a solution we have to use
# the workaround below.
defineReplace(qvgfiles) {
svgfiles = $$1
myfiles=
for(svgfile, svgfiles) myfiles += $$replace(svgfile, svg, qvg)
myfiles2=
for(myfile, myfiles) myfiles2 += $$replace(myfile, images, qvg)
return($$myfiles2)
}
rccgen.depends += $$qvgfiles( $${SVGSOURCES} )
QMAKE_EXTRA_COMPILERS += svg2qvg rccgen

View File

@ -3,24 +3,6 @@
<qresource>
<file>images/background.jpg</file>
<file>qvg/car.qvg</file>
<file>qvg/bluetooth.qvg</file>
<file>qvg/bookmark.qvg</file>
<file>qvg/bus.qvg</file>
<file>qvg/cloud.qvg</file>
<file>qvg/location.qvg</file>
<file>qvg/man.qvg</file>
<file>qvg/menu.qvg</file>
<file>qvg/phone.qvg</file>
<file>qvg/plane.qvg</file>
<file>qvg/train.qvg</file>
<file>qvg/user.qvg</file>
<file>qvg/down.qvg</file>
<file>qvg/left.qvg</file>
<file>qvg/right.qvg</file>
<file>qvg/up.qvg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,26 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
<file>qvg/car.qvg</file>
<file>qvg/bluetooth.qvg</file>
<file>qvg/bookmark.qvg</file>
<file>qvg/bus.qvg</file>
<file>qvg/cloud.qvg</file>
<file>qvg/location.qvg</file>
<file>qvg/man.qvg</file>
<file>qvg/menu.qvg</file>
<file>qvg/phone.qvg</file>
<file>qvg/plane.qvg</file>
<file>qvg/train.qvg</file>
<file>qvg/user.qvg</file>
<file>qvg/down.qvg</file>
<file>qvg/left.qvg</file>
<file>qvg/right.qvg</file>
<file>qvg/up.qvg</file>
</qresource>
</RCC>

View File

@ -1,4 +1,4 @@
CONFIG += qskexample
CONFIG += qskexample qskqvg
HEADERS += \
MainWindow.h
@ -7,7 +7,7 @@ SOURCES += \
MainWindow.cpp \
main.cpp
QRCFILES += \
QVGRESOURCES += \
qvgviewer.qrc
SVGSOURCES = \
@ -15,51 +15,3 @@ SVGSOURCES = \
svg/01.03.04q.svg \
svg/01.08.05q.svg \
svg/01.25.18.svg
# Convert path to shell path, otherwise it fails on Windows.
SVG2QVG=$$shell_path($${QSK_OUT_ROOT}/tools/bin/svg2qvg)
svg2qvg.name = SVG compiler
svg2qvg.input = SVGSOURCES
svg2qvg.output = qvg/${QMAKE_FILE_BASE}.qvg
svg2qvg.variable_out =
svg2qvg.commands += ($$sprintf($${QMAKE_MKDIR_CMD}, qvg)) && $${SVG2QVG} ${QMAKE_FILE_IN} $${svg2qvg.output}
rccgen.name = RCC compiler
rccgen.input = QRCFILES
rccgen.output = $${RCC_DIR}/qrc_${QMAKE_FILE_BASE}.cpp
rccgen.variable_out = SOURCES
rccgen.commands += ($$sprintf($${QMAKE_MKDIR_CMD}, $${RCC_DIR}))
!equals( OUT_PWD, $${PWD} ) {
# Paths inside a qrc file are always relative to the path of the
# qrc file itself. So in case of shadow builds we need to copy the
# qrc file into the shadow directory as the included qvg files
# are generated locally.
QRC_SHADOW_CLONE = $$shell_path($${OUT_PWD}/${QMAKE_FILE_BASE}_shadow.qrc)
rccgen.commands += && $${QMAKE_COPY} ${QMAKE_FILE_IN} $${QRC_SHADOW_CLONE}
# Use shell_path again to prevent from path error under Windows
rccgen.commands += && $$shell_path($$dirname(QMAKE_QMAKE)/rcc) $${QRC_SHADOW_CLONE} -o ${QMAKE_FILE_OUT}
rccgen.commands += && $${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE}
}
else {
rccgen.commands += && $$dirname(QMAKE_QMAKE)/rcc ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
}
# We would like to define a dependency for "svg2qvg.variable_out" -
# but how to do this ? As long as we don't have a solution we have to use
# the workaround below.
defineReplace(qvgfiles) {
svgfiles = $$1
myfiles=
for(svgfile, svgfiles) myfiles += $$replace(svgfile, svg, qvg)
return($$myfiles)
}
rccgen.depends += $$qvgfiles( $${SVGSOURCES} )
QMAKE_EXTRA_COMPILERS += svg2qvg rccgen

83
features/qskqvg.prf Normal file
View File

@ -0,0 +1,83 @@
##############################################################################
# rules to create qvg from svg files
##############################################################################
SVG2QVG=$$shell_path($${QSK_OUT_ROOT}/tools/bin/svg2qvg)
QVG_DIR=qvg
svg2qvg.name = SVG compiler
svg2qvg.input = SVGSOURCES
svg2qvg.output = $${QVG_DIR}/${QMAKE_FILE_BASE}.qvg
svg2qvg.variable_out =
svg2qvg.commands += ($$sprintf($${QMAKE_MKDIR_CMD}, $${QVG_DIR})) && $${SVG2QVG} ${QMAKE_FILE_IN} $${svg2qvg.output}
QMAKE_EXTRA_COMPILERS += svg2qvg
##############################################################################
# When using qvg files, that have to be generated from svg files, as resource,
##############################################################################
qvgrcc.name = RCC compiler
qvgrcc.input = QVGRESOURCES
qvgrcc.output = $${RCC_DIR}/qrc_${QMAKE_FILE_BASE}.cpp
qvgrcc.variable_out = SOURCES
qvgrcc.CONFIG += add_inputs_as_makefile_deps
# Paths inside a qrc file are always relative to the path of the
# qrc file itself. So in case of shadow builds we need to copy the
# qrc file into the shadow directory as the included qvg files
# are generated there.
QRC_SHADOW_CLONE = $$shell_path( $${OUT_PWD}/${QMAKE_FILE_BASE}_shadow.qrc )
qtPrepareTool(QMAKE_RCC, rcc, _DEP)
lessThan(QT_MAJOR_VERSION, 6): lessThan(QT_MINOR_VERSION, 12) {
# Since Qt 5.12 "rcc --list" works for qvg files, that do not yet exist
# To get these rules working for earlier versions we derive the qvg
# files from the SVGSOURCES
defineReplace(qvgfiles) {
svgfiles = $$1
files =
for( svgfile, svgfiles) {
filename = $$basename( svgfile )
files += $$shell_path( $${QVG_DIR}/$$replace( filename, svg, qvg ) )
}
return( $$files )
}
qvgrcc.depends += $$qvgfiles( $${SVGSOURCES} )
} else {
equals( OUT_PWD, $${_PRO_FILE_PWD_} ) {
qvgrcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
} else {
qvgrcc.depend_command = \
$${QMAKE_COPY} ${QMAKE_FILE_IN} $${QRC_SHADOW_CLONE} && \
$$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS $${QRC_SHADOW_CLONE} && \
$${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE}
}
}
equals( OUT_PWD, $${_PRO_FILE_PWD_} ) {
qvgrcc.commands = $$QMAKE_RCC $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
} else {
qvgrcc.commands = \
$${QMAKE_COPY} ${QMAKE_FILE_IN} $${QRC_SHADOW_CLONE} && \
$$QMAKE_RCC $$QMAKE_RESOURCE_FLAGS $${QRC_SHADOW_CLONE} -o ${QMAKE_FILE_OUT} && \
$${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE}
}
QMAKE_EXTRA_COMPILERS += qvgrcc