Skip to content

Commit 6c68bbf

Browse files
pillo79cmaglie
authored andcommitted
builder: RunRecipe: run either a set of recipes or a single recipe
Recipes must follow the 'prefix.NNN.suffix' pattern, where 'NNN' is a number. When there is also a single 'prefix.suffix' property defined, make sure to not include that in the list of recipes to run. However, if no numbered recipes are found, use the single 'prefix.suffix' form if it exists. This allows to have both a single recipe and a set of numbered recipes in the same build properties, for backwards compatibility. Signed-off-by: Luca Burelli <[email protected]>
1 parent 4e58200 commit 6c68bbf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

internal/arduino/builder/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func (b *Builder) build() error {
464464
}
465465
b.Progress.CompleteStep()
466466

467-
if err := b.RunRecipe("recipe.objcopy.", ".pattern", true); err != nil {
467+
if err := b.RunRecipe("recipe.objcopy", ".pattern", true); err != nil {
468468
return err
469469
}
470470
b.Progress.CompleteStep()

internal/arduino/builder/recipe.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,20 @@ func (b *Builder) RunRecipe(prefix, suffix string, skipIfOnlyUpdatingCompilation
6060

6161
func findRecipes(buildProperties *properties.Map, patternPrefix string, patternSuffix string) []string {
6262
var recipes []string
63+
64+
exactKey := patternPrefix + patternSuffix
65+
6366
for _, key := range buildProperties.Keys() {
64-
if strings.HasPrefix(key, patternPrefix) && strings.HasSuffix(key, patternSuffix) && buildProperties.Get(key) != "" {
67+
if key != exactKey && strings.HasPrefix(key, patternPrefix) && strings.HasSuffix(key, patternSuffix) && buildProperties.Get(key) != "" {
6568
recipes = append(recipes, key)
6669
}
6770
}
6871

72+
// If no recipes were found, check if the exact key exists
73+
if len(recipes) == 0 && buildProperties.Get(exactKey) != "" {
74+
recipes = append(recipes, exactKey)
75+
}
76+
6977
sort.Strings(recipes)
7078

7179
return recipes

0 commit comments

Comments
 (0)