11// This file is part of arduino-cli.
22//
3- // Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
3+ // Copyright 2023 ARDUINO SA (http://www.arduino.cc/)
44//
55// This software is released under the GNU General Public License version 3,
66// which covers the main part of arduino-cli.
1313// Arduino software without disclosing the source code of your own applications.
1414// To purchase a commercial license, send an email to license@arduino.cc.
1515
16- package builder
16+ package preprocessor
1717
1818import (
1919 "bytes"
2020 "context"
2121 "path/filepath"
2222 "runtime"
2323
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"
2625 "github.com/arduino/arduino-cli/arduino/sketch"
2726 "github.com/arduino/arduino-cli/executils"
2827 "github.com/arduino/arduino-cli/legacy/builder/utils"
2928 "github.com/arduino/go-paths-helper"
30- properties "github.com/arduino/go-properties-orderedmap"
29+ "github.com/arduino/go-properties-orderedmap"
3130 "github.com/pkg/errors"
3231)
3332
33+ // PreprocessSketchWithArduinoPreprocessor performs preprocessing of the arduino sketch
34+ // using arduino-preprocessor (https://github.com/arduino/arduino-preprocessor).
3435func PreprocessSketchWithArduinoPreprocessor (sk * sketch.Sketch , buildPath * paths.Path , includeFolders paths.PathList , lineOffset int , buildProperties * properties.Map , onlyUpdateCompilationDatabase bool ) ([]byte , []byte , error ) {
3536 verboseOut := & bytes.Buffer {}
3637 normalOut := & bytes.Buffer {}
@@ -40,7 +41,7 @@ func PreprocessSketchWithArduinoPreprocessor(sk *sketch.Sketch, buildPath *paths
4041
4142 sourceFile := buildPath .Join ("sketch" , sk .MainFile .Base ()+ ".cpp" )
4243 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 )
4445 verboseOut .Write (gccStdout )
4546 verboseOut .Write (gccStderr )
4647 if err != nil {
@@ -83,6 +84,6 @@ func PreprocessSketchWithArduinoPreprocessor(sk *sketch.Sketch, buildPath *paths
8384 }
8485 result := utils .NormalizeUTF8 (commandStdOut )
8586
86- err = bldr .SketchSaveItemCpp (sk .MainFile , result , buildPath .Join ("sketch" ))
87+ err = builder .SketchSaveItemCpp (sk .MainFile , result , buildPath .Join ("sketch" ))
8788 return normalOut .Bytes (), verboseOut .Bytes (), err
8889}
0 commit comments