Skip to content

Use the correct library when a relative path is passed as --library value #2126

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

Merged

Conversation

MatteoPologruto
Copy link
Contributor

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?

Code imperfection fix

What is the current behavior?

Compiling an example of a manually downloaded library fails if the command is executed inside the examples directory and a relative path to the library itself is specified.

C:\Users\m.pologruto>arduino-cli lib uninstall ArduinoIoTCloud
Uninstalling [ArduinoIoTCloud@1.11.0]...

C:\Users\m.pologruto>cd Downloads/ArduinoIoTCloud-1.11.0/examples/ArduinoIoTCloud-Basic

C:\Users\m.pologruto\Downloads\ArduinoIoTCloud-1.11.0\examples\ArduinoIoTCloud-Basic>arduino-cli compile -b arduino:samd:nano_33_iot --library ../../
...
...
Error during build: CreateFile ..\..\..\src\ArduinoIoTCloud.cpp: The system cannot find the path specified.

If the same library is installed with lib install, the library is picked from the Sketchbook's libraries directory.

What is the new behavior?

If the relative path to a library is correct, that library will be chosen over other instances of it.

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

No

@MatteoPologruto MatteoPologruto added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: CLI Related to the command line interface labels Mar 27, 2023
@MatteoPologruto MatteoPologruto self-assigned this Mar 27, 2023
@MatteoPologruto MatteoPologruto force-pushed the library-flag-relative-paths branch from ae1d5ca to 51569a5 Compare March 27, 2023 15:33
@MatteoPologruto MatteoPologruto marked this pull request as ready for review March 27, 2023 15:33
@MatteoPologruto MatteoPologruto linked an issue Mar 27, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Patch coverage: 40.00% and project coverage change: -0.09 ⚠️

Comparison is base (a9729db) 62.56% compared to head (a45c362) 62.47%.

❗ Current head a45c362 differs from pull request most recent head 04f71b0. Consider uploading reports for the commit 04f71b0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2126      +/-   ##
==========================================
- Coverage   62.56%   62.47%   -0.09%     
==========================================
  Files         231      231              
  Lines       19610    19599      -11     
==========================================
- Hits        12269    12245      -24     
- Misses       6238     6250      +12     
- Partials     1103     1104       +1     
Flag Coverage Δ
unit 62.47% <40.00%> (-0.09%) ⬇️

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

Impacted Files Coverage Δ
commands/compile/compile.go 71.10% <40.00%> (-0.72%) ⬇️

... and 12 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

There is no need to bundle the entire ArduinoIoTCloud library as test data. You can use a minimal library instead:

FooLib.zip

The only requirements for the test data:

  • A sketch that contains an #include directive.
  • A library that:
    • contains a header file with name matching the #include directive in the sketch
    • contains at least one source file (e.g., FooLib.cpp)

@MatteoPologruto MatteoPologruto force-pushed the library-flag-relative-paths branch 2 times, most recently from 20bcebf to 53ae148 Compare March 28, 2023 09:56
@MatteoPologruto MatteoPologruto force-pushed the library-flag-relative-paths branch from a45c362 to 24acd2e Compare March 28, 2023 11:57
@cmaglie cmaglie changed the title [skip-changelog] Use the correct library when a relative path is passed as --library value Use the correct library when a relative path is passed as --library value Mar 28, 2023
@MatteoPologruto MatteoPologruto force-pushed the library-flag-relative-paths branch from 24acd2e to 2b8c48d Compare March 28, 2023 13:05
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

Thanks Matteo!

@MatteoPologruto MatteoPologruto force-pushed the library-flag-relative-paths branch from 2b8c48d to 04f71b0 Compare March 29, 2023 06:46
@MatteoPologruto MatteoPologruto merged commit 51e50e1 into arduino:master Mar 29, 2023
@MatteoPologruto MatteoPologruto deleted the library-flag-relative-paths branch March 29, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--library flag not working with relative paths
3 participants