Skip to content

Commit 2a661e8

Browse files
committed
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 4601b98 commit 2a661e8

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
@@ -455,7 +455,7 @@ func (b *Builder) build() error {
455455
}
456456
b.Progress.CompleteStep()
457457

458-
if err := b.RunRecipe("recipe.objcopy.", ".pattern", true); err != nil {
458+
if err := b.RunRecipe("recipe.objcopy", ".pattern", true); err != nil {
459459
return err
460460
}
461461
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)