File tree 6 files changed +159
-113
lines changed
6 files changed +159
-113
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ package libraries
18
18
import (
19
19
"encoding/json"
20
20
"fmt"
21
+
22
+ rpc "github.com/arduino/arduino-cli/rpc/commands"
21
23
)
22
24
23
25
// LibraryLayout represents how the library source code is laid out in the library
@@ -65,3 +67,14 @@ func (d *LibraryLayout) UnmarshalJSON(b []byte) error {
65
67
}
66
68
return fmt .Errorf ("invalid library layout: %s" , s )
67
69
}
70
+
71
+ // ToRPCLibraryLayout converts this LibraryLayout to rpc.LibraryLayout
72
+ func (d * LibraryLayout ) ToRPCLibraryLayout () rpc.LibraryLayout {
73
+ switch * d {
74
+ case FlatLayout :
75
+ return rpc .LibraryLayout_flat_layout
76
+ case RecursiveLayout :
77
+ return rpc .LibraryLayout_recursive_layout
78
+ }
79
+ panic (fmt .Sprintf ("invalid LibraryLayout value %d" , * d ))
80
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ package libraries
18
18
import (
19
19
"encoding/json"
20
20
"fmt"
21
+
22
+ rpc "github.com/arduino/arduino-cli/rpc/commands"
21
23
)
22
24
23
25
// LibraryLocation represents where the library is installed
@@ -82,3 +84,33 @@ func (d *LibraryLocation) UnmarshalJSON(b []byte) error {
82
84
}
83
85
return fmt .Errorf ("invalid library location: %s" , s )
84
86
}
87
+
88
+ // ToRPCLibraryLocation converts this LibraryLocation to rpc.LibraryLocation
89
+ func (d * LibraryLocation ) ToRPCLibraryLocation () rpc.LibraryLocation {
90
+ switch * d {
91
+ case IDEBuiltIn :
92
+ return rpc .LibraryLocation_ide_builtin
93
+ case PlatformBuiltIn :
94
+ return rpc .LibraryLocation_platform_builtin
95
+ case ReferencedPlatformBuiltIn :
96
+ return rpc .LibraryLocation_referenced_platform_builtin
97
+ case User :
98
+ return rpc .LibraryLocation_user
99
+ }
100
+ panic (fmt .Sprintf ("invalid LibraryLocation value %d" , * d ))
101
+ }
102
+
103
+ // FromRPCLibraryLocation converts a rpc.LibraryLocation to a LibraryLocation
104
+ func FromRPCLibraryLocation (l rpc.LibraryLocation ) LibraryLocation {
105
+ switch l {
106
+ case rpc .LibraryLocation_ide_builtin :
107
+ return IDEBuiltIn
108
+ case rpc .LibraryLocation_platform_builtin :
109
+ return PlatformBuiltIn
110
+ case rpc .LibraryLocation_referenced_platform_builtin :
111
+ return ReferencedPlatformBuiltIn
112
+ case rpc .LibraryLocation_user :
113
+ return User
114
+ }
115
+ panic (fmt .Sprintf ("invalid rpc.LibraryLocation value %d" , l ))
116
+ }
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ func (ir installedResult) String() string {
102
102
lastName = name
103
103
}
104
104
105
- location := lib .GetLocation ()
105
+ location := lib .GetLocation (). String ()
106
106
if lib .ContainerPlatform != "" {
107
107
location = lib .GetContainerPlatform ()
108
108
}
Original file line number Diff line number Diff line change @@ -107,9 +107,9 @@ func GetOutputLibrary(lib *libraries.Library) *rpc.Library {
107
107
InstallDir : insdir ,
108
108
SourceDir : srcdir ,
109
109
UtilityDir : utldir ,
110
- Location : lib .Location .String (),
110
+ Location : lib .Location .ToRPCLibraryLocation (),
111
111
ContainerPlatform : cntplat ,
112
- Layout : lib .Layout .String (),
112
+ Layout : lib .Layout .ToRPCLibraryLayout (),
113
113
RealName : lib .RealName ,
114
114
DotALinkage : lib .DotALinkage ,
115
115
Precompiled : lib .Precompiled ,
You can’t perform that action at this time.
0 commit comments