@@ -42,7 +42,6 @@ type IncludesToIncludeFolders struct{}
4242
4343func (s * IncludesToIncludeFolders ) Run (ctx * types.Context ) error {
4444 include := ctx .IncludeJustFound
45- includes := []string {include }
4645 includeFolders := ctx .IncludeFolders
4746 headerToLibraries := ctx .HeaderToLibraries
4847
@@ -55,43 +54,32 @@ func (s *IncludesToIncludeFolders) Run(ctx *types.Context) error {
5554 return nil ;
5655 }
5756
58- newlyImportedLibraries := resolveLibraries (includes , headerToLibraries , importedLibraries , []* types.Platform {actualPlatform , platform }, libraryResolutionResults )
57+ newlyImportedLibrary := resolveLibrary (include , headerToLibraries , importedLibraries , []* types.Platform {actualPlatform , platform }, libraryResolutionResults )
58+ if newlyImportedLibrary == nil {
59+ return nil ;
60+ }
61+
5962 foldersWithSources := ctx .FoldersWithSourceFiles
6063
61- for _ , newlyImportedLibrary := range newlyImportedLibraries {
62- if ! sliceContainsLibrary (importedLibraries , newlyImportedLibrary ) {
63- importedLibraries = append (importedLibraries , newlyImportedLibrary )
64- sourceFolders := types .LibraryToSourceFolder (newlyImportedLibrary )
65- for _ , sourceFolder := range sourceFolders {
66- foldersWithSources .Push (sourceFolder )
67- }
68- includeFolders = append (includeFolders , newlyImportedLibrary .SrcFolder )
69- }
64+ importedLibraries = append (importedLibraries , newlyImportedLibrary )
65+ sourceFolders := types .LibraryToSourceFolder (newlyImportedLibrary )
66+ for _ , sourceFolder := range sourceFolders {
67+ foldersWithSources .Push (sourceFolder )
7068 }
69+ includeFolders = append (includeFolders , newlyImportedLibrary .SrcFolder )
7170
7271 ctx .ImportedLibraries = importedLibraries
7372 ctx .IncludeFolders = includeFolders
7473
7574 return nil
7675}
7776
78- func resolveLibraries ( includes [] string , headerToLibraries map [string ][]* types.Library , importedLibraries []* types.Library , platforms []* types.Platform , libraryResolutionResults map [string ]types.LibraryResolutionResult ) [] * types.Library {
77+ func resolveLibrary ( header string , headerToLibraries map [string ][]* types.Library , importedLibraries []* types.Library , platforms []* types.Platform , libraryResolutionResults map [string ]types.LibraryResolutionResult ) * types.Library {
7978 markImportedLibrary := make (map [* types.Library ]bool )
8079 for _ , library := range importedLibraries {
8180 markImportedLibrary [library ] = true
8281 }
83- var newlyImportedLibraries []* types.Library
84- for _ , header := range includes {
85- library := resolveLibrary (header , headerToLibraries , markImportedLibrary , platforms , libraryResolutionResults )
86- if library != nil {
87- newlyImportedLibraries = append (newlyImportedLibraries , library )
88- }
89- }
90-
91- return newlyImportedLibraries
92- }
9382
94- func resolveLibrary (header string , headerToLibraries map [string ][]* types.Library , markImportedLibrary map [* types.Library ]bool , platforms []* types.Platform , libraryResolutionResults map [string ]types.LibraryResolutionResult ) * types.Library {
9583 libraries := append ([]* types.Library {}, headerToLibraries [header ]... )
9684
9785 if libraries == nil || len (libraries ) == 0 {
0 commit comments