16
16
package builder
17
17
18
18
import (
19
- "os/exec"
20
19
"strings"
21
20
22
21
f "github.com/arduino/arduino-cli/internal/algorithms"
@@ -25,19 +24,9 @@ import (
25
24
"github.com/arduino/arduino-cli/legacy/builder/utils"
26
25
"github.com/arduino/go-paths-helper"
27
26
properties "github.com/arduino/go-properties-orderedmap"
28
- "github.com/pkg/errors"
29
27
)
30
28
31
29
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 ) {
41
30
buildProperties := properties .NewMap ()
42
31
buildProperties .Set ("preproc.macros.flags" , "-w -x c++ -E -CC" )
43
32
buildProperties .Merge (ctx .BuildProperties )
@@ -61,12 +50,13 @@ func prepareGCCPreprocRecipeProperties(ctx *types.Context, sourceFilePath *paths
61
50
62
51
cmd , err := builder_utils .PrepareCommandForRecipe (buildProperties , "recipe.preproc.macros" , true , ctx .PackageManager .GetEnvVarsForSpawnedProcess ())
63
52
if err != nil {
64
- return nil , errors . WithStack ( err )
53
+ return nil , err
65
54
}
66
55
67
56
// Remove -MMD argument if present. Leaving it will make gcc try
68
57
// to create a /dev/null.d dependency file, which won't work.
69
58
cmd .Args = f .Filter (cmd .Args , f .NotEquals ("-MMD" ))
70
59
71
- return cmd , nil
60
+ _ , stderr , err := utils .ExecCommand (ctx , cmd , utils .ShowIfVerbose /* stdout */ , utils .Capture /* stderr */ )
61
+ return stderr , err
72
62
}
0 commit comments