Skip to content

Commit 8563553

Browse files
matthijskooijmancmaglie
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 deaed66 commit 8563553

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
@@ -452,16 +452,16 @@ func PrepareCommandForRecipe(buildProperties properties.Map, recipe string, remo
452452
return command, nil
453453
}
454454

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

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

467467
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)