I am creating an OTA bundling tool. I'd like to find a way to ask the Arduino 2.3 IDE to run the Export Compiled Binaries menu command programmatically via a shell command (or possibly via AppleScript which seems less likely)
The Arduino CLI page says "Arduino CLI is the heart of all official Arduino development software (Arduino IDE, Arduino Web Editor)." Is the Arduino CLI interface included in the Arduino IDE installation and if so how do I make calls to it?
Hi @JoeHuber. I think you are on the right track with using Arduino CLI for this purpose. That will be far easier and more efficient than doing it through Arduino IDE.
It is. However, I think it will be easier to use a separate copy of Arduino CLI than using the executable that is bundled with the Arduino IDE installation. The separate copy of Arduino CLI will work exactly the same as the one bundled with the Arduino IDE installation. There are instructions for getting Arduino CLI here:
Thanks. My main concern is to avoid having to maintain two installs and keep code bases and libraries synchronized. I plan to continue to use the IDE for development and I just need a programatic way to ask it to Export Compiled Binaries.
Since you mention "AppleScript", I'll assume you are using macOS. If so, the arduino-cli executable is located at this path inside the Arduino IDE application:
Excellent! Thanks for the very fast and detailed info. That should do what I need.
Steve made a very interesting alternative suggestion too. It might be smarter to start and drive the whole process from the Arduino IDE than my separate helper app.
Wow, again you've been so helpful. Now that I have multiple options I'll have to think through the best combination of capabilities with the fewest risks and dependencies.
Steve's approach automatically starts the OTA bundling process when the compile is complete. But it seems vulnerable to surviving IDE updates which might overwrite the custom programmer files. And doesn't add auto versioning or build numbers.
Using a separate OTA bundling app to drive the IDE could tweak source files to add auto versioning, would seem to be relatively immune to IDE updates (maybe requiring a smart search to find the exact path to the new IDE) It also might have security issues for my app executing a CLI into the Arduino app.
If you want yet another option, you could create an extension for Arduino IDE. Unfortunately we don't have any formal documentation of the extension system, but it is the same as extensions for VS Code, and there is a lot of information available for creating VS Code extensions. You can start here:
The installation of extensions is a bit different in for Arduino IDE than for VS Code. The Arduino IDE extension installation instructions are provided here (themes are just a specific type of extension):
Arduino IDE does make some Arduino-specific information available to extensions, which would likely be needed by your extension. You can get some information about that by looking at the repository for the "VS Code Arduino API" extension (which is built into the Arduino IDE application) that provides this information, :
I'll list some Arduino IDE extensions that use that Arduino-specific information. You can use their codebases as a reference for understanding how to use the information in your own extensions:
You could work around that by creating a dedicated custom Arduino boards platform instead of modifying an existing platform. Creating and maintaining a custom boards platform might seem like a daunting task, but in a case like this where you only want to make some adjustments to the configuration of an existing platform, it is actually fairly simple. The reason is that you can reference all the resources from the existing platform, meaning your platform can consist of only a couple of files. The referencing system is documented here:
You can see an demonstration of such a minimal platform here:
This platform references most of its resources from the existing MightyCore boards platform, so it can consist of only a few files.
Or for a more significant example, here is a platform that leverages the resources of the Arduino AVR Boards platform:
You can configure the platform to run any arbitrary commands, so if you have some external command line tool or script that can add such things, then you can incorporate it into Arduino IDE's compilation process.
You might find the build hooks feature useful for that purpose:
I've been following all of your wonderful links and pointers all morning! Such an intriguing treasure hunt. I think I need to pick an approach and the create a skeleton to verify some of my assumptions before I go too much further.
This tidbit saved me so much time searching through the mountain of folders inside the app's bundle. With this info I was able to quickly add a mechanism to call out of my app and tell the arduino-cli to compile and export my sketch.
I discovered a small oversight in the arduino-cli documentation..... the compile command docs never tell you how to specify the path to the Sketch. There's an output path flag but not one for input. Luckily the examples make deducing the answer pretty straight forward.