Skip to content

Commit 2d65d3e

Browse files
matthijskooijmanfacchinm
authored andcommitted
Let ExecRecipeCollectStdErr return []byte for stderr
Previously, the return value was converted to string. Letting callers convert to string makes it easier to write the sterr contents to os.Stderr again in a future commit. Signed-off-by: Matthijs Kooijman <[email protected]>
1 parent f293151 commit 2d65d3e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: src/arduino.cc/builder/builder_utils/utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,16 @@ func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, remo
455455
return command, nil
456456
}
457457

458-
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) (string, error) {
458+
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) ([]byte, error) {
459459
command, err := PrepareCommandForRecipe(buildProperties, recipe, removeUnsetProperties, echoCommandLine, echoOutput, logger)
460460
if err != nil {
461-
return "", i18n.WrapError(err)
461+
return nil, i18n.WrapError(err)
462462
}
463463

464464
buffer := &bytes.Buffer{}
465465
command.Stderr = buffer
466466
err = command.Run()
467-
return string(buffer.Bytes()), err
467+
return buffer.Bytes(), err
468468
}
469469

470470
func RemoveHyphenMDDFlagFromGCCCommandLine(buildProperties properties.Map) {

Diff for: src/arduino.cc/builder/container_find_includes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
333333
if err != nil && !is_exit_error {
334334
return i18n.WrapError(err)
335335
}
336-
include = IncludesFinderWithRegExp(ctx, stderr)
336+
include = IncludesFinderWithRegExp(ctx, string(stderr))
337337
}
338338

339339
if include == "" {

Diff for: src/arduino.cc/builder/gcc_preproc_runner.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ func GCCPreprocRunner(ctx *types.Context, sourceFilePath string, targetFilePath
6161
return nil
6262
}
6363

64-
func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath string, targetFilePath string, includes []string) (string, error) {
64+
func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath string, targetFilePath string, includes []string) ([]byte, error) {
6565
properties, err := prepareGCCPreprocRecipeProperties(ctx, sourceFilePath, targetFilePath, includes)
6666
if err != nil {
67-
return "", i18n.WrapError(err)
67+
return nil, i18n.WrapError(err)
6868
}
6969

7070
verbose := ctx.Verbose
@@ -77,10 +77,10 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath s
7777

7878
stderr, err := builder_utils.ExecRecipeCollectStdErr(properties, constants.RECIPE_PREPROC_MACROS, true, verbose, verbose, logger)
7979
if err != nil {
80-
return string(stderr), i18n.WrapError(err)
80+
return stderr, i18n.WrapError(err)
8181
}
8282

83-
return string(stderr), nil
83+
return stderr, nil
8484
}
8585

8686
func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath string, targetFilePath string, includes []string) (properties.Map, error) {

0 commit comments

Comments
 (0)