Skip to content

Commit 12bc114

Browse files
committed
Made ComputePriority function public
1 parent 1a83e6f commit 12bc114

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Diff for: arduino/libraries/librariesresolver/cpp.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (resolver *Cpp) ResolveFor(header, architecture string) *libraries.Library
123123
var found libraries.List
124124
var foundPriority int
125125
for _, lib := range resolver.headers[header] {
126-
libPriority := computePriority(lib, header, architecture)
126+
libPriority := ComputePriority(lib, header, architecture)
127127
msg := " discarded"
128128
if found == nil || foundPriority < libPriority {
129129
found = libraries.List{}
@@ -164,7 +164,10 @@ func simplify(name string) string {
164164
return name
165165
}
166166

167-
func computePriority(lib *libraries.Library, header, arch string) int {
167+
// ComputePriority returns an integer value representing the priority of the library
168+
// for the specified header and architecture. The higher the value, the higher the
169+
// priority.
170+
func ComputePriority(lib *libraries.Library, header, arch string) int {
168171
header = strings.TrimSuffix(header, filepath.Ext(header))
169172
header = simplify(header)
170173
name := simplify(lib.Name)

Diff for: arduino/libraries/librariesresolver/cpp_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ func TestClosestMatchWithTotallyDifferentNames(t *testing.T) {
102102
}
103103

104104
func TestCppHeaderPriority(t *testing.T) {
105-
r1 := computePriority(l1, "calculus_lib.h", "avr")
106-
r2 := computePriority(l2, "calculus_lib.h", "avr")
107-
r3 := computePriority(l3, "calculus_lib.h", "avr")
108-
r4 := computePriority(l4, "calculus_lib.h", "avr")
109-
r5 := computePriority(l5, "calculus_lib.h", "avr")
110-
r6 := computePriority(l6, "calculus_lib.h", "avr")
111-
r7 := computePriority(l7, "calculus_lib.h", "avr")
105+
r1 := ComputePriority(l1, "calculus_lib.h", "avr")
106+
r2 := ComputePriority(l2, "calculus_lib.h", "avr")
107+
r3 := ComputePriority(l3, "calculus_lib.h", "avr")
108+
r4 := ComputePriority(l4, "calculus_lib.h", "avr")
109+
r5 := ComputePriority(l5, "calculus_lib.h", "avr")
110+
r6 := ComputePriority(l6, "calculus_lib.h", "avr")
111+
r7 := ComputePriority(l7, "calculus_lib.h", "avr")
112112
require.True(t, r1 > r2)
113113
require.True(t, r2 > r3)
114114
require.True(t, r3 > r4)

0 commit comments

Comments
 (0)