Skip to content

Allow locally installed libraries in sketch profiles. #2930

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jun 10, 2025

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull 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 change allows us to specify libraries in the sketch profile using a path to a local directory by prefixing the path with the string dir: .
It also provides this information in compile --dump-profile

What is the current behavior?

Only libraries in the Arduino Libraries Index could be specified in a sketch profile. A typical example may be the following:

profiles:
  uno:
    fqbn: arduino:avr:uno
    platforms:
      - platform: arduino:avr (1.8.6)
    libraries:
      - Adafruit SSD1306 (2.5.13)
      - Adafruit GFX Library (1.11.11)
      - Adafruit BusIO (1.17.0)

What is the new behavior?

A library installed in the filesystem could be specified as well:

profiles:
  uno:
    fqbn: arduino:avr:uno
    platforms:
      - platform: arduino:avr (1.8.6)
    libraries:
      - dir: libraries/MyLib
      - dir: /path/to/library/MyLibOutsideTheSketch 
      - Adafruit SSD1306 (2.5.13)
      - Adafruit GFX Library (1.11.11)
      - Adafruit BusIO (1.17.0)

In this case the two libraries:

  • libraries/MyLib
  • /path/to/library/MyLibOutsideTheSketch
    will be included during the compilation. In particular, a relative path refers to a path relative to the sketch path, in this case libraries/MyLib is to be intended as SKETCHPATH/libaries/MyLib.

Does this PR introduce a breaking change, and is titled accordingly?

No

Other information

@cmaglie cmaglie self-assigned this Jun 10, 2025
@cmaglie cmaglie added type: enhancement Proposed improvement topic: build-process Related to the sketch build process labels Jun 10, 2025
@cmaglie cmaglie force-pushed the allow_paths_in_profile_libs branch from 634d074 to cdd7f4e Compare June 10, 2025 14:50
@cmaglie cmaglie requested a review from a team June 10, 2025 15:11
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 65.95745% with 16 lines in your changes missing coverage. Please review.

Project coverage is 67.88%. Comparing base (2947cfb) to head (0bd806e).

Files with missing lines Patch % Lines
internal/arduino/sketch/profiles.go 45.00% 6 Missing and 5 partials ⚠️
commands/instances.go 68.75% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2930      +/-   ##
==========================================
+ Coverage   67.84%   67.88%   +0.04%     
==========================================
  Files         238      238              
  Lines       22442    22477      +35     
==========================================
+ Hits        15226    15259      +33     
+ Misses       6014     6012       -2     
- Partials     1202     1206       +4     
Flag Coverage Δ
unit 67.88% <65.95%> (+0.04%) ⬆️

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.

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

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

The implementation looks good, I'd just add a test to assert the compilation given a sketch.yaml with also relative lib.

@cmaglie cmaglie linked an issue Jun 11, 2025 that may be closed by this pull request
3 tasks
@cmaglie cmaglie force-pushed the allow_paths_in_profile_libs branch from 1d46837 to 0bd806e Compare June 11, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for custom libraries when using sketch.yaml
2 participants