@@ -50,10 +50,12 @@ type libraryResolutionResult struct {
50
50
51
51
// SketchLibrariesDetector todo
52
52
type SketchLibrariesDetector struct {
53
+ librariesManager * librariesmanager.LibrariesManager
53
54
librariesResolver * librariesresolver.Cpp
54
55
useCachedLibrariesResolution bool
55
56
cache * detectorCache
56
57
onlyUpdateCompilationDatabase bool
58
+ alwaysBuildProfileLibs bool
57
59
importedLibraries libraries.List
58
60
librariesResolutionResults map [string ]libraryResolutionResult
59
61
includeFolders paths.PathList
@@ -65,20 +67,24 @@ type SketchLibrariesDetector struct {
65
67
66
68
// NewSketchLibrariesDetector todo
67
69
func NewSketchLibrariesDetector (
70
+ lm * librariesmanager.LibrariesManager ,
68
71
libsResolver * librariesresolver.Cpp ,
69
72
useCachedLibrariesResolution bool ,
70
73
onlyUpdateCompilationDatabase bool ,
74
+ alwaysBuildProfileLibs bool ,
71
75
logger * logger.BuilderLogger ,
72
76
diagnosticStore * diagnostics.Store ,
73
77
) * SketchLibrariesDetector {
74
78
return & SketchLibrariesDetector {
79
+ librariesManager : lm ,
75
80
librariesResolver : libsResolver ,
76
81
useCachedLibrariesResolution : useCachedLibrariesResolution ,
77
82
cache : newDetectorCache (),
78
83
librariesResolutionResults : map [string ]libraryResolutionResult {},
79
84
importedLibraries : libraries.List {},
80
85
includeFolders : paths.PathList {},
81
86
onlyUpdateCompilationDatabase : onlyUpdateCompilationDatabase ,
87
+ alwaysBuildProfileLibs : alwaysBuildProfileLibs ,
82
88
logger : logger ,
83
89
diagnosticStore : diagnosticStore ,
84
90
}
@@ -134,10 +140,25 @@ func (l *SketchLibrariesDetector) ImportedLibraries() libraries.List {
134
140
return l .importedLibraries
135
141
}
136
142
137
- // AppendImportedLibraries todo should rename this, probably after refactoring the
138
- // container_find_includes command .
139
- func (l * SketchLibrariesDetector ) AppendImportedLibraries ( library * libraries.Library ) {
143
+ // addAndBuildLibrary adds the given library to the imported libraries list and queues its source files
144
+ // for further processing .
145
+ func (l * SketchLibrariesDetector ) addAndBuildLibrary ( sourceFileQueue * uniqueSourceFileQueue , librariesBuildPath * paths. Path , library * libraries.Library ) {
140
146
l .importedLibraries = append (l .importedLibraries , library )
147
+ if library .Precompiled && library .PrecompiledWithSources {
148
+ // Fully precompiled libraries should have no dependencies to avoid ABI breakage
149
+ if l .logger .VerbosityLevel () == logger .VerbosityVerbose {
150
+ l .logger .Info (i18n .Tr ("Skipping dependencies detection for precompiled library %[1]s" , library .Name ))
151
+ }
152
+ } else {
153
+ for _ , sourceDir := range library .SourceDirs () {
154
+ l .queueSourceFilesFromFolder (
155
+ sourceFileQueue ,
156
+ sourceDir .Dir , sourceDir .Recurse ,
157
+ library .SourceDir ,
158
+ librariesBuildPath .Join (library .DirName ),
159
+ library .UtilityDir )
160
+ }
161
+ }
141
162
}
142
163
143
164
// PrintUsedAndNotUsedLibraries todo
@@ -284,6 +305,16 @@ func (l *SketchLibrariesDetector) findIncludes(
284
305
l .queueSourceFilesFromFolder (sourceFileQueue , srcSubfolderPath , true /* recurse */ , sketchBuildPath , sketchBuildPath )
285
306
}
286
307
308
+ if l .alwaysBuildProfileLibs {
309
+ for _ , library := range l .librariesManager .FindAllInstalled () {
310
+ if library .Location == libraries .User {
311
+ l .logger .Info (i18n .Tr ("The library %[1]s has been automatically added from sketch project." , library .Name ))
312
+ l .addAndBuildLibrary (sourceFileQueue , librariesBuildPath , library )
313
+ l .addIncludeFolder (library .SourceDir )
314
+ }
315
+ }
316
+ }
317
+
287
318
for ! sourceFileQueue .Empty () {
288
319
err := l .findMissingIncludesInCompilationUnit (ctx , sourceFileQueue , buildProperties , librariesBuildPath , platformArch )
289
320
if err != nil {
@@ -452,7 +483,7 @@ func (l *SketchLibrariesDetector) findMissingIncludesInCompilationUnit(
452
483
// Add this library to the list of libraries, the
453
484
// include path and queue its source files for further
454
485
// include scanning
455
- l .AppendImportedLibraries ( library )
486
+ l .addAndBuildLibrary ( sourceFileQueue , librariesBuildPath , library )
456
487
l .addIncludeFolder (library .SourceDir )
457
488
458
489
if library .Precompiled && library .PrecompiledWithSources {
@@ -556,7 +587,7 @@ func LibrariesLoader(
556
587
librariesDirs paths.PathList ,
557
588
buildPlatform * cores.PlatformRelease ,
558
589
targetPlatform * cores.PlatformRelease ,
559
- ) (* librariesresolver.Cpp , []byte , error ) {
590
+ ) (* librariesmanager. LibrariesManager , * librariesresolver.Cpp , []byte , error ) {
560
591
verboseOut := & bytes.Buffer {}
561
592
lm := librariesManager
562
593
if useCachedLibrariesResolution {
@@ -569,7 +600,7 @@ func LibrariesLoader(
569
600
570
601
if builtInLibrariesDir != nil {
571
602
if err := builtInLibrariesDir .ToAbs (); err != nil {
572
- return nil , nil , err
603
+ return nil , nil , nil , err
573
604
}
574
605
lmb .AddLibrariesDir (librariesmanager.LibrariesDir {
575
606
Path : builtInLibrariesDir ,
@@ -592,7 +623,7 @@ func LibrariesLoader(
592
623
593
624
librariesFolders := librariesDirs
594
625
if err := librariesFolders .ToAbs (); err != nil {
595
- return nil , nil , err
626
+ return nil , nil , nil , err
596
627
}
597
628
for _ , folder := range librariesFolders {
598
629
lmb .AddLibrariesDir (librariesmanager.LibrariesDir {
@@ -618,5 +649,5 @@ func LibrariesLoader(
618
649
619
650
allLibs := lm .FindAllInstalled ()
620
651
resolver := librariesresolver .NewCppResolver (allLibs , targetPlatform , buildPlatform )
621
- return resolver , verboseOut .Bytes (), nil
652
+ return lm , resolver , verboseOut .Bytes (), nil
622
653
}
0 commit comments