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
19
"bytes"
20
20
"context"
21
21
"path/filepath"
22
22
"runtime"
23
23
24
- bldr "github.com/arduino/arduino-cli/arduino/builder"
25
- "github.com/arduino/arduino-cli/arduino/builder/preprocessor"
24
+ "github.com/arduino/arduino-cli/arduino/builder"
26
25
"github.com/arduino/arduino-cli/arduino/sketch"
27
26
"github.com/arduino/arduino-cli/executils"
28
27
"github.com/arduino/arduino-cli/legacy/builder/utils"
29
28
"github.com/arduino/go-paths-helper"
30
- properties "github.com/arduino/go-properties-orderedmap"
29
+ "github.com/arduino/go-properties-orderedmap"
31
30
"github.com/pkg/errors"
32
31
)
33
32
33
+ // PreprocessSketchWithArduinoPreprocessor performs preprocessing of the arduino sketch
34
+ // using arduino-preprocessor (https://github.com/arduino/arduino-preprocessor).
34
35
func PreprocessSketchWithArduinoPreprocessor (sk * sketch.Sketch , buildPath * paths.Path , includeFolders paths.PathList , lineOffset int , buildProperties * properties.Map , onlyUpdateCompilationDatabase bool ) ([]byte , []byte , error ) {
35
36
verboseOut := & bytes.Buffer {}
36
37
normalOut := & bytes.Buffer {}
@@ -40,7 +41,7 @@ func PreprocessSketchWithArduinoPreprocessor(sk *sketch.Sketch, buildPath *paths
40
41
41
42
sourceFile := buildPath .Join ("sketch" , sk .MainFile .Base ()+ ".cpp" )
42
43
targetFile := buildPath .Join ("preproc" , "sketch_merged.cpp" )
43
- gccStdout , gccStderr , err := preprocessor . GCC (sourceFile , targetFile , includeFolders , buildProperties )
44
+ gccStdout , gccStderr , err := GCC (sourceFile , targetFile , includeFolders , buildProperties )
44
45
verboseOut .Write (gccStdout )
45
46
verboseOut .Write (gccStderr )
46
47
if err != nil {
@@ -83,6 +84,6 @@ func PreprocessSketchWithArduinoPreprocessor(sk *sketch.Sketch, buildPath *paths
83
84
}
84
85
result := utils .NormalizeUTF8 (commandStdOut )
85
86
86
- err = bldr .SketchSaveItemCpp (sk .MainFile , result , buildPath .Join ("sketch" ))
87
+ err = builder .SketchSaveItemCpp (sk .MainFile , result , buildPath .Join ("sketch" ))
87
88
return normalOut .Bytes (), verboseOut .Bytes (), err
88
89
}
0 commit comments