@@ -17,8 +17,10 @@ package builder
17
17
18
18
import (
19
19
"fmt"
20
+ "io/ioutil"
20
21
"os"
21
22
"path/filepath"
23
+ "regexp"
22
24
"strings"
23
25
24
26
properties "github.com/arduino/go-properties-orderedmap"
@@ -115,7 +117,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
115
117
commands := []types.Command {
116
118
//&ContainerMergeCopySketchFiles{},
117
119
& ContainerAddPrototypes {},
118
- // &FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
120
+ & FilterSketchSource {Source : & ctx .Source , RemoveLineMarkers : true },
119
121
}
120
122
121
123
for _ , command := range commands {
@@ -127,6 +129,31 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
127
129
fmt .Println (err )
128
130
}
129
131
132
+ // remove "#line 1 ..." from exported c_make folder sketch
133
+ var sketchFiles []string
134
+ utils .FindFilesInFolder (& sketchFiles , cmakeFolder .Join ("sketch" ).String (), extensions , false )
135
+
136
+ for _ , file := range sketchFiles {
137
+ input , err := ioutil .ReadFile (file )
138
+ if err != nil {
139
+ fmt .Println (err )
140
+ continue
141
+ }
142
+
143
+ lines := strings .Split (string (input ), "\n " )
144
+
145
+ for i , line := range lines {
146
+ if lineToRemove , _ := regexp .MatchString (`^#line\s\d+\s"` , line ); lineToRemove == true {
147
+ lines [i ] = ""
148
+ }
149
+ }
150
+ output := strings .Join (lines , "\n " )
151
+ err = ioutil .WriteFile (file , []byte (output ), 0644 )
152
+ if err != nil {
153
+ fmt .Println (err )
154
+ }
155
+ }
156
+
130
157
// Extract CFLAGS, CPPFLAGS and LDFLAGS
131
158
var defines []string
132
159
var linkerflags []string
0 commit comments