arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Add possibility to embed custom libraries into the sketch

Open cmaglie opened this issue 1 year ago • 1 comments
trafficstars

Please check if the PR fulfills these requirements

See how to contribute

  • [X] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [X] The PR follows our contributing guidelines
  • [X] Tests for the changes have been added (for bug fixes / features)
  • [x] 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?

Adds the possibility to include libraries in the sketch libraries folder

What is the current behavior?

~/Arduino/Blink$ tree
.
├── Blink.ino
└── libraries
    └── ExampleLibrary
        └── MyLib.h

3 directories, 2 files
~/Arduino/Blink$ cat Blink.ino 
#include <MyLib.h>

void setup() {
	libFunction();
}

void loop() {
}
~/Arduino/Blink$ cat libraries/ExampleLibrary/MyLib.h 

void libFunction() {
}

~/Arduino/Blink$ arduino-cli compile -b arduino:avr:uno 
/home/cmaglie/Arduino/Blink/Blink.ino:1:10: fatal error: MyLib.h: No such file or directory
 #include <MyLib.h>
          ^~~~~~~~~
compilation terminated.

Used platform Version Path
arduino:avr   1.8.6   /home/cmaglie/.arduino15/packages/arduino/hardware/avr/1.8.6
Error during build: exit status 1

What is the new behavior?

~/Arduino/Blink$ arduino-cli compile -b arduino:avr:uno 
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

Used library   Version Path
ExampleLibrary         /home/cmaglie/Arduino/Blink/libraries/ExampleLibrary

Used platform Version Path
arduino:avr   1.8.6   /home/cmaglie/.arduino15/packages/arduino/hardware/avr/1.8.6

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

Other information

Resolves https://github.com/arduino/arduino-cli/issues/1255

cmaglie avatar Jan 25 '24 11:01 cmaglie

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (0dfb27e) 68.92% compared to head (1020934) 68.91%.

Files Patch % Lines
internal/arduino/sketch/sketch.go 71.42% 4 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2514      +/-   ##
==========================================
- Coverage   68.92%   68.91%   -0.01%     
==========================================
  Files         204      204              
  Lines       20452    20478      +26     
==========================================
+ Hits        14096    14113      +17     
- Misses       5207     5213       +6     
- Partials     1149     1152       +3     
Flag Coverage Δ
unit 68.91% <79.31%> (-0.01%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 25 '24 11:01 codecov[bot]