@@ -42,14 +42,21 @@ import (
4242type IncludesToIncludeFolders struct {}
4343
4444func (s * IncludesToIncludeFolders ) Run (context map [string ]interface {}) error {
45+ if ! utils .MapHas (context , constants .CTX_LIBRARIES ) {
46+ return nil
47+ }
4548 includes := context [constants .CTX_INCLUDES ].([]string )
4649 headerToLibraries := context [constants .CTX_HEADER_TO_LIBRARIES ].(map [string ][]* types.Library )
4750 debugLevel := utils .DebugLevel (context )
4851 logger := context [constants .CTX_LOGGER ].(i18n.Logger )
4952 platform := context [constants .CTX_TARGET_PLATFORM ].(* types.Platform )
5053 actualPlatform := context [constants .CTX_ACTUAL_PLATFORM ].(* types.Platform )
5154
52- importedLibraries , err := resolveLibraries (includes , headerToLibraries , []* types.Platform {actualPlatform , platform }, debugLevel , logger )
55+ var previousImportedLibraries []* types.Library
56+ if utils .MapHas (context , constants .CTX_IMPORTED_LIBRARIES ) {
57+ previousImportedLibraries = context [constants .CTX_IMPORTED_LIBRARIES ].([]* types.Library )
58+ }
59+ importedLibraries , err := resolveLibraries (includes , headerToLibraries , previousImportedLibraries , []* types.Platform {actualPlatform , platform }, debugLevel , logger )
5360 if err != nil {
5461 return utils .WrapError (err )
5562 }
@@ -77,17 +84,15 @@ func resolveIncludeFolders(importedLibraries []*types.Library, buildProperties m
7784 return includeFolders
7885}
7986
80- func resolveLibraries (includes []string , headerToLibraries map [string ][]* types.Library , platforms []* types.Platform , debugLevel int , logger i18n.Logger ) ([]* types.Library , error ) {
87+ //FIXME it's also resolving previously resolved libraries
88+ func resolveLibraries (includes []string , headerToLibraries map [string ][]* types.Library , previousImportedLibraries []* types.Library , platforms []* types.Platform , debugLevel int , logger i18n.Logger ) ([]* types.Library , error ) {
8189 markImportedLibrary := make (map [* types.Library ]bool )
8290 for _ , header := range includes {
8391 libraries := headerToLibraries [header ]
8492 if libraries != nil {
8593 if len (libraries ) == 1 {
8694 markImportedLibrary [libraries [0 ]] = true
8795 } else {
88- if debugLevel > 0 {
89- logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR , header )
90- }
9196 var library * types.Library
9297 for _ , platform := range platforms {
9398 if platform != nil && library == nil {
@@ -109,7 +114,8 @@ func resolveLibraries(includes []string, headerToLibraries map[string][]*types.L
109114 if library == nil {
110115 library = libraries [0 ]
111116 }
112- if debugLevel > 0 {
117+ if debugLevel > 0 && ! sliceContainsLibrary (previousImportedLibraries , library ) {
118+ logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR , header )
113119 logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_USED , library .Folder )
114120 for _ , notUsedLibrary := range libraries {
115121 if library != notUsedLibrary {
@@ -232,3 +238,13 @@ func findLibWithNameContaining(name string, libraries []*types.Library) *types.L
232238 }
233239 return nil
234240}
241+
242+ // thank you golang for s***ing: I can't use/recycle/adapt utils.SliceContains
243+ func sliceContainsLibrary (slice []* types.Library , target * types.Library ) bool {
244+ for _ , value := range slice {
245+ if value == target {
246+ return true
247+ }
248+ }
249+ return false
250+ }
0 commit comments