Skip to content

Commit 64c501d

Browse files
umbynosrsora
authored andcommitted
Fix filter sketch source for "Export cmake" output (arduino#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
1 parent f04fe92 commit 64c501d

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

legacy/builder/create_cmake_rule.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ package builder
1717

1818
import (
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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy