Skip to content

Commit f536f7b

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 d7185a9 commit f536f7b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: builder_utils/utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,16 @@ func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, remo
451451
return command, nil
452452
}
453453

454-
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) (string, error) {
454+
func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, removeUnsetProperties bool, echoCommandLine bool, echoOutput bool, logger i18n.Logger) ([]byte, error) {
455455
command, err := PrepareCommandForRecipe(buildProperties, recipe, removeUnsetProperties, echoCommandLine, echoOutput, logger)
456456
if err != nil {
457-
return "", i18n.WrapError(err)
457+
return nil, i18n.WrapError(err)
458458
}
459459

460460
buffer := &bytes.Buffer{}
461461
command.Stderr = buffer
462462
err = command.Run()
463-
return string(buffer.Bytes()), err
463+
return buffer.Bytes(), err
464464
}
465465

466466
func RemoveHyphenMDDFlagFromGCCCommandLine(buildProperties properties.Map) {

Diff for: 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: 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)