(sourceDir, includePath string)
| 277 | } |
| 278 | |
| 279 | func includeBasePathCandidates(sourceDir, includePath string) []string { |
| 280 | candidates := make(map[string]bool) |
| 281 | add := func(p string) { |
| 282 | candidates[filepath.Clean(p)] = true |
| 283 | } |
| 284 | |
| 285 | // Always try source-relative first. |
| 286 | add(filepath.Join(sourceDir, includePath)) |
| 287 | |
| 288 | // Also try ancestor roots and common include roots. |
| 289 | for dir := sourceDir; ; dir = filepath.Dir(dir) { |
| 290 | add(filepath.Join(dir, includePath)) |
| 291 | add(filepath.Join(dir, "include", includePath)) |
| 292 | |
| 293 | parent := filepath.Dir(dir) |
| 294 | if parent == dir { |
| 295 | break |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | out := make([]string, 0, len(candidates)) |
| 300 | for p := range candidates { |
| 301 | out = append(out, p) |
| 302 | } |
| 303 | sort.Strings(out) |
| 304 | return out |
| 305 | } |
no test coverage detected