Skip to content

Commit 5acd942

Browse files
committed
Added debugging prints for SourceFile structs
1 parent 6525495 commit 5acd942

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
@@ -105,6 +105,7 @@ import (
105105
"github.com/arduino/arduino-cli/legacy/builder/utils"
106106
"github.com/arduino/go-paths-helper"
107107
"github.com/pkg/errors"
108+
"github.com/sirupsen/logrus"
108109
)
109110

110111
type ContainerFindIncludes struct{}
@@ -143,12 +144,14 @@ type CppIncludesFinder struct {
143144
cache *includeCache
144145
sketch *sketch.Sketch
145146
queue *UniqueSourceFileQueue
147+
log *logrus.Entry
146148
}
147149

148150
func (f *CppIncludesFinder) DetectLibraries() error {
149151
f.cache = loadCacheFrom(f.ctx.BuildPath.Join("includes.cache"))
150152
f.sketch = f.ctx.Sketch
151153
f.queue = &UniqueSourceFileQueue{}
154+
f.log = logrus.WithField("task", "DetectingLibraries")
152155

153156
f.appendIncludeFolder(nil, "", f.ctx.BuildProperties.GetPath("build.core.path"))
154157
if f.ctx.BuildProperties.Get("build.variant.path") != "" {
@@ -159,6 +162,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
159162
if err != nil {
160163
return errors.WithStack(err)
161164
}
165+
f.log.Debugf("Queueing merged sketch: %s", mergedfile)
162166
f.queue.Push(mergedfile)
163167

164168
f.queueSourceFilesFromFolder(nil, f.ctx.SketchBuildPath, false /* recurse */)
@@ -188,6 +192,7 @@ func (f *CppIncludesFinder) DetectLibraries() error {
188192
// and should be the empty string for the default include folders, like
189193
// the core or variant.
190194
func (f *CppIncludesFinder) appendIncludeFolder(sourceFilePath *paths.Path, include string, folder *paths.Path) {
195+
f.log.Debugf("Using include folder: %s", folder)
191196
f.ctx.IncludeFolders = append(f.ctx.IncludeFolders, folder)
192197
f.cache.ExpectEntry(sourceFilePath, include, folder)
193198
}
@@ -422,7 +427,7 @@ func (f *CppIncludesFinder) findIncludesUntilDone(sourceFile SourceFile) error {
422427

423428
func (f *CppIncludesFinder) queueSourceFilesFromFolder(lib *libraries.Library, folder *paths.Path, recurse bool) error {
424429
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)
426431
filePaths := []string{}
427432
err := utils.FindFilesInFolder(&filePaths, folder.String(), extensions, recurse)
428433
if err != nil {
@@ -434,6 +439,7 @@ func (f *CppIncludesFinder) queueSourceFilesFromFolder(lib *libraries.Library, f
434439
if err != nil {
435440
return errors.WithStack(err)
436441
}
442+
f.log.Debugf(" Queuing %s", sourceFile)
437443
f.queue.Push(sourceFile)
438444
}
439445

@@ -446,6 +452,13 @@ type SourceFile struct {
446452

447453
// Path to the source file within the sketch/library root folder
448454
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))
449462
}
450463

451464
// 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
459472
return SourceFile{}, err
460473
}
461474
}
462-
return SourceFile{Library: lib, RelativePath: path}, nil
475+
return SourceFile{Library: lib, RelativePath: path, ctx: ctx}, nil
463476
}
464477

465478
// 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)