@@ -143,23 +143,24 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
143143 appendIncludeFolder (ctx , cache , nil , "" , ctx .BuildProperties .GetPath ("build.variant.path" ))
144144 }
145145
146+ sourceFileQueue := & types.UniqueSourceFileQueue {}
147+
146148 if ! ctx .UseCachedLibrariesResolution {
147149 sketch := ctx .Sketch
148150 mergedfile , err := types .MakeSourceFile (ctx , sketch , paths .New (sketch .MainFile .Base ()+ ".cpp" ))
149151 if err != nil {
150152 return errors .WithStack (err )
151153 }
152- ctx . CollectedSourceFiles .Push (mergedfile )
154+ sourceFileQueue .Push (mergedfile )
153155
154- sourceFilePaths := ctx .CollectedSourceFiles
155- queueSourceFilesFromFolder (ctx , sourceFilePaths , sketch , ctx .SketchBuildPath , false /* recurse */ )
156+ queueSourceFilesFromFolder (ctx , sourceFileQueue , sketch , ctx .SketchBuildPath , false /* recurse */ )
156157 srcSubfolderPath := ctx .SketchBuildPath .Join ("src" )
157158 if srcSubfolderPath .IsDir () {
158- queueSourceFilesFromFolder (ctx , sourceFilePaths , sketch , srcSubfolderPath , true /* recurse */ )
159+ queueSourceFilesFromFolder (ctx , sourceFileQueue , sketch , srcSubfolderPath , true /* recurse */ )
159160 }
160161
161- for ! sourceFilePaths .Empty () {
162- err := findIncludesUntilDone (ctx , cache , sourceFilePaths . Pop () )
162+ for ! sourceFileQueue .Empty () {
163+ err := findIncludesUntilDone (ctx , cache , sourceFileQueue )
163164 if err != nil {
164165 cachePath .Remove ()
165166 return errors .WithStack (err )
@@ -314,7 +315,8 @@ func writeCache(cache *includeCache, path *paths.Path) error {
314315 return nil
315316}
316317
317- func findIncludesUntilDone (ctx * types.Context , cache * includeCache , sourceFile types.SourceFile ) error {
318+ func findIncludesUntilDone (ctx * types.Context , cache * includeCache , sourceFileQueue * types.UniqueSourceFileQueue ) error {
319+ sourceFile := sourceFileQueue .Pop ()
318320 sourcePath := sourceFile .SourcePath (ctx )
319321 targetFilePath := paths .NullPath ()
320322 depPath := sourceFile .DepfilePath (ctx )
@@ -367,7 +369,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
367369 ctx .Info (tr ("Using cached library dependencies for file: %[1]s" , sourcePath ))
368370 }
369371 } else {
370- preproc_stderr , preproc_err = GCCPreprocRunnerForDiscoveringIncludes (ctx , sourcePath , targetFilePath , includes )
372+ preproc_stderr , preproc_err = GCCPreprocRunner (ctx , sourcePath , targetFilePath , includes )
371373 // Unwrap error and see if it is an ExitError.
372374 _ , is_exit_error := errors .Cause (preproc_err ).(* exec.ExitError )
373375 if preproc_err == nil {
@@ -399,7 +401,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
399401 // return errors.WithStack(err)
400402 if preproc_err == nil || preproc_stderr == nil {
401403 // Filename came from cache, so run preprocessor to obtain error to show
402- preproc_stderr , preproc_err = GCCPreprocRunnerForDiscoveringIncludes (ctx , sourcePath , targetFilePath , includes )
404+ preproc_stderr , preproc_err = GCCPreprocRunner (ctx , sourcePath , targetFilePath , includes )
403405 if preproc_err == nil {
404406 // If there is a missing #include in the cache, but running
405407 // gcc does not reproduce that, there is something wrong.
@@ -419,13 +421,13 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
419421 appendIncludeFolder (ctx , cache , sourcePath , include , library .SourceDir )
420422 sourceDirs := library .SourceDirs ()
421423 for _ , sourceDir := range sourceDirs {
422- queueSourceFilesFromFolder (ctx , ctx . CollectedSourceFiles , library , sourceDir .Dir , sourceDir .Recurse )
424+ queueSourceFilesFromFolder (ctx , sourceFileQueue , library , sourceDir .Dir , sourceDir .Recurse )
423425 }
424426 first = false
425427 }
426428}
427429
428- func queueSourceFilesFromFolder (ctx * types.Context , queue * types.UniqueSourceFileQueue , origin interface {}, folder * paths.Path , recurse bool ) error {
430+ func queueSourceFilesFromFolder (ctx * types.Context , sourceFileQueue * types.UniqueSourceFileQueue , origin interface {}, folder * paths.Path , recurse bool ) error {
429431 sourceFileExtensions := []string {}
430432 for k := range globals .SourceFilesValidExtensions {
431433 sourceFileExtensions = append (sourceFileExtensions , k )
@@ -440,7 +442,7 @@ func queueSourceFilesFromFolder(ctx *types.Context, queue *types.UniqueSourceFil
440442 if err != nil {
441443 return errors .WithStack (err )
442444 }
443- queue .Push (sourceFile )
445+ sourceFileQueue .Push (sourceFile )
444446 }
445447
446448 return nil
0 commit comments