@@ -28,6 +28,7 @@ import (
2828 "github.com/arduino/arduino-cli/internal/i18n"
2929 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3030 "github.com/arduino/go-paths-helper"
31+ "go.bug.st/f"
3132 semver "go.bug.st/relaxed-semver"
3233 "gopkg.in/yaml.v3"
3334)
@@ -268,8 +269,9 @@ func (p *ProfilePlatformReference) UnmarshalYAML(unmarshal func(interface{}) err
268269
269270// ProfileLibraryReference is a reference to a library
270271type ProfileLibraryReference struct {
271- Library string
272- Version * semver.Version
272+ Library string
273+ InstallDir * paths.Path
274+ Version * semver.Version
273275}
274276
275277// UnmarshalYAML decodes a ProfileLibraryReference from YAML source.
@@ -278,6 +280,11 @@ func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) erro
278280 if err := unmarshal (& data ); err != nil {
279281 return err
280282 }
283+ if strings .HasPrefix (data , "file:" ) {
284+ l .InstallDir = paths .New (strings .TrimPrefix (data , "file:" ))
285+ l .Library = l .InstallDir .Base ()
286+ return nil
287+ }
281288 if libName , libVersion , ok := parseNameAndVersion (data ); ! ok {
282289 return fmt .Errorf ("%s %s" , i18n .Tr ("invalid library directive:" ), data )
283290 } else if v , err := semver .Parse (libVersion ); err != nil {
@@ -291,16 +298,23 @@ func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) erro
291298
292299// AsYaml outputs the required library as Yaml
293300func (l * ProfileLibraryReference ) AsYaml () string {
294- res := fmt .Sprintf (" - %s (%s)\n " , l .Library , l .Version )
295- return res
301+ if l .InstallDir != nil {
302+ return fmt .Sprintf (" - file:%s\n " , l .InstallDir )
303+ }
304+ return fmt .Sprintf (" - %s (%s)\n " , l .Library , l .Version )
296305}
297306
298307func (l * ProfileLibraryReference ) String () string {
308+ if l .InstallDir != nil {
309+ return fmt .Sprintf ("%s@file:%s" , l .Library , l .InstallDir )
310+ }
299311 return fmt .Sprintf ("%s@%s" , l .Library , l .Version )
300312}
301313
302314// InternalUniqueIdentifier returns the unique identifier for this object
303315func (l * ProfileLibraryReference ) InternalUniqueIdentifier () string {
316+ f .Assert (l .InstallDir == nil ,
317+ "InternalUniqueIdentifier should not be called for library references with an install directory" )
304318 id := l .String ()
305319 h := sha256 .Sum256 ([]byte (id ))
306320 res := fmt .Sprintf ("%s_%s" , id , hex .EncodeToString (h [:])[:16 ])
0 commit comments