Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a5d40b0

Browse files
committedAug 24, 2020
Added function to compute library location priority
1 parent 9ae5d76 commit a5d40b0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎arduino/libraries/libraries.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,18 @@ func (library *Library) SourceDirs() []SourceDir {
138138
}
139139
return dirs
140140
}
141+
142+
// LocationPriorityFor returns a number representing the location priority for the given library
143+
// using the given platform and referenced-platform. Higher value means higher priority.
144+
func (library *Library) LocationPriorityFor(platformRelease, refPlatformRelease *cores.PlatformRelease) int {
145+
if library.Location == IDEBuiltIn {
146+
return 1
147+
} else if library.ContainerPlatform == refPlatformRelease {
148+
return 2
149+
} else if library.ContainerPlatform == platformRelease {
150+
return 3
151+
} else if library.Location == User {
152+
return 4
153+
}
154+
return 0
155+
}

‎arduino/libraries/libraries_location.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type LibraryLocation int
2828
// The enumeration is listed in ascending order of priority
2929
const (
3030
// IDEBuiltIn are libraries bundled in the IDE
31-
IDEBuiltIn = iota
31+
IDEBuiltIn LibraryLocation = iota
3232
// PlatformBuiltIn are libraries bundled in a PlatformRelease
3333
PlatformBuiltIn
3434
// ReferencedPlatformBuiltIn are libraries bundled in a PlatformRelease referenced for build

0 commit comments

Comments
 (0)
Please sign in to comment.