Because I have multiple devices (UNOs and various clones, ESP modules, STM board etc.), I've started using this little bit of code to keep track of what they have been programmed with.
// DW to keep track of code versions etc.
String compiled = "";
String filenm = "";
String deviceName = "";
// the setup function runs once when you press reset or power the board
void setup() {
// DW to print filename and date/time compiled
Serial.begin(115200);
delay (2000); // wait for uart to settle
Serial.println();
filenm = __FILE__ ;
Serial.println(filenm);
compiled = __DATE__ ;
compiled = compiled + " " + __TIME__ ;
Serial.print("Complied at ");
Serial.println(compiled);
Serial.println();
// start your 'original' sketch here, remember that you have already setup the serial port above,
// no need to do it again.
OUTPUT on Serial monitor is like this:
C:\Users\Dave\Documents\Arduino\ic2_scanner\ic2_scanner.ino
Complied at Oct 20 2016 06:19:28
Thanks. That is a quite useful thing. I'm considering a method to manage all related information of the uploaded program likes version, date, default parameters, change logs...
Anyone suggests another method should be used. Thanks
At work, I have a pretty complex java project. I use git to tag versions, ant to build it, and there is an ant task 'gitant' that knows how to talk to git. The result gets stamped with a version and environment (DEV/TEST/PROD), or if the git directory is "dirty" it gets stamped as being an incremental build.
Seeing as the IDE is java based, and ant is just java, it might be possible to re-engineer it so that it generates a build.xml for the project and internally uses ant to do the build. Modifying that build.xml would let you do stuff.
Maybe if the IDE had a button that would spit out the build steps as a script.
Alternatively, maybe there's already a page on this site that explains what the IDE does in a build in such a way that you could write a script to do what it does. You could then hack up that script.