@@ -41,6 +41,7 @@ import (
4141 "github.com/arduino/arduino-cli/internal/i18n"
4242 "github.com/arduino/go-paths-helper"
4343 "github.com/arduino/go-properties-orderedmap"
44+ "github.com/sirupsen/logrus"
4445)
4546
4647type libraryResolutionResult struct {
@@ -140,6 +141,7 @@ func (l *SketchLibrariesDetector) ImportedLibraries() libraries.List {
140141// addAndBuildLibrary adds the given library to the imported libraries list and queues its source files
141142// for further processing.
142143func (l * SketchLibrariesDetector ) addAndBuildLibrary (sourceFileQueue * uniqueSourceFileQueue , librariesBuildPath * paths.Path , library * libraries.Library ) {
144+ logrus .Tracef ("[LD] LIBRARY: %s" , library .Name )
143145 l .importedLibraries = append (l .importedLibraries , library )
144146 if library .Precompiled && library .PrecompiledWithSources {
145147 // Fully precompiled libraries should have no dependencies to avoid ABI breakage
@@ -202,6 +204,7 @@ func (l *SketchLibrariesDetector) IncludeFoldersChanged() bool {
202204
203205// addIncludeFolder add the given folder to the include path.
204206func (l * SketchLibrariesDetector ) addIncludeFolder (folder * paths.Path ) {
207+ logrus .Tracef ("[LD] INCLUDE-PATH: %s" , folder .String ())
205208 l .includeFolders = append (l .includeFolders , folder )
206209 l .cache .Expect (& detectorCacheEntry {AddedIncludePath : folder })
207210}
@@ -219,6 +222,11 @@ func (l *SketchLibrariesDetector) FindIncludes(
219222 platformArch string ,
220223 jobs int ,
221224) error {
225+ logrus .Debug ("Finding required libraries for the sketch." )
226+ defer func () {
227+ logrus .Debugf ("Library detection completed. Found %d required libraries." , len (l .importedLibraries ))
228+ }()
229+
222230 err := l .findIncludes (ctx , buildPath , buildCorePath , buildVariantPath , sketchBuildPath , sketch , librariesBuildPath , buildProperties , platformArch , jobs )
223231 if err != nil && l .onlyUpdateCompilationDatabase {
224232 l .logger .Info (
@@ -273,7 +281,7 @@ func (l *SketchLibrariesDetector) findIncludes(
273281 l .preRunner = runner .New (ctx , jobs )
274282 for _ , entry := range l .cache .EntriesAhead () {
275283 if entry .CompileTask != nil {
276- upToDate , _ := entry .Compile .ObjFileIsUpToDate ()
284+ upToDate , _ := entry .Compile .ObjFileIsUpToDate (logrus . WithField ( "runner" , "prerun" ) )
277285 if ! upToDate {
278286 _ = entry .Compile .PrepareBuildPath ()
279287 l .preRunner .Enqueue (entry .CompileTask )
@@ -387,7 +395,7 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
387395 // TODO: This reads the dependency file, but the actual building
388396 // does it again. Should the result be somehow cached? Perhaps
389397 // remove the object file if it is found to be stale?
390- unchanged , err := sourceFile .ObjFileIsUpToDate ()
398+ unchanged , err := sourceFile .ObjFileIsUpToDate (logrus . WithField ( "runner" , "main" ) )
391399 if err != nil {
392400 return err
393401 }
@@ -403,11 +411,13 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
403411 var missingIncludeH string
404412 if entry := l .cache .Peek (); unchanged && entry != nil && entry .MissingIncludeH != nil {
405413 missingIncludeH = * entry .MissingIncludeH
414+ logrus .Tracef ("[LD] COMPILE-CACHE: %s" , sourceFile .SourcePath )
406415 if first && l .logger .VerbosityLevel () == logger .VerbosityVerbose {
407416 l .logger .Info (i18n .Tr ("Using cached library dependencies for file: %[1]s" , sourcePath ))
408417 }
409418 first = false
410419 } else {
420+ logrus .Tracef ("[LD] COMPILE: %s" , sourceFile .SourcePath )
411421 if l .preRunner != nil {
412422 if r := l .preRunner .Results (preprocTask ); r != nil {
413423 preprocResult = r
@@ -448,6 +458,7 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
448458 }
449459 }
450460
461+ logrus .Tracef ("[LD] MISSING: %s" , missingIncludeH )
451462 l .cache .Expect (& detectorCacheEntry {MissingIncludeH : & missingIncludeH })
452463
453464 if missingIncludeH == "" {
@@ -495,6 +506,8 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
495506 buildDir * paths.Path ,
496507 extraIncludePath ... * paths.Path ,
497508) error {
509+ logrus .Tracef ("[LD] SCAN: %s (recurse=%v)" , folder , recurse )
510+
498511 sourceFileExtensions := []string {}
499512 for k := range globals .SourceFilesValidExtensions {
500513 sourceFileExtensions = append (sourceFileExtensions , k )
0 commit comments