use*_*001 6 c++ qt qmake makefile qt5
我有一个QT项目,在运行时为系统安装服务make install.该.pro文件的相关部分如下:
init.path = /etc/init.d/
init.files = myservicename
updaterc.path = /etc/init.d/
updaterc.extra = chmod 755 $$init.files; \
update-rc.d $$init.files defaults 97 03; \
service $$init.files start
INSTALLS += target ... init updaterc
Run Code Online (Sandbox Code Playgroud)
这将正确安装服务,然后启动它.
但是,当我运行时make uninstall,虽然已正确删除已安装的文件,但该服务仍保持安装并正在运行.我想在运行时停止和卸载服务make uninstall.
停止和卸载服务的命令如下:
sudo service myservicename stop
sudo update-rc.d -f myservicename remove
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何将上述命令集成到.pro文件中,以便qmake能够理解它们并在Makefile中创建相关规则.
我在这个主题上找到的唯一文档是这样的:http://doc.qt.io/qt-5/qmake-advanced-usage.html,但它没有提到有关卸载的任何内容.
小智 7
尝试使用.uninstall命令.
mytarget2.path = ~/Documents/inst
mytarget2.target = test.txt
mytarget2.commands = @echo "custom command"
mytarget2.uninstall = @echo "uninstall"
INSTALLS += mytarget2
Run Code Online (Sandbox Code Playgroud)
它会生成这个makefile:
####### Install
install_mytarget2: first FORCE
@test -d $(INSTALL_ROOT)/Users/mac/Documents/inst || mkdir -p $(INSTALL_ROOT)/Users/mac/Documents/inst
@echo custom command
uninstall_mytarget2: FORCE
@echo uninstall
-$(DEL_DIR) $(INSTALL_ROOT)/Users/mac/Documents/inst/
install: install_mytarget2 FORCE
uninstall: uninstall_mytarget2 FORCE
FORCE:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
693 次 |
| 最近记录: |