Changing variables on *.pro file don't affect the code
-
wrote on 21 Oct 2014, 08:55 last edited by
I have a project which stores part of its configuration on the *.pro file, the configuration is switched using a variable on the top of the file in order to make it easier for the team to change configurations, let's see a short example:
@# ------------------ #
Project connection
------------------
CONNECTIONS = ARRAKIS
------------------ #@
At the end of the *.pro file, all the "magic" is done:
@contains(CONNECTIONS, ARRAKIS) {
HOST_ADDRESS = "http://arrakis.dune.net"
API_ADDRESS = "/projects/foo/bar/baz/"
LOGIN_ADDRESS = "/projects/oauth/arrakis_login.php"
}contains(CONNECTIONS, NAMEK) {
HOST_ADDRESS = "http://namek.com"
API_ADDRESS = "/nyi/publicapi/"
LOGIN_ADDRESS = "/projects/oauth/namek_login.php"
}DEFINES += HOST_ADDRESS=\"$$HOST_ADDRESS\"
API_ADDRESS=\"$$API_ADDRESS\"
LOGIN_ADDRESS=\"$$LOGIN_ADDRESS\" @Finally in the C++ code, the defines configured on the project file are used like this:
@const QString HOST = QStringLiteral(HOST_ADDRESS);
const QString API = QStringLiteral(API_ADDRESS);
const QString LOGIN = QStringLiteral(LOGIN_ADDRESS);@So, what's the problem?
If someone changes the CONNECTIONS variable and builds the project, the binaries are generated with the values of the previous configuration unless a complete rebuild is performed, this is pretty cumbersome and makes all the configuration stuff nearly useless (due to the fact that rebuild this project takes several minutes).
What I have tryed so far?
Unexpected result (defines not updated).
Change configuration.
Build.
Unexpected result (defines not updated).
Change configuration.
Run qMake.
Build.
Expected result (defines updated).
Change configuration.
REBuild.
Expected result (defines updated).
Change configuration.
Make a dummy change in the cpp file that uses this defines (for example insert a new line)
Build.
Is there any way to achieve the expected results without rebuild the project or making dummy changes on the code?
Any help would be appreciated,
Thanks.
-
Hi and welcome to devnet,
Not the answer you would like but AFAIK, currently there's not.
[edit: corrected misleading typo]
-
wrote on 21 Oct 2014, 10:41 last edited by
[quote author="SGaist" date="1413887761"]Hi and welcome to devnet,
Not the answer you would like bug AFAIK, currently there's not. [/quote]
Sorry for my poor english skills ó_ò if I'm understanding well, you're saying that this is a bug?If it is a bug, could you lead me to report it (unless it is already reported).
-
Sorry it was a typo not bug
-
wrote on 21 Oct 2014, 10:51 last edited by
[quote author="SGaist" date="1413888427"]Sorry it was a typo not bug[/quote]
Danm! what a funny typo :D
You're right: unfortunately it's not the answer I'll like; now I only can pray for the Qt team to "fix" this.
Thanks a lot.
-
wrote on 21 Nov 2014, 11:08 last edited by
I've solved the problem using the touch command in the pro file:
touch(file_i_want_to_be_compiled_1.cpp, my_project.pro)
touch(file_i_want_to_be_compiled_2.cpp, my_project.pro)
touch(file_i_want_to_be_compiled_3.cpp, my_project.pro)
and so on...Isn't pretty, isn't neat... but it works.
-
wrote on 21 Nov 2014, 11:08 last edited by
I've solved the problem using the touch command in the pro file:
touch(file_i_want_to_be_compiled_1.cpp, my_project.pro)
touch(file_i_want_to_be_compiled_2.cpp, my_project.pro)
touch(file_i_want_to_be_compiled_3.cpp, my_project.pro)
and so on...Isn't pretty, isn't neat... but it works.
-
You could also use the find command to automate that a bit
-
You could also use the find command to automate that a bit