2023-10-18 07:23 AM
Folks,
Is there a way to have a variable that is incremented each time the project is compiled? I can do this with Rowley Crossworks and it's really useful. I define and major and minor number then a build number gets incremented each time I compile and I can get those vlaues when I interrogate the device using a CLI.
Thanks
Solved! Go to Solution.
2023-10-18 02:05 PM
Write your script/program to do whatever you need. Then call it from the "pre-build" steps in the project's C/C++ Build settings. Go to the project properties, then expand "C/C+ Build" on the left side, then click on "settings". In the right side, click on the "Build Steps" tab.
2023-10-18 07:48 AM
Not built in to the IDE, though there are probably Eclipse add-ons that do this. But you can add your own pre-build or post-build steps to do that. Run a script file that mods the value inside a .c file. I use the pre-build steps to insert the GIT commit hash into a variable, and the post-build steps to further process the hex/binary files (add CRC/SHA hashes, etc.). Even on Windows, the IDE runs a Linux compatible shell so you have sed available.
2023-10-18 09:12 AM
Hi, thanks for the reply.
When you say script, I'm guessing you mean you can get, say, a Python script to automatically run once you hit CTL-B, but before it actually does the compile?
If so, how do you implement the running of that script please? I can write the Python much easier than I can a bash script (I am running Linux so could run the latter at a push, although Python is likely better as some colleagues are unfortunate enough to have to run Windows.
Thanks!
2023-10-18 02:05 PM
Write your script/program to do whatever you need. Then call it from the "pre-build" steps in the project's C/C++ Build settings. Go to the project properties, then expand "C/C+ Build" on the left side, then click on "settings". In the right side, click on the "Build Steps" tab.
2023-10-19 01:19 AM
Great, thanks very much. :)