Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
728 views
in Technique[技术] by (71.8m points)

makefile - Qt: Run a script BEFORE make

I have a script, runScript.sh, that I would like to have run (to setup some environment variables and such) BEFORE making the application.

Using advice from Running a program/script from QMake, in my .pro file, I have on the first line,

QMAKE_POST_LINK += ./runScript.sh

which will, on a make, compile and link my application and THEN run the script.

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)?

Using Qt-4.8.4 & qmake 2.03

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

So, that could just be rewritten as

    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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...