开发者

safely define Qt constants in a shell script

开发者 https://www.devze.com 2023-01-31 23:02 出处:网络
I have 6 versions of my application and I build then all every night. My .pro file looks like开发者_如何学Go that :

I have 6 versions of my application and I build then all every night. My .pro file looks like开发者_如何学Go that :

DEFINES += \
TEN_INCH \
#TG_MODULE \
NEW_DIALOG

Thus, so as to build the different version automatically, my shell script edits the .pro file, thanks to sed. This sucks because the defines must be on their own line, and Qt Creator sometimes put them all on the same (when adding a file for example). The result is that my build seems to work, but it isn't.

So, is there a better solution to do it ? Something like passing the defines to qmake ?


Do not edit your .pro file. Instead, use .pro file scopes:

build_one {
  DEFINES += whatever
}
build_two {
  DEFINES += something_else
}

And then activate them from qmake command line:

qmake CONFIG+=build_one && make clean && make


Hm, why don't you rewrite you script so it would form the whole DEFINES directive itself?

I.e. use sed to find existing one and replace it as a whole with newly formed one? In this case it wouldn't matter if it's on one line or spans several lines.

0

精彩评论

暂无评论...
验证码 换一张
取 消