@@ -33,13 +33,15 @@ import (
33
33
"arduino.cc/builder/constants"
34
34
"arduino.cc/builder/types"
35
35
"arduino.cc/builder/utils"
36
+ "fmt"
36
37
"strconv"
37
38
"strings"
38
39
)
39
40
40
41
type PrototypesAdder struct {}
41
42
42
43
func (s * PrototypesAdder ) Run (context map [string ]interface {}) error {
44
+ debugOutput := context [constants .CTX_DEBUG_PREPROCESSOR ] != nil
43
45
source := context [constants .CTX_SOURCE ].(string )
44
46
sourceRows := strings .Split (source , "\n " )
45
47
@@ -58,6 +60,21 @@ func (s *PrototypesAdder) Run(context map[string]interface{}) error {
58
60
context [constants .CTX_PROTOTYPE_SECTION ] = prototypeSection
59
61
source = source [:firstFunctionChar ] + prototypeSection + source [firstFunctionChar :]
60
62
63
+ if debugOutput {
64
+ fmt .Println ("#PREPROCESSED SOURCE" )
65
+ prototypesRows := strings .Split (prototypeSection , "\n " )
66
+ prototypesRows = prototypesRows [:len (prototypesRows )- 1 ]
67
+ for i := 0 ; i < len (sourceRows )+ len (prototypesRows ); i ++ {
68
+ if i < insertionLine {
69
+ fmt .Printf (" |%s\n " , sourceRows [i ])
70
+ } else if i < insertionLine + len (prototypesRows ) {
71
+ fmt .Printf ("PRO|%s\n " , prototypesRows [i - insertionLine ])
72
+ } else {
73
+ fmt .Printf (" |%s\n " , sourceRows [i - len (prototypesRows )])
74
+ }
75
+ }
76
+ fmt .Println ("#END OF PREPROCESSED SOURCE" )
77
+ }
61
78
context [constants .CTX_SOURCE ] = source
62
79
63
80
return nil
0 commit comments