From 64f4207153b53e5159a5dbf02c82252a374a61aa Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 23 May 2020 19:29:20 +0200 Subject: [PATCH] build rules moved to qskqvg.prf --- examples/automotive/automotive.pro | 81 ++--------------------------- examples/automotive/images.qrc | 18 ------- examples/automotive/qvgfiles.qrc | 26 ++++++++++ examples/qvgviewer/qvgviewer.pro | 52 +------------------ features/qskqvg.prf | 83 ++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 145 deletions(-) create mode 100644 examples/automotive/qvgfiles.qrc create mode 100644 features/qskqvg.prf diff --git a/examples/automotive/automotive.pro b/examples/automotive/automotive.pro index cfb7b8bd..06c6e2b2 100644 --- a/examples/automotive/automotive.pro +++ b/examples/automotive/automotive.pro @@ -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 diff --git a/examples/automotive/images.qrc b/examples/automotive/images.qrc index 16c8761d..0c64b1e8 100644 --- a/examples/automotive/images.qrc +++ b/examples/automotive/images.qrc @@ -3,24 +3,6 @@ images/background.jpg - qvg/car.qvg - - qvg/bluetooth.qvg - qvg/bookmark.qvg - qvg/bus.qvg - qvg/cloud.qvg - qvg/location.qvg - qvg/man.qvg - qvg/menu.qvg - qvg/phone.qvg - qvg/plane.qvg - qvg/train.qvg - qvg/user.qvg - - qvg/down.qvg - qvg/left.qvg - qvg/right.qvg - qvg/up.qvg diff --git a/examples/automotive/qvgfiles.qrc b/examples/automotive/qvgfiles.qrc new file mode 100644 index 00000000..28d9e8a4 --- /dev/null +++ b/examples/automotive/qvgfiles.qrc @@ -0,0 +1,26 @@ + + + + + qvg/car.qvg + + qvg/bluetooth.qvg + qvg/bookmark.qvg + qvg/bus.qvg + qvg/cloud.qvg + qvg/location.qvg + qvg/man.qvg + qvg/menu.qvg + qvg/phone.qvg + qvg/plane.qvg + qvg/train.qvg + qvg/user.qvg + + qvg/down.qvg + qvg/left.qvg + qvg/right.qvg + qvg/up.qvg + + + + diff --git a/examples/qvgviewer/qvgviewer.pro b/examples/qvgviewer/qvgviewer.pro index fac0c2de..92646807 100644 --- a/examples/qvgviewer/qvgviewer.pro +++ b/examples/qvgviewer/qvgviewer.pro @@ -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 diff --git a/features/qskqvg.prf b/features/qskqvg.prf new file mode 100644 index 00000000..6664192b --- /dev/null +++ b/features/qskqvg.prf @@ -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 +