Unverified Commit bc8e0731 authored by Umberto Baldi's avatar Umberto Baldi Committed by GitHub

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 4ed71831
...@@ -17,8 +17,10 @@ package builder ...@@ -17,8 +17,10 @@ package builder
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"regexp"
"strings" "strings"
properties "github.com/arduino/go-properties-orderedmap" properties "github.com/arduino/go-properties-orderedmap"
...@@ -115,7 +117,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error { ...@@ -115,7 +117,7 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
commands := []types.Command{ commands := []types.Command{
//&ContainerMergeCopySketchFiles{}, //&ContainerMergeCopySketchFiles{},
&ContainerAddPrototypes{}, &ContainerAddPrototypes{},
//&FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true}, &FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
} }
for _, command := range commands { for _, command := range commands {
...@@ -127,6 +129,31 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error { ...@@ -127,6 +129,31 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
fmt.Println(err) 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 // Extract CFLAGS, CPPFLAGS and LDFLAGS
var defines []string var defines []string
var linkerflags []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