Skip to content
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

Use optimal bundled library name #65

Merged
merged 1 commit into from
Dec 31, 2021
Merged

Use optimal bundled library name #65

merged 1 commit into from
Dec 31, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Dec 28, 2021

When multiple libraries contain files matching an #include directive in the program, the Arduino build system must pick one to use for compilation. Multiple factors are used in order to make an intelligent determination of which library is best, as documented here.

In order to enhance this determination, the closeness of match between the library.properties name value and the filename in the #include directive is being added as one of those factors. This new factor is referred to as "Library Name Priority". This change has been made in Arduino CLI 0.19.0 (arduino/arduino-cli#1300), and Arduino IDE 2.0.0-beta.12 and newer.

Unfortunately, this change can result in platform bundled libraries which had previously been correctly correctly chosen
no longer being given priority over their equivalent standalone libraries, which may be incompatible or not optimized for the platform's boards.

This priority inversion only occurs when all the following conditions are true:

  • There is a standalone library installed which provides a header filename collision.
  • The platform bundled library is architecture optimized (e.g., architectures=AmebaD).
  • The standalone library is architecture compatible (architectures=*).
  • The standalone library has equal "Folder Name Priority".
  • The standalone library has better "Library Name Priority" (e.g., name=WiFi vs name=AmebaWiFi for a library with primary header file WiFi.h.

The fix is to simply give the platform bundled library a perfect "Library Name Priority", as provided by the change in this PR.

Some platform bundled libraries were given a modified name as a workaround to a bug in the Arduino IDE's Library Manager which caused Library Manager to always show the library as updatable under specific circumstances. That bug was fixed in Arduino IDE 1.8.6, ~3 years ago.

For more information or discussion regarding this change, please see arduino/arduino-cli#1292

When multiple libraries contain files matching an #include directive in the program, the Arduino build system must pick
one to use for compilation. Multiple factors are used in order to make an intelligent determination of which library is
best.

In order to enhance this determination, the closeness of match between the library.properties name value and the
filename in the #include directive is being added as one of those factors. This new factor is referred to as
"Library Name Priority".

Unfortunately, this change can result in platform bundled libraries which had previously been correctly correctly chosen
no longer being given priority over their equivalent standalone libraries, which may be incompatible or not optimized
for the platform's boards.

This priority inversion only occurs when all the following conditions are true:

- There is a standalone library installed which provides a header filename collision.
- The platform bundled library is architecture optimized (e.g., architectures=AmebaD).
- The standalone library is architecture compatible (architectures=*).
- The standalone library has equal "Folder Name Priority".
- The standalone library has better "Library Name Priority" (e.g., name=WiFi vs name=AmebaWiFi for a library with primary
  header file WiFi.h.

The fix is to simply give the platform bundled library a perfect "Library Name Priority".

Some platform bundled libraries were given a modified name as a workaround to a bug in the Arduino IDE's Library Manager
which caused Library Manager to always show the library as updatable under specific circumstances. That bug was fixed in
Arduino IDE 1.8.6, ~3 years ago.
@xidameng
Copy link
Contributor

When multiple libraries contain files matching an #include directive in the program, the Arduino build system must pick one to use for compilation. Multiple factors are used in order to make an intelligent determination of which library is best, as documented here.

In order to enhance this determination, the closeness of match between the library.properties name value and the filename in the #include directive is being added as one of those factors. This new factor is referred to as "Library Name Priority". This change has been made in Arduino CLI 0.19.0 (arduino/arduino-cli#1300), and Arduino IDE 2.0.0-beta.12 and newer.

Unfortunately, this change can result in platform bundled libraries which had previously been correctly correctly chosen no longer being given priority over their equivalent standalone libraries, which may be incompatible or not optimized for the platform's boards.

This priority inversion only occurs when all the following conditions are true:

  • There is a standalone library installed which provides a header filename collision.
  • The platform bundled library is architecture optimized (e.g., architectures=AmebaD).
  • The standalone library is architecture compatible (architectures=*).
  • The standalone library has equal "Folder Name Priority".
  • The standalone library has better "Library Name Priority" (e.g., name=WiFi vs name=AmebaWiFi for a library with primary header file WiFi.h.

The fix is to simply give the platform bundled library a perfect "Library Name Priority", as provided by the change in this PR.

Some platform bundled libraries were given a modified name as a workaround to a bug in the Arduino IDE's Library Manager which caused Library Manager to always show the library as updatable under specific circumstances. That bug was fixed in Arduino IDE 1.8.6, ~3 years ago.

For more information or discussion regarding this change, please see arduino/arduino-cli#1292

Very interesting to know, will look into it

@ambiot ambiot merged commit 14007cc into Ameba-AIoT:dev Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants