@@ -105,6 +105,7 @@ import (
105
105
"github.com/arduino/arduino-cli/legacy/builder/utils"
106
106
"github.com/arduino/go-paths-helper"
107
107
"github.com/pkg/errors"
108
+ "github.com/sirupsen/logrus"
108
109
)
109
110
110
111
type ContainerFindIncludes struct {}
@@ -143,12 +144,14 @@ type CppIncludesFinder struct {
143
144
cache * includeCache
144
145
sketch * sketch.Sketch
145
146
queue * UniqueSourceFileQueue
147
+ log * logrus.Entry
146
148
}
147
149
148
150
func (f * CppIncludesFinder ) DetectLibraries () error {
149
151
f .cache = loadCacheFrom (f .ctx .BuildPath .Join ("includes.cache" ))
150
152
f .sketch = f .ctx .Sketch
151
153
f .queue = & UniqueSourceFileQueue {}
154
+ f .log = logrus .WithField ("task" , "DetectingLibraries" )
152
155
153
156
f .appendIncludeFolder (nil , "" , f .ctx .BuildProperties .GetPath ("build.core.path" ))
154
157
if f .ctx .BuildProperties .Get ("build.variant.path" ) != "" {
@@ -159,6 +162,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
159
162
if err != nil {
160
163
return errors .WithStack (err )
161
164
}
165
+ f .log .Debugf ("Queueing merged sketch: %s" , mergedfile )
162
166
f .queue .Push (mergedfile )
163
167
164
168
f .queueSourceFilesFromFolder (nil , f .ctx .SketchBuildPath , false /* recurse */ )
@@ -188,6 +192,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
188
192
// and should be the empty string for the default include folders, like
189
193
// the core or variant.
190
194
func (f * CppIncludesFinder ) appendIncludeFolder (sourceFilePath * paths.Path , include string , folder * paths.Path ) {
195
+ f .log .Debugf ("Using include folder: %s" , folder )
191
196
f .ctx .IncludeFolders = append (f .ctx .IncludeFolders , folder )
192
197
f .cache .ExpectEntry (sourceFilePath , include , folder )
193
198
}
@@ -422,7 +427,7 @@ func (f *CppIncludesFinder) findIncludesUntilDone(sourceFile SourceFile) error {
422
427
423
428
func (f * CppIncludesFinder ) queueSourceFilesFromFolder (lib * libraries.Library , folder * paths.Path , recurse bool ) error {
424
429
extensions := func (ext string ) bool { return ADDITIONAL_FILE_VALID_EXTENSIONS_NO_HEADERS [ext ] }
425
-
430
+ f . log . Debugf ( " Queueing source files from %s (recurse %v)" , folder , recurse )
426
431
filePaths := []string {}
427
432
err := utils .FindFilesInFolder (& filePaths , folder .String (), extensions , recurse )
428
433
if err != nil {
@@ -434,6 +439,7 @@ func (f *CppIncludesFinder) queueSourceFilesFromFolder(lib *libraries.Library, f
434
439
if err != nil {
435
440
return errors .WithStack (err )
436
441
}
442
+ f .log .Debugf (" Queuing %s" , sourceFile )
437
443
f .queue .Push (sourceFile )
438
444
}
439
445
@@ -446,6 +452,13 @@ type SourceFile struct {
446
452
447
453
// Path to the source file within the sketch/library root folder
448
454
RelativePath * paths.Path
455
+
456
+ ctx * types.Context
457
+ }
458
+
459
+ func (f SourceFile ) String () string {
460
+ return fmt .Sprintf ("Root: %s - Path: %s - BuildPath: %s" ,
461
+ sourceRoot (f .ctx , f .Library ), f .RelativePath , buildRoot (f .ctx , f .Library ))
449
462
}
450
463
451
464
// Create a SourceFile containing the given source file path within the
@@ -459,7 +472,7 @@ func MakeSourceFile(ctx *types.Context, lib *libraries.Library, path *paths.Path
459
472
return SourceFile {}, err
460
473
}
461
474
}
462
- return SourceFile {Library : lib , RelativePath : path }, nil
475
+ return SourceFile {Library : lib , RelativePath : path , ctx : ctx }, nil
463
476
}
464
477
465
478
// Return the build root for the given origin, where build products will
0 commit comments