Skip to content

Commit b0ad3e2

Browse files
committed
[skip changelog] Fix receiver name in LibraryManager functions
1 parent 970b696 commit b0ad3e2

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

arduino/libraries/librariesmanager/librariesmanager.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ func (alts *LibraryAlternatives) FindVersion(version *semver.Version) *libraries
8282
}
8383

8484
// Names returns an array with all the names of the installed libraries.
85-
func (sc LibrariesManager) Names() []string {
86-
res := make([]string, len(sc.Libraries))
85+
func (lm LibrariesManager) Names() []string {
86+
res := make([]string, len(lm.Libraries))
8787
i := 0
88-
for n := range sc.Libraries {
88+
for n := range lm.Libraries {
8989
res[i] = n
9090
i++
9191
}
@@ -109,27 +109,27 @@ func NewLibraryManager(indexDir *paths.Path, downloadsDir *paths.Path) *Librarie
109109

110110
// LoadIndex reads a library_index.json from a file and returns
111111
// the corresponding Index structure.
112-
func (sc *LibrariesManager) LoadIndex() error {
113-
index, err := librariesindex.LoadIndex(sc.IndexFile)
112+
func (lm *LibrariesManager) LoadIndex() error {
113+
index, err := librariesindex.LoadIndex(lm.IndexFile)
114114
if err != nil {
115-
sc.Index = librariesindex.EmptyIndex
115+
lm.Index = librariesindex.EmptyIndex
116116
return err
117117
}
118-
sc.Index = index
118+
lm.Index = index
119119
return nil
120120
}
121121

122122
// AddLibrariesDir adds path to the list of directories
123123
// to scan when searching for libraries. If a path is already
124124
// in the list it is ignored.
125-
func (sc *LibrariesManager) AddLibrariesDir(path *paths.Path, location libraries.LibraryLocation) {
126-
for _, dir := range sc.LibrariesDir {
125+
func (lm *LibrariesManager) AddLibrariesDir(path *paths.Path, location libraries.LibraryLocation) {
126+
for _, dir := range lm.LibrariesDir {
127127
if dir.Path.EquivalentTo(path) {
128128
return
129129
}
130130
}
131131
logrus.WithField("dir", path).WithField("location", location.String()).Info("Adding libraries dir")
132-
sc.LibrariesDir = append(sc.LibrariesDir, &LibrariesDir{
132+
lm.LibrariesDir = append(lm.LibrariesDir, &LibrariesDir{
133133
Path: path,
134134
Location: location,
135135
})
@@ -138,36 +138,36 @@ func (sc *LibrariesManager) AddLibrariesDir(path *paths.Path, location libraries
138138
// AddPlatformReleaseLibrariesDir add the libraries directory in the
139139
// specified PlatformRelease to the list of directories to scan when
140140
// searching for libraries.
141-
func (sc *LibrariesManager) AddPlatformReleaseLibrariesDir(plaftormRelease *cores.PlatformRelease, location libraries.LibraryLocation) {
141+
func (lm *LibrariesManager) AddPlatformReleaseLibrariesDir(plaftormRelease *cores.PlatformRelease, location libraries.LibraryLocation) {
142142
path := plaftormRelease.GetLibrariesDir()
143143
if path == nil {
144144
return
145145
}
146-
for _, dir := range sc.LibrariesDir {
146+
for _, dir := range lm.LibrariesDir {
147147
if dir.Path.EquivalentTo(path) {
148148
return
149149
}
150150
}
151151
logrus.WithField("dir", path).WithField("location", location.String()).Info("Adding libraries dir")
152-
sc.LibrariesDir = append(sc.LibrariesDir, &LibrariesDir{
152+
lm.LibrariesDir = append(lm.LibrariesDir, &LibrariesDir{
153153
Path: path,
154154
Location: location,
155155
PlatformRelease: plaftormRelease,
156156
})
157157
}
158158

159159
// RescanLibraries reload all installed libraries in the system.
160-
func (sc *LibrariesManager) RescanLibraries() error {
161-
for _, dir := range sc.LibrariesDir {
162-
if err := sc.LoadLibrariesFromDir(dir); err != nil {
160+
func (lm *LibrariesManager) RescanLibraries() error {
161+
for _, dir := range lm.LibrariesDir {
162+
if err := lm.LoadLibrariesFromDir(dir); err != nil {
163163
return fmt.Errorf("loading libs from %s: %s", dir.Path, err)
164164
}
165165
}
166166
return nil
167167
}
168168

169-
func (sc *LibrariesManager) getUserLibrariesDir() *paths.Path {
170-
for _, dir := range sc.LibrariesDir {
169+
func (lm *LibrariesManager) getUserLibrariesDir() *paths.Path {
170+
for _, dir := range lm.LibrariesDir {
171171
if dir.Location == libraries.User {
172172
return dir.Path
173173
}
@@ -177,7 +177,7 @@ func (sc *LibrariesManager) getUserLibrariesDir() *paths.Path {
177177

178178
// LoadLibrariesFromDir loads all libraries in the given directory. Returns
179179
// nil if the directory doesn't exists.
180-
func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) error {
180+
func (lm *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) error {
181181
subDirs, err := librariesDir.Path.ReadDir()
182182
if os.IsNotExist(err) {
183183
return nil
@@ -194,10 +194,10 @@ func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) err
194194
return fmt.Errorf("loading library from %s: %s", subDir, err)
195195
}
196196
library.ContainerPlatform = librariesDir.PlatformRelease
197-
alternatives, ok := sc.Libraries[library.Name]
197+
alternatives, ok := lm.Libraries[library.Name]
198198
if !ok {
199199
alternatives = &LibraryAlternatives{}
200-
sc.Libraries[library.Name] = alternatives
200+
lm.Libraries[library.Name] = alternatives
201201
}
202202
alternatives.Add(library)
203203
}
@@ -230,9 +230,9 @@ func (lm *LibrariesManager) LoadLibraryFromDir(libRootDir *paths.Path, location
230230
// FindByReference return the installed library matching the Reference
231231
// name and version or, if the version is nil, the library installed
232232
// in the User folder.
233-
func (sc *LibrariesManager) FindByReference(libRef *librariesindex.Reference) *libraries.Library {
233+
func (lm *LibrariesManager) FindByReference(libRef *librariesindex.Reference) *libraries.Library {
234234
saneName := utils.SanitizeName(libRef.Name)
235-
alternatives, have := sc.Libraries[saneName]
235+
alternatives, have := lm.Libraries[saneName]
236236
if !have {
237237
return nil
238238
}

test/test_compile.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,16 +922,14 @@ def test_compile_with_library_priority(run_command, data_dir):
922922

923923
assert run_command("core install arduino:avr@1.8.3")
924924

925-
sketch_name = "CompileSketchWithWiFi101Dependency"
925+
sketch_name = "CompileSketchWithLibraryPriority"
926926
sketch_path = Path(data_dir, sketch_name)
927927
fqbn = "arduino:avr:uno"
928928

929-
# Manually installs the same library and add a new custom header to it
929+
# Manually installs a library
930930
git_url = "https://github.com/arduino-libraries/WiFi101.git"
931931
manually_install_lib_path = Path(data_dir, "my-libraries", "WiFi101")
932932
assert Repo.clone_from(git_url, manually_install_lib_path, multi_options=["-b 0.16.1"])
933-
# with open(manually_install_lib_path / "src" / "WiFiSomething.h", "x") as f:
934-
# f.writelines(["#ifndef WIFI_SOMETHING\n", "#define WIFI_SOMETHING\n", "#endif\n"])
935933

936934
# Install the same library we installed manually
937935
assert run_command("lib install WiFi101")

0 commit comments

Comments
 (0)