@@ -42,41 +42,39 @@ import (
42
42
type LibrariesLoader struct {}
43
43
44
44
func (s * LibrariesLoader ) Run (ctx * types.Context ) error {
45
+ lm := librariesmanager .NewLibraryManager ()
46
+ ctx .LibrariesManager = lm
47
+
45
48
builtInLibrariesFolders := ctx .BuiltInLibrariesFolders
46
49
if err := builtInLibrariesFolders .ToAbs (); err != nil {
47
50
return i18n .WrapError (err )
48
51
}
49
- sortedLibrariesFolders := builtInLibrariesFolders .Clone ( )
52
+ lm . AddLibrariesDir ( libraries . IDEBuiltIn , builtInLibrariesFolders ... )
50
53
51
- actualPlatform := ctx .ActualPlatform
52
- platform := ctx .TargetPlatform
53
54
debugLevel := ctx .DebugLevel
54
55
logger := ctx .GetLogger ()
55
56
57
+ actualPlatform := ctx .ActualPlatform
58
+ platform := ctx .TargetPlatform
56
59
if actualPlatform != platform {
57
60
if dir := actualPlatform .GetLibrariesDir (); dir != nil {
58
- sortedLibrariesFolders . Add ( dir )
61
+ lm . AddLibrariesDir ( libraries . ReferencedPlatformBuiltIn , dir )
59
62
}
60
63
}
61
-
62
64
if dir := platform .GetLibrariesDir (); dir != nil {
63
- sortedLibrariesFolders . Add ( dir )
65
+ lm . AddLibrariesDir ( libraries . PlatformBuiltIn , dir )
64
66
}
65
67
66
68
librariesFolders := ctx .OtherLibrariesFolders
67
69
if err := librariesFolders .ToAbs (); err != nil {
68
70
return i18n .WrapError (err )
69
71
}
70
- sortedLibrariesFolders . AddAllMissing ( librariesFolders )
72
+ lm . AddLibrariesDir ( libraries . Sketchbook , librariesFolders ... )
71
73
72
- ctx .LibrariesFolders = sortedLibrariesFolders
73
-
74
- lm := librariesmanager .NewLibraryManager ()
75
- for _ , libraryFolder := range sortedLibrariesFolders {
76
- if err := lm .LoadLibrariesFromDir (libraryFolder ); err != nil {
77
- return i18n .WrapError (err )
78
- }
74
+ if err := lm .RescanLibraries (); err != nil {
75
+ return i18n .WrapError (err )
79
76
}
77
+
80
78
if debugLevel > 0 {
81
79
for _ , lib := range lm .Libraries {
82
80
for _ , libAlt := range lib .Alternatives {
@@ -91,8 +89,6 @@ func (s *LibrariesLoader) Run(ctx *types.Context) error {
91
89
}
92
90
}
93
91
94
- ctx .LibrariesManager = lm
95
-
96
92
headerToLibraries := make (map [string ][]* libraries.Library )
97
93
for _ , lib := range lm .Libraries {
98
94
for _ , library := range lib .Alternatives {
0 commit comments