@@ -264,16 +264,16 @@ func (l *SketchLibrariesDetector) findIncludes(
264
264
265
265
if ! l .useCachedLibrariesResolution {
266
266
sketch := sketch
267
- mergedfile , err := makeSourceFile (sketchBuildPath , librariesBuildPath , sketch , paths .New (sketch .MainFile .Base ()+ ".cpp" ))
267
+ mergedfile , err := makeSourceFile (sketchBuildPath , sketchBuildPath , paths .New (sketch .MainFile .Base ()+ ".cpp" ))
268
268
if err != nil {
269
269
return errors .WithStack (err )
270
270
}
271
271
sourceFileQueue .push (mergedfile )
272
272
273
- l .queueSourceFilesFromFolder (sketchBuildPath , librariesBuildPath , sourceFileQueue , sketch , sketchBuildPath , false /* recurse */ )
273
+ l .queueSourceFilesFromFolder (sourceFileQueue , sketchBuildPath , false /* recurse */ , sketchBuildPath , sketchBuildPath )
274
274
srcSubfolderPath := sketchBuildPath .Join ("src" )
275
275
if srcSubfolderPath .IsDir () {
276
- l .queueSourceFilesFromFolder (sketchBuildPath , librariesBuildPath , sourceFileQueue , sketch , srcSubfolderPath , true /* recurse */ )
276
+ l .queueSourceFilesFromFolder (sourceFileQueue , srcSubfolderPath , true /* recurse */ , sketchBuildPath , sketchBuildPath )
277
277
}
278
278
279
279
for ! sourceFileQueue .empty () {
@@ -419,20 +419,21 @@ func (l *SketchLibrariesDetector) findIncludesUntilDone(
419
419
}
420
420
} else {
421
421
for _ , sourceDir := range library .SourceDirs () {
422
- l .queueSourceFilesFromFolder (sketchBuildPath , librariesBuildPath , sourceFileQueue , library , sourceDir .Dir , sourceDir .Recurse )
422
+ l .queueSourceFilesFromFolder (sourceFileQueue , sourceDir .Dir , sourceDir .Recurse ,
423
+ library .SourceDir , librariesBuildPath .Join (library .DirName ), library .UtilityDir )
423
424
}
424
425
}
425
426
first = false
426
427
}
427
428
}
428
429
429
430
func (l * SketchLibrariesDetector ) queueSourceFilesFromFolder (
430
- sketchBuildPath * paths.Path ,
431
- librariesBuildPath * paths.Path ,
432
431
sourceFileQueue * uniqueSourceFileQueue ,
433
- origin interface {},
434
432
folder * paths.Path ,
435
433
recurse bool ,
434
+ sourceDir * paths.Path ,
435
+ buildDir * paths.Path ,
436
+ extraIncludePath ... * paths.Path ,
436
437
) error {
437
438
sourceFileExtensions := []string {}
438
439
for k := range globals .SourceFilesValidExtensions {
@@ -444,7 +445,7 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
444
445
}
445
446
446
447
for _ , filePath := range filePaths {
447
- sourceFile , err := makeSourceFile (sketchBuildPath , librariesBuildPath , origin , filePath )
448
+ sourceFile , err := makeSourceFile (sourceDir , buildDir , filePath , extraIncludePath ... )
448
449
if err != nil {
449
450
return errors .WithStack (err )
450
451
}
@@ -537,33 +538,42 @@ func (f *sourceFile) Equals(g *sourceFile) bool {
537
538
// given origin. The given path can be absolute, or relative within the
538
539
// origin's root source folder
539
540
func makeSourceFile (
540
- sketchBuildPath * paths.Path ,
541
- librariesBuildPath * paths.Path ,
542
- origin interface {} ,
543
- path * paths.Path ,
541
+ sourceDir * paths.Path ,
542
+ buildDir * paths.Path ,
543
+ sourceFilePath * paths. Path ,
544
+ extraIncludePath ... * paths.Path ,
544
545
) (* sourceFile , error ) {
545
- res := & sourceFile {}
546
-
547
- switch o := origin .(type ) {
548
- case * sketch.Sketch :
549
- res .buildRoot = sketchBuildPath
550
- res .sourceRoot = sketchBuildPath
551
- case * libraries.Library :
552
- res .buildRoot = librariesBuildPath .Join (o .DirName )
553
- res .sourceRoot = o .SourceDir
554
- res .extraIncludePath = o .UtilityDir
555
- default :
556
- panic ("Unexpected origin for SourceFile: " + fmt .Sprint (origin ))
557
- }
558
-
559
- if path .IsAbs () {
546
+ res := & sourceFile {
547
+ buildRoot : buildDir ,
548
+ sourceRoot : sourceDir ,
549
+ }
550
+
551
+ if len (extraIncludePath ) > 1 {
552
+ panic ("only one extra include path allowed" )
553
+ }
554
+ if len (extraIncludePath ) > 0 {
555
+ res .extraIncludePath = extraIncludePath [0 ]
556
+ }
557
+ // switch o := origin.(type) {
558
+ // case *sketch.Sketch:
559
+ // res.buildRoot = sketchBuildPath
560
+ // res.sourceRoot = sketchBuildPath
561
+ // case *libraries.Library:
562
+ // res.buildRoot = librariesBuildPath.Join(o.DirName)
563
+ // res.sourceRoot = o.SourceDir
564
+ // res.extraIncludePath = o.UtilityDir
565
+ // default:
566
+ // panic("Unexpected origin for SourceFile: " + fmt.Sprint(origin))
567
+ // }
568
+
569
+ if sourceFilePath .IsAbs () {
560
570
var err error
561
- path , err = res .sourceRoot .RelTo (path )
571
+ sourceFilePath , err = res .sourceRoot .RelTo (sourceFilePath )
562
572
if err != nil {
563
573
return nil , err
564
574
}
565
575
}
566
- res .relativePath = path
576
+ res .relativePath = sourceFilePath
567
577
return res , nil
568
578
}
569
579
0 commit comments