@@ -50,57 +50,67 @@ func LibraryList(ctx context.Context, req *rpc.LibraryListReq) (*rpc.LibraryList
50
50
51
51
instaledLib := []* rpc.InstalledLibrary {}
52
52
res := listLibraries (lm , req .GetUpdatable (), req .GetAll ())
53
- if len (res ) > 0 {
54
- if f := req .GetFqbn (); f != "" {
55
- fqbn , err := cores .ParseFQBN (req .GetFqbn ())
56
- if err != nil {
57
- return nil , fmt .Errorf ("parsing fqbn: %s" , err )
58
- }
59
- _ , boardPlatform , _ , _ , refBoardPlatform , err := pm .ResolveFQBN (fqbn )
60
- if err != nil {
61
- return nil , fmt .Errorf ("loading board data: %s" , err )
62
- }
53
+ if f := req .GetFqbn (); f != "" {
54
+ fqbn , err := cores .ParseFQBN (req .GetFqbn ())
55
+ if err != nil {
56
+ return nil , fmt .Errorf ("parsing fqbn: %s" , err )
57
+ }
58
+ _ , boardPlatform , _ , _ , refBoardPlatform , err := pm .ResolveFQBN (fqbn )
59
+ if err != nil {
60
+ return nil , fmt .Errorf ("loading board data: %s" , err )
61
+ }
63
62
64
- filteredRes := map [string ]* installedLib {}
65
- for _ , lib := range res {
66
- if cp := lib .Library .ContainerPlatform ; cp != nil {
67
- if cp != boardPlatform && cp != refBoardPlatform {
68
- // Filter all libraries from extraneous platforms
69
- continue
70
- }
63
+ filteredRes := map [string ]* installedLib {}
64
+ for _ , lib := range res {
65
+ if cp := lib .Library .ContainerPlatform ; cp != nil {
66
+ if cp != boardPlatform && cp != refBoardPlatform {
67
+ // Filter all libraries from extraneous platforms
68
+ continue
71
69
}
72
- if latest , has := filteredRes [ lib . Library . Name ]; has {
73
- if latest . Library . LocationPriorityFor ( boardPlatform , refBoardPlatform ) >= lib .Library .LocationPriorityFor ( boardPlatform , refBoardPlatform ) {
74
- continue
75
- }
70
+ }
71
+ if latest , has := filteredRes [ lib .Library .Name ]; has {
72
+ if latest . Library . LocationPriorityFor ( boardPlatform , refBoardPlatform ) >= lib . Library . LocationPriorityFor ( boardPlatform , refBoardPlatform ) {
73
+ continue
76
74
}
77
- filteredRes [lib .Library .Name ] = lib
78
75
}
79
76
80
- res = []* installedLib {}
81
- for _ , lib := range filteredRes {
82
- res = append (res , lib )
77
+ // Check if library is compatible with board specified by FBQN
78
+ compatible := false
79
+ for _ , arch := range lib .Library .Architectures {
80
+ compatible = (arch == fqbn .PlatformArch || arch == "*" )
81
+ if compatible {
82
+ break
83
+ }
84
+ }
85
+ lib .Library .CompatibleWith = map [string ]bool {
86
+ f : compatible ,
83
87
}
88
+
89
+ filteredRes [lib .Library .Name ] = lib
84
90
}
85
91
86
- for _ , lib := range res {
87
- if nameFilter != "" && strings .ToLower (lib .Library .Name ) != nameFilter {
88
- continue
89
- }
90
- libtmp , err := GetOutputLibrary (lib .Library )
91
- if err != nil {
92
- return nil , err
93
- }
94
- release := GetOutputRelease (lib .Available )
95
- instaledLib = append (instaledLib , & rpc.InstalledLibrary {
96
- Library : libtmp ,
97
- Release : release ,
98
- })
92
+ res = []* installedLib {}
93
+ for _ , lib := range filteredRes {
94
+ res = append (res , lib )
99
95
}
96
+ }
100
97
101
- return & rpc.LibraryListResp {InstalledLibrary : instaledLib }, nil
98
+ for _ , lib := range res {
99
+ if nameFilter != "" && strings .ToLower (lib .Library .Name ) != nameFilter {
100
+ continue
101
+ }
102
+ libtmp , err := GetOutputLibrary (lib .Library )
103
+ if err != nil {
104
+ return nil , err
105
+ }
106
+ release := GetOutputRelease (lib .Available )
107
+ instaledLib = append (instaledLib , & rpc.InstalledLibrary {
108
+ Library : libtmp ,
109
+ Release : release ,
110
+ })
102
111
}
103
- return & rpc.LibraryListResp {}, nil
112
+
113
+ return & rpc.LibraryListResp {InstalledLibrary : instaledLib }, nil
104
114
}
105
115
106
116
// listLibraries returns the list of installed libraries. If updatable is true it
@@ -171,6 +181,7 @@ func GetOutputLibrary(lib *libraries.Library) (*rpc.Library, error) {
171
181
License : lib .License ,
172
182
Examples : lib .Examples .AsStrings (),
173
183
ProvidesIncludes : lib .DeclaredHeaders (),
184
+ CompatibleWith : lib .CompatibleWith ,
174
185
}, nil
175
186
}
176
187
0 commit comments