Skip to content

Commit 293c2d5

Browse files
authored
add #line directive to additional source files
improvement for arduino#323
1 parent d9d12ab commit 293c2d5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

additional_sketch_files_copier.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ func (s *AdditionalSketchFilesCopier) Run(ctx *types.Context) error {
6363
return i18n.WrapError(err)
6464
}
6565

66-
bytes, err := ioutil.ReadFile(file.Name)
66+
originalFileContent, err := ioutil.ReadFile(file.Name)
6767
if err != nil {
6868
return i18n.WrapError(err)
6969
}
7070

71-
if targetFileChanged(bytes, targetFilePath) {
72-
err := utils.WriteFileBytes(targetFilePath, bytes)
71+
line := []byte("#line 1 " + utils.QuoteCppString(file.Name) + "\n")
72+
changedFileContent := bytes.Join([][]byte{line,originalFileContent},[]byte{})
73+
if targetFileChanged(changedFileContent, targetFilePath) {
74+
err := utils.WriteFileBytes(targetFilePath, changedFileContent)
7375
if err != nil {
7476
return i18n.WrapError(err)
7577
}

0 commit comments

Comments
 (0)