Skip to content

Commit f1b0834

Browse files
Move QueueSourceFilesFromFolder into container_find_includes.go
This function used to be a pass, but it was reduced to a regular function in 1001916 (Remove Context.FoldersWithSourceFiles). By now, the function is only called from container_find_includes.go, so it makes sense to just move it into that file. This does not change any code, it just moves the function and renames it to be private. Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
1 parent de46825 commit f1b0834

File tree

2 files changed

+19
-55
lines changed

2 files changed

+19
-55
lines changed

src/arduino.cc/builder/collect_all_source_files_from_folders_with_sources.go

-52
This file was deleted.

src/arduino.cc/builder/container_find_includes.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func (s *ContainerFindIncludes) Run(ctx *types.Context) error {
5252
ctx.CollectedSourceFiles.Push(filepath.Join(sketchBuildPath, filepath.Base(sketch.MainFile.Name)+".cpp"))
5353

5454
sourceFilePaths := ctx.CollectedSourceFiles
55-
QueueSourceFilesFromFolder(sourceFilePaths, ctx.SketchBuildPath, /* recurse */ false)
55+
queueSourceFilesFromFolder(sourceFilePaths, ctx.SketchBuildPath, /* recurse */ false)
5656
srcSubfolderPath := filepath.Join(ctx.SketchBuildPath, constants.SKETCH_FOLDER_SRC)
5757
if info, err := os.Stat(srcSubfolderPath); err == nil && info.IsDir() {
58-
QueueSourceFilesFromFolder(sourceFilePaths, srcSubfolderPath, /* recurse */ true)
58+
queueSourceFilesFromFolder(sourceFilePaths, srcSubfolderPath, /* recurse */ true)
5959
}
6060

6161
for !sourceFilePaths.Empty() {
@@ -114,7 +114,23 @@ func findIncludesUntilDone(ctx *types.Context, sourceFilePath string) error {
114114
ctx.IncludeFolders = append(ctx.IncludeFolders, library.SrcFolder)
115115
sourceFolders := types.LibraryToSourceFolder(library)
116116
for _, sourceFolder := range sourceFolders {
117-
QueueSourceFilesFromFolder(ctx.CollectedSourceFiles, sourceFolder.Folder, sourceFolder.Recurse)
117+
queueSourceFilesFromFolder(ctx.CollectedSourceFiles, sourceFolder.Folder, sourceFolder.Recurse)
118118
}
119119
}
120120
}
121+
122+
func queueSourceFilesFromFolder(queue *types.UniqueStringQueue, folder string, recurse bool) error {
123+
extensions := func(ext string) bool { return ADDITIONAL_FILE_VALID_EXTENSIONS_NO_HEADERS[ext] }
124+
125+
filePaths := []string{}
126+
err := utils.FindFilesInFolder(&filePaths, folder, extensions, recurse)
127+
if err != nil {
128+
return i18n.WrapError(err)
129+
}
130+
131+
for _, filePath := range filePaths {
132+
queue.Push(filePath)
133+
}
134+
135+
return nil
136+
}

0 commit comments

Comments
 (0)