@@ -290,7 +290,7 @@ func (l *SketchLibrariesDetector) findIncludes(
290
290
291
291
if ! l .useCachedLibrariesResolution {
292
292
sketch := sketch
293
- mergedfile , err := makeSourceFile (sketchBuildPath , sketchBuildPath , paths .New (sketch .MainFile .Base ()+ ".cpp.merged" ))
293
+ mergedfile , err := l . makeSourceFile (sketchBuildPath , sketchBuildPath , paths .New (sketch .MainFile .Base ()+ ".cpp.merged" ))
294
294
if err != nil {
295
295
return err
296
296
}
@@ -503,7 +503,7 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
503
503
}
504
504
505
505
for _ , filePath := range filePaths {
506
- sourceFile , err := makeSourceFile (sourceDir , buildDir , filePath , extraIncludePath ... )
506
+ sourceFile , err := l . makeSourceFile (sourceDir , buildDir , filePath , extraIncludePath ... )
507
507
if err != nil {
508
508
return err
509
509
}
@@ -513,6 +513,33 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
513
513
return nil
514
514
}
515
515
516
+ // makeSourceFile create a sourceFile object for the given source file path.
517
+ // The given sourceFilePath can be absolute, or relative within the sourceRoot root folder.
518
+ func (l * SketchLibrariesDetector ) makeSourceFile (sourceRoot , buildRoot , sourceFilePath * paths.Path , extraIncludePaths ... * paths.Path ) (* sourceFile , error ) {
519
+ if len (extraIncludePaths ) > 1 {
520
+ panic ("only one extra include path allowed" )
521
+ }
522
+ var extraIncludePath * paths.Path
523
+ if len (extraIncludePaths ) > 0 {
524
+ extraIncludePath = extraIncludePaths [0 ]
525
+ }
526
+
527
+ if sourceFilePath .IsAbs () {
528
+ var err error
529
+ sourceFilePath , err = sourceRoot .RelTo (sourceFilePath )
530
+ if err != nil {
531
+ return nil , err
532
+ }
533
+ }
534
+ res := & sourceFile {
535
+ SourcePath : sourceRoot .JoinPath (sourceFilePath ),
536
+ ObjectPath : buildRoot .Join (sourceFilePath .String () + ".o" ),
537
+ DepfilePath : buildRoot .Join (sourceFilePath .String () + ".d" ),
538
+ ExtraIncludePath : extraIncludePath ,
539
+ }
540
+ return res , nil
541
+ }
542
+
516
543
func (l * SketchLibrariesDetector ) failIfImportedLibraryIsWrong () error {
517
544
if len (l .importedLibraries ) == 0 {
518
545
return nil
0 commit comments