Commit 64c501da authored by Umberto Baldi's avatar Umberto Baldi Committed by rsora

Fix filter sketch source for "Export cmake" output (#514)

* fix filter sketch source

* removed lines generated from preprocessor

* remove file added by mistake

* remove lines generated by preprocessor in c_make file

* introduce again ContainerAddPrototypes
parent f04fe92c
......@@ -17,8 +17,10 @@ package builder
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
properties "github.com/arduino/go-properties-orderedmap"
......@@ -115,7 +117,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
commands := []types.Command{
//&ContainerMergeCopySketchFiles{},
&ContainerAddPrototypes{},
//&FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
&FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
}
for _, command := range commands {
......@@ -127,6 +129,31 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
fmt.Println(err)
}
// remove "#line 1 ..." from exported c_make folder sketch
var sketchFiles []string
utils.FindFilesInFolder(&sketchFiles, cmakeFolder.Join("sketch").String(), extensions, false)
for _, file := range sketchFiles {
input, err := ioutil.ReadFile(file)
if err != nil {
fmt.Println(err)
continue
}
lines := strings.Split(string(input), "\n")
for i, line := range lines {
if lineToRemove, _ := regexp.MatchString(`^#line\s\d+\s"`, line); lineToRemove == true {
lines[i] = ""
}
}
output := strings.Join(lines, "\n")
err = ioutil.WriteFile(file, []byte(output), 0644)
if err != nil {
fmt.Println(err)
}
}
// Extract CFLAGS, CPPFLAGS and LDFLAGS
var defines []string
var linkerflags []string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment