Skip to content

Commit 5115d44

Browse files
authored
[skip changelog] Document "Library Name Priority" (#1301)
When multiple libraries contain files matching an `#include` directive, Arduino CLI must pick one. Multiple factors are used in order to make an intelligent determination of which library is best. In order to enhance this determination, the library.properties `name` value is now one of those factors. The other factors are already documented in the "Sketch Build Process" documentation, but this newly added feature was previously undocumented.
1 parent c342eac commit 5115d44

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Diff for: docs/sketch-build-process.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ following rules, one by one in this order, until a rule determines a winner:
5454

5555
1. A library that is architecture compatible wins against a library that is not architecture compatible (see
5656
[**Architecture Matching**](#architecture-matching))
57-
1. A library that has better "folder name priority" wins (see [**Folder Name Priority**](#folder-name-priority))
57+
1. A library with both [library name](#library-name-priority) and [folder name](#folder-name-priority) matching the
58+
include wins
59+
1. A library that has better "library name priority" or "folder name priority" wins (see
60+
[**Library Name Priority**](#library-name-priority) and [**Folder Name Priority**](#folder-name-priority))
5861
1. A library that is architecture optimized wins against a library that is not architecture optimized (see
5962
[**Architecture Matching**](#architecture-matching))
6063
1. A library that has a better "location priority" wins (see [**Location Priority**](#location-priority))
@@ -86,6 +89,21 @@ Examples:
8689
| `architectures=avr,esp8266` | YES | YES |
8790
| `architectures=samd` | NO | NO |
8891

92+
### Library Name Priority
93+
94+
A library's name is defined by the [library.properties](library-specification.md#libraryproperties-file-format) `name`
95+
field. That value is sanitized by replacing spaces with `_` before comparing it to the file name of the include.
96+
97+
The "library name priority" is determined as follows (in order of highest to lowest priority):
98+
99+
| Rule | Example for `Arduino_Low_Power.h` |
100+
| ------------------------------------------------------------------------- | --------------------------------- |
101+
| The library name matches the include 100% | `Arduino Low Power` |
102+
| The library name matches the include 100%, except with a `-master` suffix | `Arduino Low Power-master` |
103+
| The library name has a matching prefix | `Arduino Low Power Whatever` |
104+
| The library name has a matching suffix | `Awesome Arduino Low Power` |
105+
| The library name contains the include | `The Arduino Low Power Lib` |
106+
89107
### Folder Name Priority
90108

91109
The "folder name priority" is determined as follows (in order of highest to lowest priority):

0 commit comments

Comments
 (0)