@@ -55,7 +55,7 @@ func (s *LibrariesBuilder) Run(ctx *types.Context) error {
55
55
ctx .LibrariesObjectFiles = objectFiles
56
56
57
57
// Search for precompiled libraries
58
- fixLDFLAGforPrecompiledLibraries (ctx , libs )
58
+ fixLDFLAG (ctx , libs )
59
59
60
60
return nil
61
61
}
@@ -109,35 +109,33 @@ func findExpectedPrecompiledLibFolder(ctx *types.Context, library *libraries.Lib
109
109
return nil
110
110
}
111
111
112
- func fixLDFLAGforPrecompiledLibraries (ctx * types.Context , libs libraries.List ) error {
112
+ func fixLDFLAG (ctx * types.Context , libs libraries.List ) error {
113
113
114
114
for _ , library := range libs {
115
- if library .Precompiled {
116
- // add library src path to compiler.c.elf.extra_flags
117
- // use library.Name as lib name and srcPath/{mcpu} as location
118
- path := findExpectedPrecompiledLibFolder (ctx , library )
119
- if path == nil {
120
- break
121
- }
122
- // find all library names in the folder and prepend -l
123
- filePaths := []string {}
124
- libs_cmd := library .LDflags + " "
125
- extensions := func (ext string ) bool {
126
- return PRECOMPILED_LIBRARIES_VALID_EXTENSIONS_DYNAMIC [ext ] || PRECOMPILED_LIBRARIES_VALID_EXTENSIONS_STATIC [ext ]
127
- }
128
- utils .FindFilesInFolder (& filePaths , path .String (), extensions , false )
129
- for _ , lib := range filePaths {
130
- name := strings .TrimSuffix (filepath .Base (lib ), filepath .Ext (lib ))
131
- // strip "lib" first occurrence
132
- if strings .HasPrefix (name , "lib" ) {
133
- name = strings .Replace (name , "lib" , "" , 1 )
134
- libs_cmd += "-l" + name + " "
135
- }
115
+ // add library src path to compiler.c.elf.extra_flags
116
+ // use library.Name as lib name and srcPath/{mcpu} as location
117
+ path := findExpectedPrecompiledLibFolder (ctx , library )
118
+ if path == nil {
119
+ break
120
+ }
121
+ // find all library names in the folder and prepend -l
122
+ filePaths := []string {}
123
+ libs_cmd := library .LDflags + " "
124
+ extensions := func (ext string ) bool {
125
+ return PRECOMPILED_LIBRARIES_VALID_EXTENSIONS_DYNAMIC [ext ] || PRECOMPILED_LIBRARIES_VALID_EXTENSIONS_STATIC [ext ]
126
+ }
127
+ utils .FindFilesInFolder (& filePaths , path .String (), extensions , false )
128
+ for _ , lib := range filePaths {
129
+ name := strings .TrimSuffix (filepath .Base (lib ), filepath .Ext (lib ))
130
+ // strip "lib" first occurrence
131
+ if strings .HasPrefix (name , "lib" ) {
132
+ name = strings .Replace (name , "lib" , "" , 1 )
133
+ libs_cmd += "-l" + name + " "
136
134
}
137
-
138
- currLDFlags := ctx .BuildProperties .Get (constants .BUILD_PROPERTIES_COMPILER_LIBRARIES_LDFLAGS )
139
- ctx .BuildProperties .Set (constants .BUILD_PROPERTIES_COMPILER_LIBRARIES_LDFLAGS , currLDFlags + "\" -L" + path .String ()+ "\" " + libs_cmd + " " )
140
135
}
136
+
137
+ currLDFlags := ctx .BuildProperties .Get (constants .BUILD_PROPERTIES_COMPILER_LIBRARIES_LDFLAGS )
138
+ ctx .BuildProperties .Set (constants .BUILD_PROPERTIES_COMPILER_LIBRARIES_LDFLAGS , currLDFlags + "\" -L" + path .String ()+ "\" " + libs_cmd + " " )
141
139
}
142
140
return nil
143
141
}
0 commit comments