Skip to content

Commit 1ff5393

Browse files
make RunRecipe a method recevier of arduino/builder
1 parent a9cfb1c commit 1ff5393

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

legacy/builder/recipe_runner.go renamed to arduino/builder/recipe.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,21 @@ import (
2020
"sort"
2121
"strings"
2222

23-
"github.com/arduino/arduino-cli/arduino/builder/logger"
2423
"github.com/arduino/arduino-cli/arduino/builder/utils"
2524
properties "github.com/arduino/go-properties-orderedmap"
2625
"github.com/pkg/errors"
2726
"github.com/sirupsen/logrus"
2827
)
2928

30-
func RecipeByPrefixSuffixRunner(
29+
// RunRecipe fixdoc
30+
func (b *Builder) RunRecipe(
3131
prefix, suffix string,
3232
skipIfOnlyUpdatingCompilationDatabase, onlyUpdateCompilationDatabase bool,
33-
buildProps *properties.Map,
34-
builderLogger *logger.BuilderLogger,
3533
) error {
3634
logrus.Debugf(fmt.Sprintf("Looking for recipes like %s", prefix+"*"+suffix))
3735

3836
// TODO is it necessary to use Clone?
39-
buildProperties := buildProps.Clone()
37+
buildProperties := b.buildProperties.Clone()
4038
recipes := findRecipes(buildProperties, prefix, suffix)
4139

4240
// TODO is it necessary to use Clone?
@@ -50,15 +48,15 @@ func RecipeByPrefixSuffixRunner(
5048
}
5149

5250
if onlyUpdateCompilationDatabase && skipIfOnlyUpdatingCompilationDatabase {
53-
if builderLogger.Verbose() {
54-
builderLogger.Info(tr("Skipping: %[1]s", strings.Join(command.GetArgs(), " ")))
51+
if b.logger.Verbose() {
52+
b.logger.Info(tr("Skipping: %[1]s", strings.Join(command.GetArgs(), " ")))
5553
}
5654
return nil
5755
}
5856

59-
verboseInfo, _, _, err := utils.ExecCommand(builderLogger.Verbose(), builderLogger.Stdout(), builderLogger.Stderr(), command, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
60-
if builderLogger.Verbose() {
61-
builderLogger.Info(string(verboseInfo))
57+
verboseInfo, _, _, err := utils.ExecCommand(b.logger.Verbose(), b.logger.Stdout(), b.logger.Stderr(), command, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
58+
if b.logger.Verbose() {
59+
b.logger.Info(string(verboseInfo))
6260
}
6361
if err != nil {
6462
return errors.WithStack(err)

commands/compile/compile.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,9 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
339339
exportBinaries = false
340340
}
341341
if exportBinaries {
342-
err := builder.RecipeByPrefixSuffixRunner(
342+
err := sketchBuilder.RunRecipe(
343343
"recipe.hooks.savehex.presavehex", ".pattern", false,
344344
builderCtx.OnlyUpdateCompilationDatabase,
345-
sketchBuilder.GetBuildProperties(),
346-
builderLogger,
347345
)
348346
if err != nil {
349347
return r, err
@@ -383,10 +381,9 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
383381
}
384382
}
385383

386-
err = builder.RecipeByPrefixSuffixRunner(
384+
err = sketchBuilder.RunRecipe(
387385
"recipe.hooks.savehex.postsavehex", ".pattern", false,
388386
builderCtx.OnlyUpdateCompilationDatabase,
389-
sketchBuilder.GetBuildProperties(), builderLogger,
390387
)
391388
if err != nil {
392389
return r, err

legacy/builder/builder.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,9 @@ func logIfVerbose(warn bool, msg string) types.BareCommand {
390390
}
391391

392392
func recipeByPrefixSuffixRunner(ctx *types.Context, prefix, suffix string, skipIfOnlyUpdatingCompilationDatabase bool) error {
393-
return RecipeByPrefixSuffixRunner(
393+
return ctx.Builder.RunRecipe(
394394
prefix, suffix, skipIfOnlyUpdatingCompilationDatabase,
395395
ctx.OnlyUpdateCompilationDatabase,
396-
ctx.Builder.GetBuildProperties(),
397-
ctx.BuilderLogger,
398396
)
399397
}
400398

0 commit comments

Comments
 (0)