Skip to content

Commit 89f7ece

Browse files
author
Federico Fissore
committed
prototypes line directives now contain original sketch file name. Useful when
sketckes are made of multiple .ino files Signed-off-by: Federico Fissore <[email protected]>
1 parent 044817d commit 89f7ece

20 files changed

+203
-152
lines changed

src/arduino.cc/builder/compare_prototypes_from_source_and_preproc_source.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ package builder
3131

3232
import (
3333
"arduino.cc/builder/constants"
34-
"arduino.cc/builder/utils"
3534
)
3635

3736
type ComparePrototypesFromSourceAndPreprocSource struct{}
@@ -42,7 +41,7 @@ func (s *ComparePrototypesFromSourceAndPreprocSource) Run(context map[string]int
4241

4342
actualCTags := []map[string]string{}
4443
for _, ctagOfPreprocSource := range ctagsOfPreprocSource {
45-
if utils.SliceContainsCTag(ctagsOfSource, ctagOfPreprocSource) {
44+
if sliceContainsCTag(ctagsOfSource, ctagOfPreprocSource) {
4645
actualCTags = append(actualCTags, ctagOfPreprocSource)
4746
}
4847
}
@@ -51,3 +50,12 @@ func (s *ComparePrototypesFromSourceAndPreprocSource) Run(context map[string]int
5150

5251
return nil
5352
}
53+
54+
func sliceContainsCTag(slice []map[string]string, target map[string]string) bool {
55+
for _, value := range slice {
56+
if value[FIELD_FUNCTION_NAME] == target[FIELD_FUNCTION_NAME] {
57+
return true
58+
}
59+
}
60+
return false
61+
}

src/arduino.cc/builder/constants/constants.go

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const BUILD_PROPERTIES_TOOLS_KEY = "tools"
7373
const BUILD_PROPERTIES_VID = "vid"
7474
const COAN = "coan"
7575
const CTAGS = "ctags"
76-
const CTAGS_FIELD_FUNCTION_NAME = "functionName"
7776
const CTX_ACTUAL_PLATFORM = "actualPlatform"
7877
const CTX_ARCHIVE_FILE_PATH_CORE = "archiveFileCore"
7978
const CTX_BUILD_CORE = "buildCore"

src/arduino.cc/builder/ctags_parser.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ const FIELD_CODE = "code"
4343
const FIELD_CLASS = "class"
4444
const FIELD_STRUCT = "struct"
4545
const FIELD_NAMESPACE = "namespace"
46+
const FIELD_FILENAME = "filename"
4647
const FIELD_SKIP = "skipMe"
48+
const FIELD_FUNCTION_NAME = "functionName"
4749

4850
const KIND_PROTOTYPE = "prototype"
4951
const KIND_FUNCTION = "function"
@@ -104,7 +106,7 @@ func addPrototype(tag map[string]string) {
104106
return
105107
}
106108

107-
tag[KIND_PROTOTYPE] = tag[FIELD_RETURNTYPE] + " " + tag[constants.CTAGS_FIELD_FUNCTION_NAME] + tag[FIELD_SIGNATURE] + ";"
109+
tag[KIND_PROTOTYPE] = tag[FIELD_RETURNTYPE] + " " + tag[FIELD_FUNCTION_NAME] + tag[FIELD_SIGNATURE] + ";"
108110

109111
tag[KIND_PROTOTYPE_MODIFIERS] = ""
110112
if strings.Index(tag[FIELD_CODE], STATIC+" ") != -1 {
@@ -205,8 +207,10 @@ func parseTag(row string) map[string]string {
205207
tag := make(map[string]string)
206208
parts := strings.Split(row, "\t")
207209

208-
tag[constants.CTAGS_FIELD_FUNCTION_NAME] = parts[0]
209-
parts = parts[1:]
210+
tag[FIELD_FUNCTION_NAME] = parts[0]
211+
tag[FIELD_FILENAME] = parts[1]
212+
213+
parts = parts[2:]
210214

211215
for _, part := range parts {
212216
if strings.Contains(part, ":") {

src/arduino.cc/builder/ctags_to_prototypes.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func collectFunctionNames(tags []map[string]string) []string {
101101
names := []string{}
102102
for _, tag := range tags {
103103
if tag[FIELD_KIND] == KIND_FUNCTION {
104-
names = append(names, tag[constants.CTAGS_FIELD_FUNCTION_NAME])
104+
names = append(names, tag[FIELD_FUNCTION_NAME])
105105
}
106106
}
107107
return names
@@ -120,8 +120,8 @@ func toPrototypes(tags []map[string]string) []*types.Prototype {
120120
prototypes := []*types.Prototype{}
121121
for _, tag := range tags {
122122
if tag[FIELD_SKIP] != TRUE {
123-
ctag := types.Prototype{FunctionName: tag[constants.CTAGS_FIELD_FUNCTION_NAME], Prototype: tag[KIND_PROTOTYPE], Modifiers: tag[KIND_PROTOTYPE_MODIFIERS], Line: tag[FIELD_LINE], Fields: tag}
124-
prototypes = append(prototypes, &ctag)
123+
prototype := &types.Prototype{FunctionName: tag[FIELD_FUNCTION_NAME], File: tag[FIELD_FILENAME], Prototype: tag[KIND_PROTOTYPE], Modifiers: tag[KIND_PROTOTYPE_MODIFIERS], Line: tag[FIELD_LINE], Fields: tag}
124+
prototypes = append(prototypes, prototype)
125125
}
126126
}
127127
return prototypes

src/arduino.cc/builder/prototypes_adder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func composePrototypeSection(line int, prototypes []*types.Prototype) string {
7878
func joinPrototypes(prototypes []*types.Prototype) string {
7979
prototypesSlice := []string{}
8080
for _, proto := range prototypes {
81-
prototypesSlice = append(prototypesSlice, "#line "+proto.Line)
81+
prototypesSlice = append(prototypesSlice, "#line "+proto.Line+" \""+proto.File+"\"")
8282
prototypeParts := []string{}
8383
if proto.Modifiers != "" {
8484
prototypeParts = append(prototypeParts, proto.Modifiers)

0 commit comments

Comments
 (0)