Skip to content

Commit 2baed3c

Browse files
committed
linker: switch 'recipe.c.combine.pattern' to a recipe
Enable the use of recipes for the `recipe.c.combine.pattern` command. Allows for more flexibility in the build process. Signed-off-by: Luca Burelli <[email protected]>
1 parent 2a661e8 commit 2baed3c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

docs/platform-specification.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ compiler.libraries.ldflags=
302302
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} "{archive_file_path}" "-L{build.path}" -lm
303303
```
304304

305+
If the linking process requires multiple steps, the recipe can be written using the **recipe.c.combine.NUMBER.pattern**
306+
syntax. In this case, each step will be executed in the order specified by the number. When multiple steps are defined,
307+
the **recipe.c.combine.pattern** property is ignored.
308+
305309
#### Recipes for extraction of executable files and other binary data
306310

307311
An arbitrary number of extra steps can be performed at the end of objects linking. These steps can be used to extract

internal/arduino/builder/linker.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,5 @@ func (b *Builder) link() error {
9090
properties.Set("archive_file_path", b.buildArtifacts.coreArchiveFilePath.String())
9191
properties.Set("object_files", objectFileList)
9292

93-
command, err := b.prepareCommandForRecipe(properties, "recipe.c.combine.pattern", false)
94-
if err != nil {
95-
return err
96-
}
97-
98-
return b.execCommand(command)
93+
return b.RunRecipeWithProps("recipe.c.combine", ".pattern", properties, false)
9994
}

internal/arduino/builder/recipe.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ import (
2727

2828
// RunRecipe fixdoc
2929
func (b *Builder) RunRecipe(prefix, suffix string, skipIfOnlyUpdatingCompilationDatabase bool) error {
30+
// TODO is it necessary to use Clone?
31+
return b.RunRecipeWithProps(prefix, suffix, b.buildProperties.Clone(), skipIfOnlyUpdatingCompilationDatabase)
32+
}
33+
34+
func (b *Builder) RunRecipeWithProps(prefix, suffix string, buildProperties *properties.Map, skipIfOnlyUpdatingCompilationDatabase bool) error {
3035
logrus.Debugf("Looking for recipes like %s", prefix+"*"+suffix)
3136

32-
// TODO is it necessary to use Clone?
33-
buildProperties := b.buildProperties.Clone()
3437
recipes := findRecipes(buildProperties, prefix, suffix)
3538

3639
// TODO is it necessary to use Clone?

0 commit comments

Comments
 (0)