@@ -88,41 +88,7 @@ func resolveIncludeFolders(importedLibraries []*types.Library, buildProperties m
88
88
func resolveLibraries (includes []string , headerToLibraries map [string ][]* types.Library , previousImportedLibraries []* types.Library , platforms []* types.Platform , debugLevel int , logger i18n.Logger ) ([]* types.Library , error ) {
89
89
markImportedLibrary := make (map [* types.Library ]bool )
90
90
for _ , header := range includes {
91
- libraries := headerToLibraries [header ]
92
- if libraries != nil {
93
- if len (libraries ) == 1 {
94
- markImportedLibrary [libraries [0 ]] = true
95
- } else {
96
- var library * types.Library
97
- for _ , platform := range platforms {
98
- if platform != nil && library == nil {
99
- librariesWithinSpecifiedPlatform := librariesWithinPlatform (libraries , platform )
100
- library = findBestLibraryWithHeader (header , librariesWithinSpecifiedPlatform )
101
- }
102
- }
103
- for _ , platform := range platforms {
104
- if platform != nil && library == nil {
105
- library = findBestLibraryWithHeader (header , librariesCompatibleWithPlatform (libraries , platform ))
106
- }
107
- }
108
- if library == nil {
109
- library = findBestLibraryWithHeader (header , libraries )
110
- }
111
- if library == nil {
112
- library = libraries [0 ]
113
- }
114
- if debugLevel > 0 && ! sliceContainsLibrary (previousImportedLibraries , library ) {
115
- logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR , header )
116
- logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_USED , library .Folder )
117
- for _ , notUsedLibrary := range libraries {
118
- if library != notUsedLibrary {
119
- logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_NOT_USED , notUsedLibrary .Folder )
120
- }
121
- }
122
- }
123
- markImportedLibrary [library ] = true
124
- }
125
- }
91
+ resolveLibrary (header , headerToLibraries , markImportedLibrary , previousImportedLibraries , platforms , debugLevel , logger )
126
92
}
127
93
128
94
var importedLibraries []* types.Library
@@ -133,6 +99,53 @@ func resolveLibraries(includes []string, headerToLibraries map[string][]*types.L
133
99
return importedLibraries , nil
134
100
}
135
101
102
+ func resolveLibrary (header string , headerToLibraries map [string ][]* types.Library , markImportedLibrary map [* types.Library ]bool , previousImportedLibraries []* types.Library , platforms []* types.Platform , debugLevel int , logger i18n.Logger ) {
103
+ libraries := headerToLibraries [header ]
104
+
105
+ if libraries == nil {
106
+ return
107
+ }
108
+
109
+ if len (libraries ) == 1 {
110
+ markImportedLibrary [libraries [0 ]] = true
111
+ return
112
+ }
113
+
114
+ var library * types.Library
115
+
116
+ for _ , platform := range platforms {
117
+ if platform != nil && library == nil {
118
+ librariesWithinSpecifiedPlatform := librariesWithinPlatform (libraries , platform )
119
+ library = findBestLibraryWithHeader (header , librariesWithinSpecifiedPlatform )
120
+ }
121
+ }
122
+
123
+ for _ , platform := range platforms {
124
+ if platform != nil && library == nil {
125
+ library = findBestLibraryWithHeader (header , librariesCompatibleWithPlatform (libraries , platform ))
126
+ }
127
+ }
128
+
129
+ if library == nil {
130
+ library = findBestLibraryWithHeader (header , libraries )
131
+ }
132
+
133
+ if library == nil {
134
+ library = libraries [0 ]
135
+ }
136
+
137
+ if debugLevel > 0 && ! sliceContainsLibrary (previousImportedLibraries , library ) {
138
+ logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR , header )
139
+ logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_USED , library .Folder )
140
+ for _ , notUsedLibrary := range libraries {
141
+ if library != notUsedLibrary {
142
+ logger .Fprintln (os .Stderr , constants .MSG_LIBRARIES_NOT_USED , notUsedLibrary .Folder )
143
+ }
144
+ }
145
+ }
146
+ markImportedLibrary [library ] = true
147
+ }
148
+
136
149
func libraryCompatibleWithPlatform (library * types.Library , platform * types.Platform ) bool {
137
150
if len (library .Archs ) == 0 {
138
151
return true
@@ -234,7 +247,7 @@ func findLibWithNameContaining(name string, libraries []*types.Library) *types.L
234
247
return nil
235
248
}
236
249
237
- // thank you golang for s***ing : I can't use/recycle/adapt utils.SliceContains
250
+ // thank you golang: I can not use/recycle/adapt utils.SliceContains
238
251
func sliceContainsLibrary (slice []* types.Library , target * types.Library ) bool {
239
252
for _ , value := range slice {
240
253
if value == target {
0 commit comments