Skip to content

Commit a1f8b0c

Browse files
committed
added qmake target for generating files from templates
1 parent d19460b commit a1f8b0c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Sync-my-L2P.pro

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ CONFIG += c++11
44
VERSION = "2.4.2"
55
VERSION_CODE = "20402"
66

7-
message("generate files from templates ...")
7+
TEMPLATE_FILES = include/version.h.template \
8+
gui/info.ui.template \
9+
windows/SyncMyL2P.xml.template
10+
11+
template_compiler.input = TEMPLATE_FILES
12+
template_compiler.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_IN_BASE}
13+
template_compiler.depends = ${QMAKE_FILE_IN} Sync-my-L2P.pro
814
win32|win64 {
9-
UNUSED = $$system(powershell -Command \"(Get-Content -Encoding utf8 \\\"include/version.h.template\\\").Replace(\\\"__PRODUCT_VERSION_CODE\\\",\\\"$$VERSION_CODE\\\").Replace(\\\"__PRODUCT_VERSION\\\",\\\"$$VERSION\\\") | Set-Content -Encoding utf8 -Path include/version.h\")
10-
UNUSED = $$system(powershell -Command \"(Get-Content -Encoding utf8 \\\"gui/info.ui.template\\\").Replace(\\\"__PRODUCT_VERSION_CODE\\\",\\\"$$VERSION_CODE\\\").Replace(\\\"__PRODUCT_VERSION\\\",\\\"$$VERSION\\\") | Set-Content -Encoding utf8 -Path gui/info.ui\")
11-
UNUSED = $$system(powershell -Command \"(Get-Content -Encoding utf8 \\\"windows/SyncMyL2P.xml.template\\\").Replace(\\\"__PRODUCT_VERSION_CODE\\\",\\\"$$VERSION_CODE\\\").Replace(\\\"__PRODUCT_VERSION\\\",\\\"$$VERSION\\\") | Set-Content -Encoding utf8 -Path windows/SyncMyL2P.xml\")
15+
template_compiler.commands = powershell -Command \"(Get-Content -Encoding utf8 \\\"${QMAKE_FILE_IN}\\\").Replace(\\\"__PRODUCT_VERSION_CODE\\\",\\\"$$VERSION_CODE\\\").Replace(\\\"__PRODUCT_VERSION\\\",\\\"$$VERSION\\\") | Set-Content -Encoding utf8 -Path ${QMAKE_FILE_OUT}\"
1216
}
1317
unix {
14-
UNUSED = $$system(sed 's/__PRODUCT_VERSION_CODE/$$VERSION_CODE/g' ./include/version.h.template | sed 's/__PRODUCT_VERSION/$$VERSION/g' > ./include/version.h)
15-
UNUSED = $$system(sed 's/__PRODUCT_VERSION_CODE/$$VERSION_CODE/g' ./gui/info.ui.template | sed 's/__PRODUCT_VERSION/$$VERSION/g' > ./gui/info.ui)
18+
template_compiler.commands = sed 's/__PRODUCT_VERSION_CODE/$$VERSION_CODE/g' ${QMAKE_FILE_IN} | sed 's/__PRODUCT_VERSION/$$VERSION/g' > ${QMAKE_FILE_OUT}
1619
}
20+
template_compiler.CONFIG = target_predeps no_link
21+
QMAKE_EXTRA_COMPILERS += template_compiler
1722

1823
macx {
1924
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15

0 commit comments

Comments
 (0)