Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12dfc6a

Browse filesBrowse files
committed
update project template to generate svc files
1 parent 1ab14cc commit 12dfc6a
Copy full SHA for 12dfc6a

File tree

Expand file treeCollapse file tree

11 files changed

+81
-54
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+81
-54
lines changed

‎ProjectTemplate/project.pro

Copy file name to clipboardExpand all lines: ProjectTemplate/project.pro
+35-5Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,49 @@ SOURCES += \\
1818
main.cpp \\
1919
%{SvcSrcName}
2020

21-
DISTFILES += \
21+
target.path = $$[QT_INSTALL_BINS]
22+
INSTALLS += target
2223
@if '%{CreateSystemd}'
23-
%{SvcSystemdName} \
24+
25+
linux:!android {
26+
# install targets for systemd service files
27+
QMAKE_SUBSTITUTES += %{SvcSystemdName}.in
28+
29+
install_svcconf.files += $$shadowed(%{SvcSystemdName})
2430
@if '%{SocketPort}'
25-
%{SvcSystemdSocketName} \
31+
install_svcconf.files += %{SvcSystemdSocketName}
2632
@endif
33+
install_svcconf.CONFIG += no_check_exist
34+
install_svcconf.path = $$[QT_INSTALL_LIBS]/systemd/system/
35+
INSTALLS += install_svcconf
36+
}
2737
@endif
2838
@if '%{CreateWindows}'
29-
%{SvcWindowsName} \
39+
40+
win32 {
41+
# install targets for windows service files
42+
QMAKE_SUBSTITUTES += %{SvcWindowsName}.in
43+
44+
install_svcconf.files += $$shadowed(%{SvcWindowsName})
45+
install_svcconf.CONFIG += no_check_exist
46+
install_svcconf.path = $$[QT_INSTALL_BINS]
47+
INSTALLS += install_svcconf
48+
}
3049
@endif
3150
@if '%{CreateLaunchd}'
32-
%{SvcLaunchdName} \
51+
52+
macos {
53+
# install targets for launchd service files
54+
QMAKE_SUBSTITUTES += %{SvcLaunchdName}.in
55+
56+
install_svcconf.files += $$shadowed(%{SvcLaunchdName})
57+
install_svcconf.CONFIG += no_check_exist
58+
install_svcconf.path = /Library/LaunchDaemons
59+
INSTALLS += install_svcconf
60+
}
3361
@endif
3462
@if '%{CreateAndroid}'
63+
64+
OTHER_FILES += \\
3565
AndroidManifest-service.part.xml
3666
@endif

‎ProjectTemplate/scinstall.bat

Copy file name to clipboardExpand all lines: ProjectTemplate/scinstall.bat
-3Lines changed: 0 additions & 3 deletions
This file was deleted.

‎ProjectTemplate/scinstall.bat.in

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
sc create %{ProjectName} binPath= "$${target.path}\\$$TARGET.exe --backend windows" start= demand displayname= "%{ProjectName} Service" || exit /B 1
3+
sc description %{ProjectName} "The %{ProjectName} Service" || exit /B 1

‎ProjectTemplate/service.plist renamed to ‎ProjectTemplate/service.plist.in

Copy file name to clipboardExpand all lines: ProjectTemplate/service.plist.in
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<string>%{SvcBundleName}</string>
77
<key>ProgramArguments</key>
88
<array>
9-
<string>/path/to/%{TargetName}</string>
9+
<string>$${target.path}/$$TARGET</string>
1010
<string>--backend</string>
1111
<string>launchd</string>
1212
</array>

‎ProjectTemplate/service.service renamed to ‎ProjectTemplate/service.service.in

Copy file name to clipboardExpand all lines: ProjectTemplate/service.service.in
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ After=network-online.target %{SvcSystemdSocketName}
88
[Service]
99
Type=notify
1010
NotifyAccess=exec
11-
ExecStart=/path/to/%{TargetName} -platform minimal --backend systemd
12-
ExecReload=/path/to/%{TargetName} -platform minimal --backend systemd reload $MAINPID
13-
ExecStop=/path/to/%{TargetName} -platform minimal --backend systemd stop $MAINPID
11+
ExecStart=$${target.path}/$$TARGET -platform minimal --backend systemd
12+
ExecReload=$${target.path}/$$TARGET -platform minimal --backend systemd reload $MAINPID
13+
ExecStop=$${target.path}/$$TARGET -platform minimal --backend systemd stop $MAINPID
1414
#WatchdogSec=10
1515
Restart=on-abnormal
16-
RuntimeDirectory=%{TargetName}
16+
RuntimeDirectory=$$TARGET
1717

