-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
arduino-cli should provide "environments" #108
Comments
Just an additional idea: libraries installed in an environment should "override" libraries installed in the global (shared) environment |
I faked this up using a Docker image per "environment" I want to use. This lets me be very explicit about what each build platform sees. It's a WIP, and not currently public, but if there is interest I can share. I know others have similar base images, but for some reason I chose to make one from scratch. |
I'm not personally keen on environments, but having a system like the Node Package Manager (NPM) for managing libraries would be awesome. It could just use Github Repos to start with (no need to set up an official library registry... yet):
I would love to have a package.json file (or similar) though which lists required libraries, and then have the cli download them to the sketch directory as needed. You can also allow the user to install them globally like npm does, and that would fulfill @scls19fr's request. EDIT: Hold up. Libraries can be saved to the the ./src directory in a sketch directory. I could write a simple package manager cli utility that makes use of that fact. It would be a simple case of checking a package file and downloading the relevant code to ./src before calling |
+1 for using Docker, we're working on official releases for images shipping the CLI that should make this even easier. You can already have something really close to an env by setting up At this point we've no plan to add a sophisticated env manager with specific commands and stuff like global fallback but let's keep this issue open to collect feedback and alternative approaches. |
#32 was closed, pointing to this issue for further discussion. The core of that issue was to be able to include libraries in the sketch directory, in order to make a sketch directory more self-contained and easier to distribute to others. In this issue, a broader solution using environments is proposed, which serves a similar goal, but as @masci already says is quite a lot more sophisticated and thus less likely to be implemented. Also, it seems that such an environment-bases approach needs more setup (e.g. it needs the user to explicitly create an environment and install libraries into it), while the simplier " |
I have been looking into this topic for a while in order to improve the tooling we use and get a nice reproducible environment for an Arduino project I am working on, and I think there is a key insight here:
This can be done by placing a special file in the project root directory. We could call this file I think this solves a bunch of common problems previously reported by users and requires little change to the CLI. I would love to hear your opinions on it! |
I started working on a CI/CD pipeline for embedded systems and Arduino seemed like an easy target to start with. What I'd like is a stateless environment, if the developer has This change should allow at least install, compile and upload to be used without any parameters, all of them relying on the file present in the current workspace (like project.json, arduino-cli.json, etc.). Install should pull all the cores and libraries necessary to build the project. You shouldn't have to specify which cores, rather potential targets. Compile should create binaries for all target boards, right now the build output is straight into the project folder and upload depends on the output file name and location which is somewhat annoying. Upload should try to upload to a currently available board if there's a build for it. If the target is ambiguous it should prompt a port or FQBN specification. A draft of what the .json might look like.
So after these changes in a never before used environment all I need is:
I want to dockerize the build but also allow local builds, if I have to change the scripts I'll have to change the Dockerfile, not to mention that I want to use Github Actions as well. So simplifying these commands would make the process consistent no matter what the build environment is. |
Apparently, there is already a way to attach a board target to a sketch via the |
I have been looking for similar things for a while too. Just implemented a proof-of-concept Dockerized |
When people have to resort to docker to solve this problem, we've failed as a community. Why can't the cli just support things the way C has been handling libraries for decades? INCLUDES= and LDFLAGS= would be a nice start, same goes for -I and -L. The same goes for 'environments'. There is little to no reason to have environments if standard library support is permitted. It really feels like a lot of the work on the arduino side of things is 'reinventing makefiles'. |
My solution to this is to leverage the existing options in arduino-cli.yaml, and the ARDUINO_DATA_DIR environment variable, as mentioned above. I use a makefile where "make env" installs the arduino-cli, and the specified core and libraries. Everything is downloaded and cached within the project, essentially making it an isolated environment. The entire pipeline is reduced to four commands. Clone, make env, make, make upload. If anyone is interested, I've got a simple example here. |
@c4deszes if you're looking for CI, check out arduino_ci or the accompanying Arduino CI github action (full disclosure, I maintain them). @scls19fr could this be solved by placing multiple directories:
user: /path/to/environments/myenv I do this in the |
Use Codecov for recording and reporting code coverage information
In response to #32...
First I need to get arduino-cli.yaml directories.user setting. To do that, I catched the parse_yaml function from Stefan Farestam's answer and make some changes around the printf() function (and idented the awk script). Then, I created a utils.sh and pasted the code there. Lastly I putted that file in
This script just get the Arduino15 path and concatenates with "libraries" literal.
The With that I can include MyClock lib in My-Script.ino with |
Actually, we implemented the sketch project files, that should support something really similar to your use case: https://arduino.github.io/arduino-cli/latest/sketch-project-file/ |
How can we point our own libraries in this yml file? We just point the absolute path to it? |
This is not possible. Because we implemented the sketch project files as a system to have a reproducible environment. Using an unpublished library wouldn't allow such thing. |
@PhilippeBrissant |
@ubidefeo |
@PhilippeBrissant |
@PhilippeBrissant
and so on :) You can decide to have multiple libraries in a folder on your system and put them all there, but if you want to compile against a single library in development you're better off using |
As we continue grooming through issues, I'm coming back to this one and wonder if you have seen our support for profiles. Also in the work the option to support locally sourced libraries, but we're still playing around with vendored content :) https://arduino.github.io/arduino-cli/0.31/sketch-project-file/ |
Haven't really been looking at the Arduino ecosystem for a while but it's a promising development. I still think it needs a way to be able to download the libraries listed in the profiles like The ability to do this is arguably the number one reason Node.js took off like it did. It also appears that there would be a lot of duplicates if multiple boards are being targeted that use the same libraries but have slightly different config options for whatever reason. Maybe include a way to extend a profile if there isn't the option already. |
Actually, the profiles can do all of this already.
This is not possible as of now, the simple workaround is to copy the common libraries in each board's profile. Anyway, if you feel that this feature is compelling, please open a dedicated issue so we can discuss and track it properly. I'm closing this generic issue as completed since discussing single missing features in this "catch-all" issue may become quickly chaotic and not useful. |
Hello,
I wonder if the concept of "environment" (comparable to conda environments or Julia Pkg environments) have been considered (it could help to have several versions of a library installed without odd effects).
Here is a possible workflow for dealing with environment with arduino-cli :
Create an environment named
myenv
It should create an empty directory name
myenv
in~/Documents/Arduino/envs
List all existing environments
Add packages to this environment
Latest version of a package
A given version
(this will need #105 to be fixed)
(An environment could also be created directly from a file but this could probably be implemented later)
I assume core is installed in the global environment (because I think it's important to keep ability to have libraries and core installed in a shared manner)
This last command will use ArduinoJson==5.13.4 even if, for example, ArduinoJson==6.x.y is installed in the "global" environment.
What is your opinion of such an idea?
Kind regards
The text was updated successfully, but these errors were encountered: