-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Arduino CLI (instead of IDE) backend #206
Comments
I think this is a duplicate of #147. |
Oh, scratch that, that issue about compiling the unit tests with arduino-cli, IIUC, this issue is about compiling the examples/sketches with arduino-cil. Totally different thing (and this one is probably a lot less invasive to implement). |
That's my hope. So if that can go smoothly, all that's needed is to write down what flags drive each command. Here's the interface I had made for the "linux builder" CLI which IIRC was a beta version of that CLI (which wasn't as mature as I needed it to be at the time I initially wrote the library): require "arduino_ci/host"
require 'arduino_ci/arduino_cmd'
module ArduinoCI
# Implementation of Arduino linux CLI commands
class ArduinoCmdLinuxBuilder < ArduinoCmd
flag :get_pref, "--get-pref" # apparently doesn't exist
flag :set_pref, "--pref" # apparently doesn't exist
flag :save_prefs, "--save-prefs" # apparently doesn't exist
flag :use_board, "-fqbn"
flag :install_boards, "--install-boards" # apparently doesn't exist
flag :install_library, "--install-library" # apparently doesn't exist
flag :verify, "-compile"
end
end If you know the flags to accomplish all these operations in the CLI, this might be a quick win. There might also be some workaround; |
I haven't done too much with arduino-cli, but I can try to comment. Wrt prefs, For installing boards (rather, cores that supply boards):
Note that you can pass For libraries, there is:
This even allows installing libraries outside of the library manager by supplying a direct git url, but I'm not sure what the constraints are for that. For compiling, there is:
With |
You can set them via environment variables:
Yeah, that is not currently necessary, but it will be soon due to arduino/arduino-cli#1051. However, this option is not available in the current release version of Arduino CLI because it was just added a few weeks ago (arduino/arduino-cli#1042) The backwards compatible way to do it is by setting the |
@per1234 this may be a stupid question, but is the IDE a prerequisite for installing the CLI? I don't see anything in the README to indicate that it would be... but I don't want to run into arduino/Arduino#9351 I'm just hacking my way through it at the moment but if I'm definitely headed for a blocker then I'll pick something else to work on in the meantime. |
No. The CLI is completely standalone. One thing that might be surprising to people accustomed to the ways of the Arduino IDE is that Arduino IDE comes with a bundled copy of the Arduino AVR Boards platform, while Arduino CLI doesn't come with anything bundled. So after installing the Arduino IDE, you can immediately start compiling sketches for the Uno et al, which is a good thing for beginners, but wasteful if you are only using other architectures and have no need for the whole AVR toolchain. Some 3rd party AVR boards platforms are configured/documented with the assumption that the |
I made good progress with this, happening in #218 now. If If I'm understanding correctly, the |
By some mysterious twist of fate, I found myself working with the people who make that magic happen. I can't claim to make much of a significant contribution, but it's certainly a privilege to have even a small role in such an important project. I'm glad if you find it to be useful for your project!
The mechanism is there to do so (https://arduino.github.io/arduino-cli/latest/package_index_json-specification/#__code_3:~:text=toolsDependencies,-%3A%20the), but it all depends on whether the boards platform author has defined the tools dependencies in their package index. As I mentioned in my previous comment, some 3rd party platform authors (typically AVR) don't bother to define the tools dependencies because an Arduino IDE user will already have them installed. Platforms can reference resources from other platforms (core libraries, core variants, tool recipes) (https://arduino.github.io/arduino-cli/latest/platform-specification/#referencing-another-core-variant-or-tool), and in this case there is a dependency on that other platform being installed. There isn't currently a mechanism for programmatically defining a dependency on another platform (though there is an open feature request for this), so in this case the platform author must rely on the user to install the referenced platform. For example, https://github.com/damellis/attiny references
With any of the official Arduino boards platforms, the complete installation of all dependencies is accomplished with a single |
The more progress I make on this, the more I'm curious whether arduino-cli would adopt unit testing support (i.e. merge from this library) at some future point. Assuming #169 is received favorably, arduino_ci is simply delegating everything except the unit test / mock library to the CLI tool. |
@ianfixes A related report is arduino/arduino-cli#936 where others have similar thoughts (not sure why I only remembered this now). |
That is excellent, thanks for letting me know! |
Feature Request
There are many benefits to using the Arduino CLI instead of the IDE to run commands. But the IDE was the only way when this project was written.
Update
ArduinoCmd
(arduino_cmd.rb
) to use the CLI instead of IDE.This is expected to fix #137 as well as the issue of "hidden built-in" libraries like Ethernet.
This also will satisfy cross-platform, see #180 (comment)
The text was updated successfully, but these errors were encountered: