Skip to content

Include detection refactor #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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>
  • Loading branch information
matthijskooijman committed Aug 2, 2016
commit f1b08347daf33c5031a09e4cc437569731870bcc

This file was deleted.

22 changes: 19 additions & 3 deletions src/arduino.cc/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func (s *ContainerFindIncludes) Run(ctx *types.Context) error {
ctx.CollectedSourceFiles.Push(filepath.Join(sketchBuildPath, filepath.Base(sketch.MainFile.Name)+".cpp"))

sourceFilePaths := ctx.CollectedSourceFiles
QueueSourceFilesFromFolder(sourceFilePaths, ctx.SketchBuildPath, /* recurse */ false)
queueSourceFilesFromFolder(sourceFilePaths, ctx.SketchBuildPath, /* recurse */ false)
srcSubfolderPath := filepath.Join(ctx.SketchBuildPath, constants.SKETCH_FOLDER_SRC)
if info, err := os.Stat(srcSubfolderPath); err == nil && info.IsDir() {
QueueSourceFilesFromFolder(sourceFilePaths, srcSubfolderPath, /* recurse */ true)
queueSourceFilesFromFolder(sourceFilePaths, srcSubfolderPath, /* recurse */ true)
}

for !sourceFilePaths.Empty() {
Expand Down Expand Up @@ -114,7 +114,23 @@ func findIncludesUntilDone(ctx *types.Context, sourceFilePath string) error {
ctx.IncludeFolders = append(ctx.IncludeFolders, library.SrcFolder)
sourceFolders := types.LibraryToSourceFolder(library)
for _, sourceFolder := range sourceFolders {
QueueSourceFilesFromFolder(ctx.CollectedSourceFiles, sourceFolder.Folder, sourceFolder.Recurse)
queueSourceFilesFromFolder(ctx.CollectedSourceFiles, sourceFolder.Folder, sourceFolder.Recurse)
}
}
}

func queueSourceFilesFromFolder(queue *types.UniqueStringQueue, folder string, recurse bool) error {
extensions := func(ext string) bool { return ADDITIONAL_FILE_VALID_EXTENSIONS_NO_HEADERS[ext] }

filePaths := []string{}
err := utils.FindFilesInFolder(&filePaths, folder, extensions, recurse)
if err != nil {
return i18n.WrapError(err)
}

for _, filePath := range filePaths {
queue.Push(filePath)
}

return nil
}