Skip to content

Commit

Permalink
GCC doesn't like paths with \, because \ is a special char. Escaping.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Fissore <[email protected]>
  • Loading branch information
Federico Fissore committed Sep 25, 2015
1 parent 03ab957 commit 24ac2c1
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/arduino.cc/builder/sketch_source_merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ package builder
import (
"arduino.cc/builder/constants"
"arduino.cc/builder/types"
"strings"
)

type SketchSourceMerger struct{}
Expand All @@ -51,7 +52,7 @@ func (s *SketchSourceMerger) Run(context map[string]interface{}) error {
}

func addPreprocLine(sketch *types.SketchFile) string {
source := "#line 1 \"" + sketch.Name + "\"\n"
source := "#line 1 \"" + strings.Replace(sketch.Name, "\\", "\\\\", -1) + "\"\n"
source += sketch.Source
source += "\n"

Expand Down
9 changes: 8 additions & 1 deletion src/arduino.cc/builder/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"path/filepath"
"strings"
"testing"
"text/template"
)

func LoadAndInterpolate(t *testing.T, filename string, context map[string]interface{}) string {
tpl, err := template.ParseFiles(filename)
funcsMap := template.FuncMap{
"EscapeBackSlashes": func(s string) string {
return strings.Replace(s, "\\", "\\\\", -1)
},
}

tpl, err := template.New(filepath.Base(filename)).Funcs(funcsMap).ParseFiles(filename)
NoError(t, err)

var buf bytes.Buffer
Expand Down
6 changes: 3 additions & 3 deletions src/arduino.cc/builder/test/sketch1/merged_sketch.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
void setup() {

}

void loop() {

}
#line 1 "{{(index .sketch.OtherSketchFiles 0).Name}}"
#line 1 "{{EscapeBackSlashes (index .sketch.OtherSketchFiles 0).Name}}"

#line 1 "{{(index .sketch.OtherSketchFiles 1).Name}}"
#line 1 "{{EscapeBackSlashes (index .sketch.OtherSketchFiles 1).Name}}"
String hello() {
return "world";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
#define DEBUG 1
#define DISABLED 0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
#define DEBUG 1
#define DISABLED 0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
/*
* The code is released under the GNU General Public License.
* Developed by Kristian Lauszus, TKJ Electronics 2013
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
#include <SoftwareSerial.h> // required to send and receive AT commands from the GPRS Shield
#include <Wire.h> // required for I2C communication with the RTC

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
#include <CapacitiveSensor.h>
/*
#include <WiFi.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
const char *foo = "\
hello \
world\n";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
void setup();
void loop();
#line 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
/* START CODE */

struct A_NEW_TYPE {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Arduino.h>
#line 1
#line 1 "{{.sketch.MainFile.Name}}"
#line 1 "{{EscapeBackSlashes .sketch.MainFile.Name}}"
#include "config.h"

#ifdef DEBUG
Expand Down

0 comments on commit 24ac2c1

Please sign in to comment.