Skip to content

Commit

Permalink
Add BuilderLogger in arduino/builder
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 12, 2023
1 parent d19de33 commit 340217e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions arduino/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"

"github.com/arduino/arduino-cli/arduino/builder/logger"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
Expand All @@ -45,6 +46,8 @@ type Builder struct {

// core related
coreBuildCachePath *paths.Path

logger *logger.BuilderLogger
}

// NewBuilder creates a sketch Builder.
Expand All @@ -56,6 +59,7 @@ func NewBuilder(
coreBuildCachePath *paths.Path,
jobs int,
requestBuildProperties []string,
logger *logger.BuilderLogger,
) (*Builder, error) {
buildProperties := properties.NewMap()
if boardBuildProperties != nil {
Expand Down Expand Up @@ -113,6 +117,7 @@ func NewBuilder(
jobs: jobs,
customBuildProperties: append(requestBuildProperties, "build.warn_data_percentage=75"),
coreBuildCachePath: coreBuildCachePath,
logger: logger,
}, nil
}

Expand Down
6 changes: 3 additions & 3 deletions arduino/builder/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestMergeSketchSources(t *testing.T) {
}
mergedSources := strings.ReplaceAll(string(mergedBytes), "%s", pathToGoldenSource)

b, err := NewBuilder(sk, nil, paths.New("testdata"), false, nil, 0, nil)
b, err := NewBuilder(sk, nil, paths.New("testdata"), false, nil, 0, nil, nil)
require.NoError(t, err)

offset, source, err := b.sketchMergeSources(nil)
Expand All @@ -63,7 +63,7 @@ func TestMergeSketchSourcesArduinoIncluded(t *testing.T) {
require.NotNil(t, sk)

// ensure not to include Arduino.h when it's already there
b, err := NewBuilder(sk, nil, paths.New("testdata"), false, nil, 0, nil)
b, err := NewBuilder(sk, nil, paths.New("testdata"), false, nil, 0, nil, nil)
require.NoError(t, err)

_, source, err := b.sketchMergeSources(nil)
Expand All @@ -80,7 +80,7 @@ func TestCopyAdditionalFiles(t *testing.T) {
sk1, err := sketch.New(paths.New("testdata", t.Name()))
require.Nil(t, err)
require.Equal(t, sk1.AdditionalFiles.Len(), 1)
b1, err := NewBuilder(sk1, nil, paths.New("testdata"), false, nil, 0, nil)
b1, err := NewBuilder(sk1, nil, paths.New("testdata"), false, nil, 0, nil, nil)
require.NoError(t, err)

// copy the sketch over, create a fake main file we don't care about it
Expand Down
1 change: 1 addition & 0 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
coreBuildCachePath,
int(req.GetJobs()),
req.GetBuildProperties(),
builderLogger,
)
if err != nil {
if strings.Contains(err.Error(), "invalid build properties") {
Expand Down
4 changes: 2 additions & 2 deletions legacy/builder/test/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *pat

builderLogger := logger.New(nil, nil, false, "")
ctx.BuilderLogger = builderLogger
ctx.Builder, err = bldr.NewBuilder(sk, nil, buildPath, false, nil, 0, nil)
ctx.Builder, err = bldr.NewBuilder(sk, nil, buildPath, false, nil, 0, nil, builderLogger)
require.NoError(t, err)
if fqbn != "" {
ctx.FQBN = parseFQBN(t, fqbn)
Expand All @@ -112,7 +112,7 @@ func prepareBuilderTestContext(t *testing.T, ctx *types.Context, sketchPath *pat
requiredTools, err := pme.FindToolsRequiredForBuild(targetPlatform, buildPlatform)
require.NoError(t, err)

ctx.Builder, err = bldr.NewBuilder(sk, boardBuildProperties, buildPath, false /*OptimizeForDebug*/, nil, 0, nil)
ctx.Builder, err = bldr.NewBuilder(sk, boardBuildProperties, buildPath, false /*OptimizeForDebug*/, nil, 0, nil, builderLogger)
require.NoError(t, err)

ctx.PackageManager = pme
Expand Down

0 comments on commit 340217e

Please sign in to comment.