@@ -73,7 +73,7 @@ private void GenerateSymbols()
73
73
RemainingCompilationTasks -- ;
74
74
else
75
75
InvokeCompiler ( e . CustomCompiler , e . CompilerArguments ,
76
- e . OutputDir , module . SymbolsLibraryName ) ;
76
+ e . OutputDir , module ) ;
77
77
}
78
78
}
79
79
@@ -156,49 +156,23 @@ private SymbolsCodeGenerator GetSymbolsCodeGenerator(Module module)
156
156
return symbolsCodeGenerator ;
157
157
}
158
158
159
- private void InvokeCompiler ( string compiler , string arguments , string outputDir , string symbols )
159
+ private void InvokeCompiler ( string compiler , string arguments , string outputDir , Module module )
160
160
{
161
161
new Thread ( ( ) =>
162
162
{
163
163
int error ;
164
164
string errorMessage ;
165
165
ProcessHelper . Run ( compiler , arguments , out error , out errorMessage ) ;
166
- CollectSymbols ( outputDir , symbols , errorMessage ) ;
166
+ var output = GetOutputFile ( module . SymbolsLibraryName ) ;
167
+ if ( ! File . Exists ( Path . Combine ( outputDir , output ) ) )
168
+ Diagnostics . Error ( errorMessage ) ;
169
+ else
170
+ compiledLibraries [ module ] = new CompiledLibrary
171
+ { OutputDir = outputDir , Library = module . SymbolsLibraryName } ;
167
172
RemainingCompilationTasks -- ;
168
173
} ) . Start ( ) ;
169
174
}
170
175
171
- private void CollectSymbols ( string outputDir , string symbols , string errorMessage )
172
- {
173
- using ( var parserOptions = new ParserOptions ( ) )
174
- {
175
- parserOptions . AddLibraryDirs ( outputDir ) ;
176
- var output = Path . GetFileName ( $@ "{ ( Platform . IsWindows ?
177
- string . Empty : "lib" ) } { symbols } .{
178
- ( Platform . IsMacOS ? "dylib" : Platform . IsWindows ? "dll" : "so" ) } " ) ;
179
- if ( ! File . Exists ( Path . Combine ( outputDir , output ) ) )
180
- {
181
- Diagnostics . Error ( errorMessage ) ;
182
- return ;
183
- }
184
- parserOptions . LibraryFile = output ;
185
- using ( var parserResult = Parser . ClangParser . ParseLibrary ( parserOptions ) )
186
- {
187
- if ( parserResult . Kind == ParserResultKind . Success )
188
- {
189
- var nativeLibrary = ClangParser . ConvertLibrary ( parserResult . Library ) ;
190
- lock ( @lock )
191
- {
192
- Context . Symbols . Libraries . Add ( nativeLibrary ) ;
193
- Context . Symbols . IndexSymbols ( ) ;
194
- }
195
- }
196
- else
197
- Diagnostics . Error ( $ "Parsing of { Path . Combine ( outputDir , output ) } failed.") ;
198
- }
199
- }
200
- }
201
-
202
176
private void CheckBasesForSpecialization ( Class @class )
203
177
{
204
178
foreach ( var @base in @class . Bases . Where ( b => b . IsClass ) )
@@ -232,19 +206,62 @@ private int RemainingCompilationTasks
232
206
remainingCompilationTasks = value ;
233
207
if ( remainingCompilationTasks == 0 )
234
208
{
209
+ foreach ( var module in Context . Options . Modules . Where ( compiledLibraries . ContainsKey ) )
210
+ {
211
+ CompiledLibrary compiledLibrary = compiledLibraries [ module ] ;
212
+ CollectSymbols ( compiledLibrary . OutputDir , compiledLibrary . Library ) ;
213
+ }
235
214
var findSymbolsPass = Context . TranslationUnitPasses . FindPass < FindSymbolsPass > ( ) ;
236
215
findSymbolsPass . Wait = false ;
237
216
}
238
217
}
239
218
}
240
219
}
241
220
221
+ private void CollectSymbols ( string outputDir , string library )
222
+ {
223
+ using ( var parserOptions = new ParserOptions ( ) )
224
+ {
225
+ parserOptions . AddLibraryDirs ( outputDir ) ;
226
+ var output = GetOutputFile ( library ) ;
227
+ parserOptions . LibraryFile = output ;
228
+ using ( var parserResult = Parser . ClangParser . ParseLibrary ( parserOptions ) )
229
+ {
230
+ if ( parserResult . Kind == ParserResultKind . Success )
231
+ {
232
+ var nativeLibrary = ClangParser . ConvertLibrary ( parserResult . Library ) ;
233
+ lock ( @lock )
234
+ {
235
+ Context . Symbols . Libraries . Add ( nativeLibrary ) ;
236
+ Context . Symbols . IndexSymbols ( ) ;
237
+ }
238
+ }
239
+ else
240
+ Diagnostics . Error ( $ "Parsing of { Path . Combine ( outputDir , output ) } failed.") ;
241
+ }
242
+ }
243
+ }
244
+
245
+ private static string GetOutputFile ( string library )
246
+ {
247
+ return Path . GetFileName ( $@ "{ ( Platform . IsWindows ?
248
+ string . Empty : "lib" ) } { library } .{
249
+ ( Platform . IsMacOS ? "dylib" : Platform . IsWindows ? "dll" : "so" ) } " ) ;
250
+ }
251
+
242
252
private int remainingCompilationTasks ;
243
253
private static readonly object @lock = new object ( ) ;
244
254
245
255
private Dictionary < Module , SymbolsCodeGenerator > symbolsCodeGenerators =
246
256
new Dictionary < Module , SymbolsCodeGenerator > ( ) ;
247
257
private Dictionary < Module , HashSet < ClassTemplateSpecialization > > specializations =
248
258
new Dictionary < Module , HashSet < ClassTemplateSpecialization > > ( ) ;
259
+ private Dictionary < Module , CompiledLibrary > compiledLibraries = new Dictionary < Module , CompiledLibrary > ( ) ;
260
+
261
+ private class CompiledLibrary
262
+ {
263
+ public string OutputDir { get ; set ; }
264
+ public string Library { get ; set ; }
265
+ }
249
266
}
250
267
}
0 commit comments