1818
[Install]
1919
# Use the following for a system service

‎ProjectTemplate/wizard.json

Copy file name to clipboardExpand all lines: ProjectTemplate/wizard.json
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
[
1414
{ "key": "TargetName", "value": "%{JS: '%{ProjectName}'.toLowerCase()}" },
1515
{ "key": "ProFileName", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
16-
16+
1717
{ "key": "SvcCn", "value": "%{JS: Cpp.className('%{SvcName}')}" },
1818
{ "key": "SvcGuard", "value": "%{JS: Cpp.headerGuard('%{SvcHdrName}')}" },
19-
19+
2020
{ "key": "SvcSystemdName", "value": "%{JS: Util.fileName('%{JS: '%{SvcName}'.toLowerCase()}', 'service')}" },
2121
{ "key": "SvcSystemdSocketName", "value": "%{JS: Util.fileName('%{JS: '%{SvcName}'.toLowerCase()}', 'socket')}" },
2222
{ "key": "SvcWindowsName", "value": "%{JS: Util.fileName('%{JS: '%{SvcName}'.toLowerCase()}-install', 'bat')}" },
@@ -88,7 +88,7 @@
8888
"data": { "factor": 2 }
8989
},
9090
{
91-
"name": "SocketPort",
91+
"name": "SocketPort",
9292
"trDisplayName": "Socket-Activation port:",
9393
"type": "LineEdit",
9494
"mandatory": false,
@@ -98,7 +98,7 @@
9898
}
9999
},
100100
{
101-
"name": "BundlePrefix",
101+
"name": "BundlePrefix",
102102
"trDisplayName": "Bundle prefix:",
103103
"type": "LineEdit",
104104
"data": {
@@ -121,7 +121,7 @@
121121
"mandatory": true,
122122
"type": "LineEdit",
123123
"data":
124-
{
124+
{
125125
"trText": "%{ProjectName}Service",
126126
"validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)"
127127
}
@@ -187,8 +187,8 @@
187187
"target": "%{ProjectDirectory}/%{SvcSrcName}"
188188
},
189189
{
190-
"source": "service.service",
191-
"target": "%{ProjectDirectory}/%{SvcSystemdName}",
190+
"source": "service.service.in",
191+
"target": "%{ProjectDirectory}/%{SvcSystemdName}.in",
192192
"condition": "%{JS: '%{CreateSystemd}' !== ''}"
193193
},
194194
{
@@ -197,13 +197,13 @@
197197
"condition": "%{JS: '%{CreateSystemd}' !== '' && '%{SocketPort}' !== ''}"
198198
},
199199
{
200-
"source": "scinstall.bat",
201-
"target": "%{ProjectDirectory}/%{SvcWindowsName}",
200+
"source": "scinstall.bat.in",
201+
"target": "%{ProjectDirectory}/%{SvcWindowsName}.in",
202202
"condition": "%{JS: '%{CreateWindows}' !== ''}"
203203
},
204204
{
205-
"source": "service.plist",
206-
"target": "%{ProjectDirectory}/%{SvcLaunchdName}",
205+
"source": "service.plist.in",
206+
"target": "%{ProjectDirectory}/%{SvcLaunchdName}.in",
207207
"condition": "%{JS: '%{CreateLaunchd}' !== ''}"
208208
},
209209
{

‎examples/service/EchoControl/EchoControl.pro

Copy file name to clipboardExpand all lines: examples/service/EchoControl/EchoControl.pro
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ TARGET = EchoControl
44
QT += core gui widgets service
55

66
SOURCES += \
7-
main.cpp \
8-
controlwidget.cpp
7+
main.cpp \
8+
controlwidget.cpp
99

1010
HEADERS += \
11-
controlwidget.h
11+
controlwidget.h
1212

1313
FORMS += \
14-
controlwidget.ui
14+
controlwidget.ui
1515

1616
target.path = $$[QT_INSTALL_EXAMPLES]/service/$$TARGET
1717
INSTALLS += target
18-
19-
#add lib dir to rpath
20-
mac: QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../../lib\''

‎examples/service/EchoService/EchoService.pro

Copy file name to clipboardExpand all lines: examples/service/EchoService/EchoService.pro
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ SOURCES += \
1515
main.cpp \
1616
echoservice.cpp
1717

18-
target.path = $$[QT_INSTALL_EXAMPLES]/service/EchoService
19-
INSTALLS += target
20-
21-
#add lib dir to rpath
22-
mac: QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../../lib\''
23-
2418
DISTFILES += \
2519
echoservice.service \
2620
echoservice.socket \
27-
scinstall.bat \
28-
echoservice.plist
21+
scinstall.bat \
22+
echoservice.plist
23+
24+
target.path = $$[QT_INSTALL_EXAMPLES]/service/EchoService
25+
INSTALLS += target

‎examples/service/TerminalService/TerminalService.pro

Copy file name to clipboardExpand all lines: examples/service/TerminalService/TerminalService.pro
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ CONFIG -= app_bundle
99
TARGET = terminalservice
1010

1111
HEADERS += \
12-
terminalservice.h
12+
terminalservice.h
1313

1414
SOURCES += \
1515
main.cpp \
16-
terminalservice.cpp
16+
terminalservice.cpp
1717

1818
target.path = $$[QT_INSTALL_EXAMPLES]/service/TerminalService
1919
INSTALLS += target
20-
21-
#add lib dir to rpath
22-
mac: QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../../lib\''

‎qtservice.pro

Copy file name to clipboardExpand all lines: qtservice.pro
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ runtests.recurse += sub_tests sub_src
1515
QMAKE_EXTRA_TARGETS += runtests
1616

1717
DISTFILES += .qmake.conf \
18-
sync.profile
18+
sync.profile \
19+
ProjectTemplate/*

‎src/imports/service/service.pro

Copy file name to clipboardExpand all lines: src/imports/service/service.pro
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,25 @@ OTHER_FILES += qmldir
2020
CONFIG += qmlcache
2121
load(qml_plugin)
2222

23-
# overwrite the plugindump wrapper
24-
ldpath.name = LD_LIBRARY_PATH
25-
ldpath.value = "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$$[QT_INSTALL_LIBS]:$$(LD_LIBRARY_PATH)"
26-
qmlpath.name = QML2_IMPORT_PATH
27-
qmlpath.value = "$$shadowed($$dirname(_QMAKE_CONF_))/qml/:$$[QT_INSTALL_QML]:$$(QML2_IMPORT_PATH)"
28-
QT_TOOL_ENV = ldpath qmlpath
29-
qtPrepareTool(QMLPLUGINDUMP, qmlplugindump)
30-
QT_TOOL_ENV =
31-
3223
generate_qmltypes {
24+
# run again to overwrite module env
25+
ldpath.name = LD_LIBRARY_PATH
26+
ldpath.value = "$$shadowed($$dirname(_QMAKE_CONF_))/lib/:$$[QT_INSTALL_LIBS]:$$(LD_LIBRARY_PATH)"
27+
qmlpath.name = QML2_IMPORT_PATH
28+
qmlpath.value = "$$shadowed($$dirname(_QMAKE_CONF_))/qml/:$$[QT_INSTALL_QML]:$$(QML2_IMPORT_PATH)"
29+
PLGDUMP_ENV = ldpath qmlpath
30+
QT_TOOL_ENV = ldpath qmlpath
31+
qtPrepareTool(QMLPLUGINDUMP, qmlplugindump)
32+
QT_TOOL_ENV =
33+
3334
#overwrite the target deps as make target is otherwise not detected
3435
qmltypes.depends = ../../../qml/$$TARGETPATH/$(TARGET)
36+
OLDDMP = $$take_first(qmltypes.commands)
37+
qmltypes.commands = $$QMLPLUGINDUMP $${qmltypes.commands}
38+
message("replaced $$OLDDMP with $$QMLPLUGINDUMP")
3539

3640
mfirst.target = all
3741
mfirst.depends += qmltypes
3842
QMAKE_EXTRA_TARGETS += mfirst
3943
}
44+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.