Skip to content

Commit 93740ed

Browse files
committed
Added debugging prints for SourceFile structs
1 parent 224f05f commit 93740ed

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

legacy/builder/container_find_includes.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import (
106106
"github.com/arduino/arduino-cli/legacy/builder/utils"
107107
"github.com/arduino/go-paths-helper"
108108
"github.com/pkg/errors"
109+
"github.com/sirupsen/logrus"
109110
)
110111

111112
type ContainerFindIncludes struct{}
@@ -132,12 +133,14 @@ type CppIncludesFinder struct {
132133
cache *includeCache
133134
sketch *types.Sketch
134135
queue *UniqueSourceFileQueue
136+
log *logrus.Entry
135137
}
136138

137139
func (f *CppIncludesFinder) DetectLibraries() error {
138140
f.cache = loadCacheFrom(f.ctx.BuildPath.Join("includes.cache"))
139141
f.sketch = f.ctx.Sketch
140142
f.queue = &UniqueSourceFileQueue{}
143+
f.log = logrus.WithField("task", "DetectingLibraries")
141144

142145
f.appendIncludeFolder(nil, "", f.ctx.BuildProperties.GetPath("build.core.path"))
143146
if f.ctx.BuildProperties.Get("build.variant.path") != "" {
@@ -148,6 +151,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
148151
if err != nil {
149152
return errors.WithStack(err)
150153
}
154+
f.log.Debugf("Queueing merged sketch: %s", mergedfile)
151155
f.queue.Push(mergedfile)
152156

153157
f.queueSourceFilesFromFolder(nil, f.ctx.SketchBuildPath, false /* recurse */)
@@ -177,6 +181,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
177181
// and should be the empty string for the default include folders, like
178182
// the core or variant.
179183
func (f *CppIncludesFinder) appendIncludeFolder(sourceFilePath *paths.Path, include string, folder *paths.Path) {
184+
f.log.Debugf("Using include folder: %s", folder)
180185
f.ctx.IncludeFolders = append(f.ctx.IncludeFolders, folder)
181186
f.cache.ExpectEntry(sourceFilePath, include, folder)
182187
}
@@ -403,7 +408,7 @@ func (f *CppIncludesFinder) findIncludesUntilDone(sourceFile SourceFile) error {
403408

404409
func (f *CppIncludesFinder) queueSourceFilesFromFolder(lib *libraries.Library, folder *paths.Path, recurse bool) error {
405410
extensions := func(ext string) bool { return ADDITIONAL_FILE_VALID_EXTENSIONS_NO_HEADERS[ext] }
406-
411+
f.log.Debugf(" Queueing source files from %s (recurse %v)", folder, recurse)
407412
filePaths := []string{}
408413
err := utils.FindFilesInFolder(&filePaths, folder.String(), extensions, recurse)
409414
if err != nil {
@@ -415,6 +420,7 @@ func (f *CppIncludesFinder) queueSourceFilesFromFolder(lib *libraries.Library, f
415420
if err != nil {
416421
return errors.WithStack(err)
417422
}
423+
f.log.Debugf(" Queuing %s", sourceFile)
418424
f.queue.Push(sourceFile)
419425
}
420426

@@ -427,6 +433,13 @@ type SourceFile struct {
427433

428434
// Path to the source file within the sketch/library root folder
429435
RelativePath *paths.Path
436+
437+
ctx *types.Context
438+
}
439+
440+
func (f SourceFile) String() string {
441+
return fmt.Sprintf("Root: %s - Path: %s - BuildPath: %s",
442+
sourceRoot(f.ctx, f.Library), f.RelativePath, buildRoot(f.ctx, f.Library))
430443
}
431444

432445
// Create a SourceFile containing the given source file path within the
@@ -440,7 +453,7 @@ func MakeSourceFile(ctx *types.Context, lib *libraries.Library, path *paths.Path
440453
return SourceFile{}, err
441454
}
442455
}
443-
return SourceFile{Library: lib, RelativePath: path}, nil
456+
return SourceFile{Library: lib, RelativePath: path, ctx: ctx}, nil
444457
}
445458

446459
// Return the build root for the given origin, where build products will

legacy/builder/test/includes_to_include_folders_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/arduino/arduino-cli/legacy/builder"
2424
"github.com/arduino/arduino-cli/legacy/builder/types"
2525
paths "github.com/arduino/go-paths-helper"
26+
"github.com/sirupsen/logrus"
2627
"github.com/stretchr/testify/require"
2728
)
2829

@@ -297,6 +298,7 @@ func TestIncludesToIncludeFoldersSubfolders(t *testing.T) {
297298
Verbose: true,
298299
}
299300

301+
logrus.SetLevel(logrus.DebugLevel)
300302
buildPath := SetupBuildPath(t, ctx)
301303
defer buildPath.RemoveAll()
302304

0 commit comments

Comments
 (0)