问题描述
我有一个脚本runScript.sh,我希望在编写应用程序之前先运行它(以设置一些环境变量等).
I have a script, runScript.sh, that I would like to have run (to setup some environment variables and such) BEFORE making the application.
在我的计算机上使用来自QMake的程序/脚本的建议 .pro文件,我在第一行,
Using advice from Running a program/script from QMake, in my .pro file, I have on the first line,
QMAKE_POST_LINK += ./runScript.sh
,它将在make
上编译并链接我的应用程序,然后运行脚本.
which will, on a make
, compile and link my application and THEN run the script.
我看过如何在.pro文件中将脚本设置为目标,但是我不确定我是否完全理解这个概念.有人可以更好地解释它,或者(甚至更好)有人知道如何做我想做的更简单的事情(我希望有一个"QMAKE_PRE_LINK",但这似乎并不存在)?
I've seen examples of how to set the script up as a target in the .pro file,but I am not sure if I quite grasp the concept. Could someone explain it better or (even better) does anyone know how to do what I'm trying to do simpler (I was hoping for a "QMAKE_PRE_LINK" but that does not seem to exist lol)?
使用Qt-4.8.4& qmake 2.03
Using Qt-4.8.4 & qmake 2.03
推荐答案
您发布的链接对此进行了很好的解释.
Link you've posted explains that very well.
extralib.target = extra
extralib.commands = echo "Building extralib.."; \ # Run your programs here
make -w -C ../my_libraries/extralib; \
echo "Done building extralib."; \
extralib.depends =
QMAKE_EXTRA_TARGETS += extralib
PRE_TARGETDEPS = extra
因此,可以将其重写为
extralib.target = extra
extralib.commands = echo "Setuping the envirovment.."; \
export MYVAR="/usr/src/whatever" \
export SECONDVAR="/home/user" \
./runScript.sh
extralib.depends =
QMAKE_EXTRA_TARGETS += extralib
PRE_TARGETDEPS = extra
这篇关于Qt:在制作之前运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!