Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added gRPC functions to manage libraries in profiles#3019

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cmaglie wants to merge19 commits intoarduino:master
base:master
Choose a base branch
Loading
fromcmaglie:grpc-profiles-functions

Conversation

@cmaglie
Copy link
Member

Please check if the PR fulfills these requirements

Seehow to contribute

  • The PR has no duplicates (please search among thePull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

This is an extract of#2917 containing only the gRPC part of the PR.

What is the current behavior?

Adds only the gRPC functions for managing libraries in profiles, no user-facing changes.

What is the new behavior?

Does this PR introduce a breaking change, and istitled accordingly?

No

Other information

@cmagliecmaglie self-assigned thisOct 3, 2025
@cmagliecmaglie added type: enhancementProposed improvement topic: gRPCRelated to the gRPC interface labelsOct 3, 2025
@per1234per1234 added the topic: codeRelated to content of the project itself labelOct 4, 2025
per1234
per1234 previously requested changesOct 5, 2025
@codecov
Copy link

codecovbot commentedOct 6, 2025
edited
Loading

Codecov Report

❌ Patch coverage is55.74230% with158 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.17%. Comparing base (8f81c72) to head (8b4b3a5).

Files with missing linesPatch %Lines
internal/arduino/sketch/profiles.go62.22%21 Missing and 13 partials⚠️
commands/service_profile_lib_add.go57.97%20 Missing and 9 partials⚠️
commands/service_profile_init.go48.83%13 Missing and 9 partials⚠️
commands/service_profile_lib_remove.go61.40%11 Missing and 11 partials⚠️
commands/service_profile_lib_list.go0.00%16 Missing⚠️
commands/service_profile_set_default.go0.00%14 Missing⚠️
commands/cmderrors/cmderrors.go0.00%9 Missing and 1 partial⚠️
commands/service_library_install.go62.50%4 Missing and 2 partials⚠️
commands/service_library_resolve_deps.go85.18%2 Missing and 2 partials⚠️
internal/arduino/libraries/librariesindex/index.go80.00%1 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##           master    #3019      +/-   ##==========================================- Coverage   69.42%   69.17%   -0.26%==========================================  Files         242      247       +5       Lines       18632    18935     +303     ==========================================+ Hits        12936    13099     +163- Misses       4502     4604     +102- Partials     1194     1232      +38
FlagCoverage Δ
unit69.17% <55.74%> (-0.26%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cmaglie added a commit to cmaglie/arduino-cli that referenced this pull requestOct 6, 2025
As stated by@per1234:> Build profile data is already provided via the LoadSketch method, so it> seems that even a mechanism that is truly for getting profile data should> be implemented by simply expanding the SketchProfile message to contain> all the data of the build profile (actually kind of silly that it> currently only provides a subset of the profile data).arduino#3019 (comment)
@per1234per1234 dismissed theirstale reviewOctober 6, 2025 13:17

Requested change has been made. Thanks!

// Name of the library.
stringname=1;
// Version of the library if taken from the Library Index.
stringversion=2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Clients would love to use a dedicated message to add the latest version of the library (without listing the available versions), and maybe add the currently installed version that errors if the library is not installed.

@cmagliecmaglieforce-pushed thegrpc-profiles-functions branch fromdbac430 to2327b35CompareOctober 29, 2025 10:00
@dankeboy36
Copy link
Contributor

Hello Cristian,

Thanks for your great work 💪 I’ve been testing this area from the IDE side and was wondering how this feature is expected to work with an IDE or editor. Maybe this isn’t the most appropriate channel, but I guess you’re the best person to ask.

It’s clear there’s a real need for this feature:

While reading the PR and the related IDE issuearduino/arduino-ide#2573, I was trying to understand how profiles are meant to behave over gRPC, maybe later in Arduino IDE 2.x:

  • If an IDE opens two sketches with different profiles (e.g.arduino:avr:uno andesp32:esp32:esp32da), should each sketch have its own gRPC client or session?
  • When switching or activating a profile, does the CLI reinitialize the build environment (toolchains, platforms, libraries), or are these shared and cached? For example, iflibA is installed in profileA but not in profileB, will a library search over gRPC return different results for each profile?
  • If multiple profiles use the same library, will it be installed multiple times, or can they share a global copy? Since each sketch can have its ownsketch.yaml, does that mean the same dependency could be downloaded many times?
  • When using gRPC, shouldcompile,upload, etc. always loadfqbn,port, and other settings from the active profile, or should clients omit them?

I really like how profiles make builds reproducible and easy to share — that’s perfect for CI or collaborative work. But in an IDE that uses gRPC interactively, managing multiple isolated clients could get heavy, especially if it means repeated downloads.

In my current setup I treatsketch.yaml mostly as a lightweight config file. Libraries and platforms are managed globally, and if something is missing, the user only gets a warning instead of full profile enforcement.

I’d be curious to hear how Arduino sees this working long-term on the gRPC side — especially for IDE integration. Will profiles act more like isolated environments or just as stored build settings that can be written and updated through gRPC?

No hurry with this. Thanks a lot for your time

@cmaglie
Copy link
MemberAuthor

Hi@dankeboy36!

Thank you for your valuable feedback, as always.

If an IDE opens two sketches with different profiles (e.g. arduino:avr:uno and esp32:esp32:esp32da), should each sketch have its own gRPC client or session?

The basic idea is that when a profile is in use, the platforms and libraries installed globally should have no effect, and only the platforms and libraries listed in the profile should be visible. This idea was implemented by adding theprofile parameter in theInit method:

messageInitRequest {// An Arduino Core instance.Instanceinstance=1;// Profile to use.stringprofile=2;// The path where the sketch is stored.stringsketch_path=3;}

An instance initialized with a profile should be able to see only the libraries listed in the profile, and I've actually checked that this is the case, using the following profile:

profiles:  uno:    fqbn: arduino:avr:uno    platforms:      - platform: arduino:avr (1.8.3)    libraries:      - Servo (1.1.6)

If I try to initialize an instance of the CLI with the profile and try to get the list of installed libraries:

err:=srv.Init(&rpc.InitRequest{Instance:inst,SketchPath:sketchPath.String(),Profile:"uno",},stream)res,err:=srv.LibraryList(ctx,&rpc.LibraryListRequest{Instance:inst,All:true,})require.NoError(t,err)for_,lib:=rangeres.InstalledLibraries {fmt.Println("LIB>",lib.GetLibrary().GetName(),lib.GetLibrary().GetVersion(),lib.GetLibrary().GetLocation(),lib.GetLibrary().GetInstallDir())}

I got the expected:

LIB> Servo 1.1.6 LIBRARY_LOCATION_PROFILE /home/cmaglie/.arduino15/internal/Servo_1.1.6_663e17729cbd9f93/ServoLIB> Wire 1.0 LIBRARY_LOCATION_PLATFORM_BUILTIN /home/cmaglie/.arduino15/internal/arduino_avr_1.8.3_40b0bc3206d75f60/libraries/WireLIB> EEPROM 2.0 LIBRARY_LOCATION_PLATFORM_BUILTIN /home/cmaglie/.arduino15/internal/arduino_avr_1.8.3_40b0bc3206d75f60/libraries/EEPROMLIB> HID 1.0 LIBRARY_LOCATION_PLATFORM_BUILTIN /home/cmaglie/.arduino15/internal/arduino_avr_1.8.3_40b0bc3206d75f60/libraries/HIDLIB> SPI 1.0 LIBRARY_LOCATION_PLATFORM_BUILTIN /home/cmaglie/.arduino15/internal/arduino_avr_1.8.3_40b0bc3206d75f60/libraries/SPILIB> SoftwareSerial 1.0 LIBRARY_LOCATION_PLATFORM_BUILTIN /home/cmaglie/.arduino15/internal/arduino_avr_1.8.3_40b0bc3206d75f60/libraries/SoftwareSerial

The Servo library is listed asLOCATION_PROFILE, the other libraries arePLATFORM_BUILTIN.

So, based on the previous test, the answer to the following question is:

When switching or activating a profile, does the CLI reinitialize the build environment (toolchains, platforms, libraries), or are these shared and cached? For example, if libA is installed in profileA but not in profileB, will a library search over gRPC return different results for each profile?

Yes, the result will differ depending on the profile. By the way, there is a distinction between a library search (i.e., searching for a library in the Library Index) and listing installed libraries. In the first case, searching for a library will always produce the same result regardless of the selected profile; however, listing the installed libraries will show different results based on the selected profile.

If multiple profiles use the same library, will it be installed multiple times, or can they share a global copy? Since each sketch can have its own sketch.yaml, does that mean the same dependency could be downloaded many times?

Libraries and platforms installed through profiles are placed in a private folder inside$DATA_DIR/internal/. The same package will not be downloaded twice; there are no duplicates here. Those directories should be read-only. By the way, there are no protections in place to prevent users from making changes.

$ ls ~/.arduino15/internal/ -ltotale 200drwxr-xr-x  3 cmaglie cmaglie 4096 ott  3  2024  Adafruit_BusIO_1.16.1_ba866f2a3757c639drwxr-xr-x  4 cmaglie cmaglie 4096 ott  9  2024 'Adafruit SleepyDog Library@1.6.5_a3c453d34b90db4b'drwxrwxr-x  3 cmaglie cmaglie 4096 mag 30 16:02  arduino_arduinoOTA_1.2.1_c939277d7d79c18ddrwxr-xr-x  3 cmaglie cmaglie 4096 gen 23  2024  arduino_arduinoOTA_1.3.0_8902221f9b4869cedrwxr-xr-x  6 cmaglie cmaglie 4096 mag 30 16:02  arduino_arm-none-eabi-gcc_7-2017q4_7b7be9f526b2cb64drwxr-xr-x  8 cmaglie cmaglie 4096 nov 17 11:55  arduino_avr_1.8.3_40b0bc3206d75f60drwxr-xr-x  8 cmaglie cmaglie 4096 gen 23  2024  arduino_avr_1.8.4_7ad8ae8e9f6a9dc9drwxr-xr-x  9 cmaglie cmaglie 4096 gen 23  2024  arduino_avr_1.8.5_70334d3546efee53drwxr-xr-x  9 cmaglie cmaglie 4096 lug  1  2024  arduino_avr_1.8.6_78e0815c6047bc54drwxr-xr-x  4 cmaglie cmaglie 4096 gen 23  2024  arduino_avrdude_6.3.0-arduino17_b00caa3114ef923ddrwxr-xr-x  7 cmaglie cmaglie 4096 mag 30 16:03  arduino_avrdude_6.3.0-arduino9_734fb0aeab0d748fdrwxr-xr-x  8 cmaglie cmaglie 4096 gen 23  2024  arduino_avr-gcc_7.3.0-atmel3.6.1-arduino7_fc423089e09cfcabdrwxr-xr-x  3 cmaglie cmaglie 4096 lug  7 17:10  ArduinoBearSSL_1.7.6_3fd6f33f302ce290

When using gRPC, should compile, upload, etc. always load fqbn, port, and other settings from the active profile, or should clients omit them?

TheCompile andUpload commandsshould retrieve the FQBN and Port from the profile, and the gRPC API allows overriding them if the FQBN and Port parameters are filled. At least, that was the intention.
I put the above statement to the test, and I discovered that:

  • Compile always requires the sketch path (even if it was already specified in theInit call)
  • Upload always requires the sketch path (even if it was already specified in theInit call)
  • Upload always requires the port address (even if it was present in the profile)
    The CLI UI actually covers this behaviour by filling in the missing pieces in the gRPC calls.

The above must surely be fixed in the next releases. I'll open an issue for that.

@cmaglie
Copy link
MemberAuthor

cmaglie commentedNov 17, 2025
edited
Loading

We are currently using this API in the AppLab IDE to manage profiles in the sketch. This is still experimental, and your suggestions and thoughts are more than welcome. Thanks for taking the time to write them down. 🙏🏼

I’d be curious to hear how Arduino sees this working long-term on the gRPC side — especially for IDE integration. Will profiles act more like isolated environments or just as stored build settings that can be written and updated through gRPC?

At the moment, I would say that they serve both purposes:

  • They provide isolated environments, even reproducible builds if all the versions and URLs are correctly specified.
  • In a certain sense, they store the build settings, too? (having all the resources needed to build a sketch).

The hard question is how all of this integrates with the IDE?

My envisioned gRPC API involves the IDE creating multiple instances (using theCreate gRPC call), one for each open "sketch." Each instance should then be initialized (with theInit method), optionally with a profile, while the CLI manages the resources (possibly reusing/sharing to avoid wasting resources).
If the user selects a different profile, the instance should be re-initialized.

Currently, I understand the Arduino IDE 2 uses a global instance (without a profile) that might be shared across all sketches that do not use profiles. I see that this could complicate things when the profiles are introduced because each UX business logic needs to be implemented twice, once for the classic "non-profiled" sketches and once for "profiled" sketches.

There are still changes to the API to be made to make it IDE-friendly. The current state of the gRPC API is still not ready for that, but the above is the direction I'd like to see in the future.

@per1234per1234 added the topic: package-managementRelated to the packaging and managing of the platform/libraries labelNov 18, 2025
@cmagliecmaglieforce-pushed thegrpc-profiles-functions branch from7c9f505 toea0038fCompareNovember 25, 2025 09:26
@cmaglie
Copy link
MemberAuthor

I've removed the Git portion from this PR#3028 because it needs more work. It will be merged and discussed separately.

As stated by@per1234:> Build profile data is already provided via the LoadSketch method, so it> seems that even a mechanism that is truly for getting profile data should> be implemented by simply expanding the SketchProfile message to contain> all the data of the build profile (actually kind of silly that it> currently only provides a subset of the profile data).arduino#3019 (comment)
And also corresponding messages:  InitProfileRequest -> ProfileCreateRequest  InitProfileResponse -> ProfileCreateResponse
The function is now split into two functions:- librariesGetAllInstalled that requires a librariesmanager.Explorer.- libraryResolveDependencies that requires only a librariesindex.Index  and do not require anymore a librariesmanager.Explorer.
@cmagliecmaglieforce-pushed thegrpc-profiles-functions branch frombaebee1 toce55e4bCompareNovember 25, 2025 10:26
@cmagliecmaglie marked this pull request as ready for reviewNovember 25, 2025 10:45
@cmagliecmaglie requested a review froma teamNovember 25, 2025 10:45
}

newProfile:=&sketch.Profile{Name:req.GetProfileName(),FQBN:req.GetFqbn()}
// TODO: what to do with the PlatformIndexURL?
Copy link
Contributor

@dankeboy36dankeboy36Nov 25, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great question, preferably, the CLI can tell if a resolved platform was detected by one of the additional board (aka. 3rd party) URLs. A missing feature (prop) on the platform object?

@cmagliecmaglieforce-pushed thegrpc-profiles-functions branch fromce55e4b to8b4b3a5CompareNovember 26, 2025 17:00
-`<INDEX_LIB_NAME> (<INDEX_LIB_VERSION>)` represents a library from the Arduino Libraries Index that is a direct
dependency of the sketch, for example,`MyLib (1.0.0)`.
-`dependency: <INDEX_LIB_NAME> (<INDEX_LIB_VERSION>)` represents a library from the Arduino Libraries Index that is
an "indirect dependency", i.e., a library that is not used directly by the sketch, but is required by other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
an "indirect dependency", i.e., a library that is not used directly by the sketch, but is required by other
a "transitive dependency", i.e., a library that is not used directly by the sketch, but is required by other

"Transitive dependency" appears to be the more common term:

https://trends.google.com/trends/explore?date=today%205-y&q=%22indirect%20dependency%22,%22transitive%20dependency%22&hl=en

Comment on lines +65 to +67
in the profile with the declaration`dependency: UtilLib (1.3.4)`. During sketch compilation, a dependency library
is treated the same as a non-dependency library; the only difference is in automatic library management, where a
dependency library can be installed or removed together with the library that uses it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
in the profile with the declaration `dependency: UtilLib (1.3.4)`. During sketch compilation, a dependency library
is treated the same as a non-dependency library; the only difference is in automatic library management, where a
dependency library can be installed or removed together with the library that uses it.
in the profile with the declaration `dependency: UtilLib (1.3.4)`. During sketch compilation, a`dependency` library
is treated the same as a non-`dependency` library; the only difference is in automatic library management, where a
`dependency` library can be installed or removed together with the library that uses it.

I think that treating "dependency" as prose in this context of sketch compilation makes things too confusing, as in this context all the libraries are dependencies. Adding code markup makes it clear that "dependency" is referring to the specific type of library dependency defined in the build profile.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@per1234per1234per1234 requested changes

+1 more reviewer

@dankeboy36dankeboy36dankeboy36 left review comments

Reviewers whose approvals may not affect merge requirements

Requested changes must be addressed to merge this pull request.

Assignees

@cmagliecmaglie

Labels

topic: codeRelated to content of the project itselftopic: gRPCRelated to the gRPC interfacetopic: package-managementRelated to the packaging and managing of the platform/librariestype: enhancementProposed improvement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@cmaglie@dankeboy36@per1234

[8]ページ先頭

©2009-2025 Movatter.jp