Skip to content

Commit a37057c

Browse files
committed
Dump custom libraries in profiles with --dump-profile command
1 parent a9cabb3 commit a37057c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

internal/cli/compile/compile.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,22 +323,23 @@ func runCompileCommand(cmd *cobra.Command, args []string, srv rpc.ArduinoCoreSer
323323
// Output profile
324324

325325
libs := ""
326-
hasVendoredLibs := false
327326
for _, lib := range builderRes.GetUsedLibraries() {
328327
if lib.GetLocation() != rpc.LibraryLocation_LIBRARY_LOCATION_USER && lib.GetLocation() != rpc.LibraryLocation_LIBRARY_LOCATION_UNMANAGED {
329328
continue
330329
}
331-
if lib.GetVersion() == "" {
332-
hasVendoredLibs = true
333-
continue
330+
if lib.GetVersion() == "" || lib.Location == rpc.LibraryLocation_LIBRARY_LOCATION_UNMANAGED {
331+
libDir := paths.New(lib.GetInstallDir())
332+
// If the library is installed in the sketch path, we want to output the relative path
333+
// to the sketch path, so that the sketch is portable.
334+
if ok, err := libDir.IsInsideDir(sketchPath); err == nil && ok {
335+
if ref, err := libDir.RelFrom(sketchPath); err == nil {
336+
libDir = ref
337+
}
338+
}
339+
libs += fmt.Sprintln(" - dir: " + libDir.String())
340+
} else {
341+
libs += fmt.Sprintln(" - " + lib.GetName() + " (" + lib.GetVersion() + ")")
334342
}
335-
libs += fmt.Sprintln(" - " + lib.GetName() + " (" + lib.GetVersion() + ")")
336-
}
337-
if hasVendoredLibs {
338-
msg := "\n"
339-
msg += i18n.Tr("WARNING: The sketch is compiled using one or more custom libraries.") + "\n"
340-
msg += i18n.Tr("Currently, Build Profiles only support libraries available through Arduino Library Manager.")
341-
feedback.Warning(msg)
342343
}
343344

344345
newProfileName := "my_profile_name"

0 commit comments

Comments
 (0)