Skip to content

Commit 117f079

Browse files
committed
Simplified GCCPreprocRunner function
1 parent e3f80ff commit 117f079

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

legacy/builder/gcc_preproc_runner.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package builder
1717

1818
import (
19-
"os/exec"
2019
"strings"
2120

2221
f "github.com/arduino/arduino-cli/internal/algorithms"
@@ -25,19 +24,9 @@ import (
2524
"github.com/arduino/arduino-cli/legacy/builder/utils"
2625
"github.com/arduino/go-paths-helper"
2726
properties "github.com/arduino/go-properties-orderedmap"
28-
"github.com/pkg/errors"
2927
)
3028

3129
func GCCPreprocRunner(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) ([]byte, error) {
32-
cmd, err := prepareGCCPreprocRecipeProperties(ctx, sourceFilePath, targetFilePath, includes)
33-
if err != nil {
34-
return nil, err
35-
}
36-
_, stderr, err := utils.ExecCommand(ctx, cmd, utils.ShowIfVerbose /* stdout */, utils.Capture /* stderr */)
37-
return stderr, err
38-
}
39-
40-
func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) (*exec.Cmd, error) {
4130
buildProperties := properties.NewMap()
4231
buildProperties.Set("preproc.macros.flags", "-w -x c++ -E -CC")
4332
buildProperties.Merge(ctx.BuildProperties)
@@ -61,12 +50,13 @@ func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths
6150

6251
cmd, err := builder_utils.PrepareCommandForRecipe(buildProperties, "recipe.preproc.macros", true, ctx.PackageManager.GetEnvVarsForSpawnedProcess())
6352
if err != nil {
64-
return nil, errors.WithStack(err)
53+
return nil, err
6554
}
6655

6756
// Remove -MMD argument if present. Leaving it will make gcc try
6857
// to create a /dev/null.d dependency file, which won't work.
6958
cmd.Args = f.Filter(cmd.Args, f.NotEquals("-MMD"))
7059

71-
return cmd, nil
60+
_, stderr, err := utils.ExecCommand(ctx, cmd, utils.ShowIfVerbose /* stdout */, utils.Capture /* stderr */)
61+
return stderr, err
7262
}

0 commit comments

Comments
 (0)