Qt:在制作之前运行脚本 [英] Qt: Run a script BEFORE make

查看:238
本文介绍了Qt:在制作之前运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本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:在制作之前运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