1
1
// This file is part of arduino-cli.
2
2
//
3
- // Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
3
+ // Copyright 2023 ARDUINO SA (http://www.arduino.cc/)
4
4
//
5
5
// This software is released under the GNU General Public License version 3,
6
6
// which covers the main part of arduino-cli.
13
13
// Arduino software without disclosing the source code of your own applications.
14
14
// To purchase a commercial license, send an email to [email protected] .
15
15
16
- package builder
16
+ package preprocessor
17
17
18
18
import (
19
- "bytes"
19
+ "context"
20
+ "fmt"
20
21
"strings"
21
22
22
23
"github.com/arduino/arduino-cli/executils"
24
+ "github.com/arduino/arduino-cli/i18n"
23
25
"github.com/arduino/go-paths-helper"
24
- properties "github.com/arduino/go-properties-orderedmap"
26
+ "github.com/arduino/go-properties-orderedmap"
25
27
"github.com/pkg/errors"
26
28
)
27
29
30
+ var tr = i18n .Tr
31
+
32
+ // RunCTags performs a run of ctags on the given source file. Returns the ctags output and the stderr contents.
28
33
func RunCTags (sourceFile * paths.Path , buildProperties * properties.Map ) ([]byte , []byte , error ) {
29
34
ctagsBuildProperties := properties .NewMap ()
30
35
ctagsBuildProperties .Set ("tools.ctags.path" , "{runtime.tools.ctags.path}" )
@@ -48,13 +53,10 @@ func RunCTags(sourceFile *paths.Path, buildProperties *properties.Map) ([]byte,
48
53
if err != nil {
49
54
return nil , nil , err
50
55
}
51
- stdout := & bytes.Buffer {}
52
- stderr := & bytes.Buffer {}
53
- proc .RedirectStdoutTo (stdout )
54
- proc .RedirectStderrTo (stderr )
55
- if err = proc .Run (); err != nil {
56
- return nil , nil , err
57
- }
58
- _ , _ = stderr .WriteString (strings .Join (parts , " " ))
59
- return stdout .Bytes (), stderr .Bytes (), err
56
+ stdout , stderr , err := proc .RunAndCaptureOutput (context .Background ())
57
+
58
+ // Append ctags arguments to stderr
59
+ args := fmt .Sprintln (strings .Join (parts , " " ))
60
+ stderr = append ([]byte (args ), stderr ... )
61
+ return stdout , stderr , err
60
62
}
0 commit comments