Im using arduino ide 1.8. i'm not exactly sure what script/file is used when the upload button in ide is clicked.
I want to add some commands to duplicate the the sketch directory im working from and rename the duplicate. Basically saving a copy original sketch to another directory and then save/compile/modify the new sketch..
The working directory for the sketch wont change, just ide backup the sketch and save it with incremented number in some other folder before the changes are saved.
Any way to modify the ide behavior without re-compiling from source?
I don't know about modifying the IDE, but you can use the IDE from the command line. So that being the case you can write a batch file, a python script, or the like to take the ino, copy the directory, then compile and upload.
I periodically copy the folder with all my saved sketches .
When I open a sketch to modify , I save it straight away with an incremented version number … e.g “ mysketch_v1”. , “mysketch_v2”.
You can also add some comments at the top to detail your mods . You could also look at GitHub, to track your changes automatically ( something I want to look at , as I share some stuff). Wot is GitHub ?
Hi @notsolowki. The commands that run when you click the "Upload" button in the Arduino IDE are defined by the Arduino boards platform of the board you have selected at that time from the Tools > Board menu.
This is not part of the source code of the Arduino IDE application, but separate configuration files distributed by each boards platform author (other than the "Arduino AVR Boards" platform that comes preinstalled with the IDE, you usually install them via the Arduino IDE Boards Manager).
You can learn all about the Arduino boards platform system here:
You could probably create a "pre-build hook" in platforms.txt that would back up your files for you, especially if you're not too worried about the resulting installation being "portable" to other OSes.
See: Platform specification - Arduino CLI
Most of us old-timers have out own methodology for back-up and I suspect it runs the complexity gamut. One concern you may not have considered is your sketch backup may be out-of-sync with your external libraries.
In my backup scenario, all libraries are in the sketch folder; that is, no external dependencies exist. Back a few years ago when I was publishing I quickly realized I had to protect myself from library time-warp. Thus when I attach code in ZIP format, I am reasonably certain a novice can compile it error free: excepting IDE version and OS environmental concerns.
I'm starting to use 1.8.x portable installs per project. So libraries can be installed in the 'usual' location. When as project is completed, I backup the complete installation directory which contains everything that is needed (including IDE, board packages, libraries and sketches).
The install directory of the IDE is names after the project; new project, new installation of the IDE. A bit expensive on disk space but for me it's worth it.