Skip to content

Commit 706d825

Browse files
matthijskooijmancmaglie
authored andcommitted
Let ExecRecipe return the command executed
This prepares for building a compilation database later. The returned command is not currently used anywhere yet, so this commit should not change behaviour.
1 parent 6ff849f commit 706d825

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

legacy/builder/builder_utils/utils.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func compileFileWithRecipe(ctx *types.Context, sourcePath *paths.Path, source *p
248248
return nil, errors.WithStack(err)
249249
}
250250
if !objIsUpToDate {
251-
_, _, err := ExecRecipe(ctx, properties, recipe, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
251+
_, _, _, err := ExecRecipe(ctx, properties, recipe, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
252252
if err != nil {
253253
return nil, errors.WithStack(err)
254254
}
@@ -479,22 +479,23 @@ func ArchiveCompiledFiles(ctx *types.Context, buildPath *paths.Path, archiveFile
479479
properties.SetPath(constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH, archiveFilePath)
480480
properties.SetPath(constants.BUILD_PROPERTIES_OBJECT_FILE, objectFile)
481481

482-
if _, _, err := ExecRecipe(ctx, properties, constants.RECIPE_AR_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */); err != nil {
482+
if _, _, _, err := ExecRecipe(ctx, properties, constants.RECIPE_AR_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */); err != nil {
483483
return nil, errors.WithStack(err)
484484
}
485485
}
486486

487487
return archiveFilePath, nil
488488
}
489489

490-
func ExecRecipe(ctx *types.Context, buildProperties *properties.Map, recipe string, stdout int, stderr int) ([]byte, []byte, error) {
490+
func ExecRecipe(ctx *types.Context, buildProperties *properties.Map, recipe string, stdout int, stderr int) (*exec.Cmd, []byte, []byte, error) {
491491
// See util.ExecCommand for stdout/stderr arguments
492492
command, err := PrepareCommandForRecipe(buildProperties, recipe, false)
493493
if err != nil {
494-
return nil, nil, errors.WithStack(err)
494+
return nil, nil, nil, errors.WithStack(err)
495495
}
496496

497-
return utils.ExecCommand(ctx, command, stdout, stderr)
497+
outbytes, errbytes, err := utils.ExecCommand(ctx, command, stdout, stderr)
498+
return command, outbytes, errbytes, err
498499
}
499500

500501
const COMMANDLINE_LIMIT = 30000

legacy/builder/phases/linker.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
8080
properties.Set("archive_file", archive.Base())
8181
properties.SetPath("archive_file_path", archive)
8282
properties.SetPath("object_file", object)
83-
_, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_AR_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
83+
_, _, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_AR_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
8484
if err != nil {
8585
return err
8686
}
@@ -97,7 +97,7 @@ func link(ctx *types.Context, objectFiles paths.PathList, coreDotARelPath *paths
9797
properties.Set(constants.BUILD_PROPERTIES_ARCHIVE_FILE_PATH, coreArchiveFilePath.String())
9898
properties.Set("object_files", objectFileList)
9999

100-
_, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_C_COMBINE_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
100+
_, _, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_C_COMBINE_PATTERN, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
101101
return err
102102
}
103103

legacy/builder/phases/sizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func checkSize(ctx *types.Context, buildProperties *properties.Map) error {
112112
}
113113

114114
func execSizeRecipe(ctx *types.Context, properties *properties.Map) (textSize int, dataSize int, eepromSize int, resErr error) {
115-
out, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_SIZE_PATTERN, utils.Capture /* stdout */, utils.Show /* stderr */)
115+
_, out, _, err := builder_utils.ExecRecipe(ctx, properties, constants.RECIPE_SIZE_PATTERN, utils.Capture /* stdout */, utils.Show /* stderr */)
116116
if err != nil {
117117
resErr = errors.New("Error while determining sketch size: " + err.Error())
118118
return

legacy/builder/recipe_runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (s *RecipeByPrefixSuffixRunner) Run(ctx *types.Context) error {
4747
if ctx.DebugLevel >= 10 {
4848
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_DEBUG, constants.MSG_RUNNING_RECIPE, recipe)
4949
}
50-
_, _, err := builder_utils.ExecRecipe(ctx, properties, recipe, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
50+
_, _, _, err := builder_utils.ExecRecipe(ctx, properties, recipe, utils.ShowIfVerbose /* stdout */, utils.Show /* stderr */)
5151
if err != nil {
5252
return errors.WithStack(err)
5353
}

0 commit comments

Comments
 (0)