@@ -143,23 +143,24 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
143
143
appendIncludeFolder (ctx , cache , nil , "" , ctx .BuildProperties .GetPath ("build.variant.path" ))
144
144
}
145
145
146
+ sourceFileQueue := & types.UniqueSourceFileQueue {}
147
+
146
148
if ! ctx .UseCachedLibrariesResolution {
147
149
sketch := ctx .Sketch
148
150
mergedfile , err := types .MakeSourceFile (ctx , sketch , paths .New (sketch .MainFile .Base ()+ ".cpp" ))
149
151
if err != nil {
150
152
return errors .WithStack (err )
151
153
}
152
- ctx . CollectedSourceFiles .Push (mergedfile )
154
+ sourceFileQueue .Push (mergedfile )
153
155
154
- sourceFilePaths := ctx .CollectedSourceFiles
155
- queueSourceFilesFromFolder (ctx , sourceFilePaths , sketch , ctx .SketchBuildPath , false /* recurse */ )
156
+ queueSourceFilesFromFolder (ctx , sourceFileQueue , sketch , ctx .SketchBuildPath , false /* recurse */ )
156
157
srcSubfolderPath := ctx .SketchBuildPath .Join ("src" )
157
158
if srcSubfolderPath .IsDir () {
158
- queueSourceFilesFromFolder (ctx , sourceFilePaths , sketch , srcSubfolderPath , true /* recurse */ )
159
+ queueSourceFilesFromFolder (ctx , sourceFileQueue , sketch , srcSubfolderPath , true /* recurse */ )
159
160
}
160
161
161
- for ! sourceFilePaths .Empty () {
162
- err := findIncludesUntilDone (ctx , cache , sourceFilePaths . Pop () )
162
+ for ! sourceFileQueue .Empty () {
163
+ err := findIncludesUntilDone (ctx , cache , sourceFileQueue )
163
164
if err != nil {
164
165
cachePath .Remove ()
165
166
return errors .WithStack (err )
@@ -314,7 +315,8 @@ func writeCache(cache *includeCache, path *paths.Path) error {
314
315
return nil
315
316
}
316
317
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 ()
318
320
sourcePath := sourceFile .SourcePath (ctx )
319
321
targetFilePath := paths .NullPath ()
320
322
depPath := sourceFile .DepfilePath (ctx )
@@ -367,7 +369,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
367
369
ctx .Info (tr ("Using cached library dependencies for file: %[1]s" , sourcePath ))
368
370
}
369
371
} else {
370
- preproc_stderr , preproc_err = GCCPreprocRunnerForDiscoveringIncludes (ctx , sourcePath , targetFilePath , includes )
372
+ preproc_stderr , preproc_err = GCCPreprocRunner (ctx , sourcePath , targetFilePath , includes )
371
373
// Unwrap error and see if it is an ExitError.
372
374
_ , is_exit_error := errors .Cause (preproc_err ).(* exec.ExitError )
373
375
if preproc_err == nil {
@@ -399,7 +401,7 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
399
401
// return errors.WithStack(err)
400
402
if preproc_err == nil || preproc_stderr == nil {
401
403
// 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 )
403
405
if preproc_err == nil {
404
406
// If there is a missing #include in the cache, but running
405
407
// gcc does not reproduce that, there is something wrong.
@@ -419,13 +421,13 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
419
421
appendIncludeFolder (ctx , cache , sourcePath , include , library .SourceDir )
420
422
sourceDirs := library .SourceDirs ()
421
423
for _ , sourceDir := range sourceDirs {
422
- queueSourceFilesFromFolder (ctx , ctx . CollectedSourceFiles , library , sourceDir .Dir , sourceDir .Recurse )
424
+ queueSourceFilesFromFolder (ctx , sourceFileQueue , library , sourceDir .Dir , sourceDir .Recurse )
423
425
}
424
426
first = false
425
427
}
426
428
}
427
429
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 {
429
431
sourceFileExtensions := []string {}
430
432
for k := range globals .SourceFilesValidExtensions {
431
433
sourceFileExtensions = append (sourceFileExtensions , k )
@@ -440,7 +442,7 @@ func queueSourceFilesFromFolder(ctx *types.Context, queue *types.UniqueSourceFil
440
442
if err != nil {
441
443
return errors .WithStack (err )
442
444
}
443
- queue .Push (sourceFile )
445
+ sourceFileQueue .Push (sourceFile )
444
446
}
445
447
446
448
return nil
0 commit comments