@@ -290,7 +290,7 @@ func (l *SketchLibrariesDetector) findIncludes(
290290
291291 if ! l .useCachedLibrariesResolution {
292292 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" ))
294294 if err != nil {
295295 return err
296296 }
@@ -503,7 +503,7 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
503503 }
504504
505505 for _ , filePath := range filePaths {
506- sourceFile , err := makeSourceFile (sourceDir , buildDir , filePath , extraIncludePath ... )
506+ sourceFile , err := l . makeSourceFile (sourceDir , buildDir , filePath , extraIncludePath ... )
507507 if err != nil {
508508 return err
509509 }
@@ -513,6 +513,33 @@ func (l *SketchLibrariesDetector) queueSourceFilesFromFolder(
513513 return nil
514514}
515515
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+
516543func (l * SketchLibrariesDetector ) failIfImportedLibraryIsWrong () error {
517544 if len (l .importedLibraries ) == 0 {
518545 return nil
0 commit comments