@@ -284,6 +284,19 @@ func (l *SketchLibrariesDetector) findIncludes(
284
284
return nil
285
285
}
286
286
287
+ func (l * SketchLibrariesDetector ) gccPreprocessTask (sourceFile * sourceFile , buildProperties * properties.Map ) * runner.Task {
288
+ // Libraries may require the "utility" directory to be added to the include
289
+ // search path, but only for the source code of the library, so we temporary
290
+ // copy the current search path list and add the library' utility directory
291
+ // if needed.
292
+ includeFolders := l .includeFolders
293
+ if extraInclude := sourceFile .ExtraIncludePath ; extraInclude != nil {
294
+ includeFolders = append (includeFolders , extraInclude )
295
+ }
296
+
297
+ return preprocessor .GCC (sourceFile .SourcePath , paths .NullPath (), includeFolders , buildProperties )
298
+ }
299
+
287
300
func (l * SketchLibrariesDetector ) findMissingIncludesInCompilationUnit (
288
301
ctx context.Context ,
289
302
sourceFileQueue * uniqueSourceFileQueue ,
@@ -315,15 +328,7 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
315
328
for {
316
329
l .cache .Expect (& detectorCacheEntry {Compile : sourceFile })
317
330
318
- // Libraries may require the "utility" directory to be added to the include
319
- // search path, but only for the source code of the library, so we temporary
320
- // copy the current search path list and add the library' utility directory
321
- // if needed.
322
- includeFolders := l .includeFolders
323
- if extraInclude := sourceFile .ExtraIncludePath ; extraInclude != nil {
324
- includeFolders = append (includeFolders , extraInclude )
325
- }
326
-
331
+ preprocTask := l .gccPreprocessTask (sourceFile , buildProperties )
327
332
var preprocErr error
328
333
var preprocResult * runner.Result
329
334
@@ -335,7 +340,8 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
335
340
}
336
341
first = false
337
342
} else {
338
- preprocResult , preprocErr = preprocessor .GCC (ctx , sourcePath , paths .NullPath (), includeFolders , buildProperties )
343
+ preprocResult = preprocTask .Run (ctx )
344
+ preprocErr = preprocResult .Error
339
345
if l .logger .Verbose () {
340
346
l .logger .WriteStdout (preprocResult .Stdout )
341
347
}
@@ -368,7 +374,8 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
368
374
369
375
// If preprocess result came from cache, run the preprocessor to obtain the actual error to show
370
376
if preprocErr == nil || len (preprocResult .Stderr ) == 0 {
371
- preprocResult , preprocErr = preprocessor .GCC (ctx , sourcePath , paths .NullPath (), includeFolders , buildProperties )
377
+ preprocResult = preprocTask .Run (ctx )
378
+ preprocErr = preprocResult .Error
372
379
if l .logger .Verbose () {
373
380
l .logger .WriteStdout (preprocResult .Stdout )
374
381
}
0 commit comments