@@ -17,8 +17,10 @@ package builder
1717
1818import (
1919 "fmt"
20+ "io/ioutil"
2021 "os"
2122 "path/filepath"
23+ "regexp"
2224 "strings"
2325
2426 properties "github.com/arduino/go-properties-orderedmap"
@@ -115,7 +117,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
115117 commands := []types.Command {
116118 //&ContainerMergeCopySketchFiles{},
117119 & ContainerAddPrototypes {},
118- // &FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
120+ & FilterSketchSource {Source : & ctx .Source , RemoveLineMarkers : true },
119121 }
120122
121123 for _ , command := range commands {
@@ -127,6 +129,31 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
127129 fmt .Println (err )
128130 }
129131
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+
130157 // Extract CFLAGS, CPPFLAGS and LDFLAGS
131158 var defines []string
132159 var linkerflags []string
0 commit comments