Skip to content

Commit c41bc91

Browse files
committed
[CMAKE] export only preprocessed source
1 parent 915bc10 commit c41bc91

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Diff for: src/arduino.cc/builder/create_cmake_rule.go

+13
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
106106
if err != nil {
107107
fmt.Println(err)
108108
}
109+
110+
// Use old ctags method to generate export file
111+
commands := []types.Command{
112+
&ContainerMergeCopySketchFiles{},
113+
&ContainerAddPrototypes{},
114+
&FilterSketchSource{Source: &ctx.Source, RemoveLineMarkers: true},
115+
&SketchSaver{},
116+
}
117+
118+
for _, command := range commands {
119+
command.Run(ctx)
120+
}
121+
109122
err = utils.CopyDir(ctx.SketchBuildPath, filepath.Join(cmakeFolder, "sketch"), extensions)
110123
if err != nil {
111124
fmt.Println(err)

Diff for: src/arduino.cc/builder/filter_sketch_source.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import (
3939
)
4040

4141
type FilterSketchSource struct {
42-
Source *string
42+
Source *string
43+
RemoveLineMarkers bool
4344
}
4445

4546
func (s *FilterSketchSource) Run(ctx *types.Context) error {
@@ -57,6 +58,9 @@ func (s *FilterSketchSource) Run(ctx *types.Context) error {
5758
filename := parseLineMarker(line)
5859
if filename != "" {
5960
inSketch = utils.SliceContains(fileNames, filename)
61+
if inSketch && s.RemoveLineMarkers {
62+
continue
63+
}
6064
}
6165

6266
if inSketch {
@@ -79,7 +83,7 @@ func parseLineMarker(line string) string {
7983
// https://github.com/gcc-mirror/gcc/blob/edd716b6b1caa1a5cb320a8cd7f626f30198e098/gcc/c-family/c-ppoutput.c#L413-L415
8084

8185
split := strings.SplitN(line, " ", 3)
82-
if len(split) < 3 || split[0] != "#" {
86+
if len(split) < 3 || len(split[0]) == 0 || split[0][0] != '#' {
8387
return ""
8488
}
8589

0 commit comments

Comments
 (0)