@@ -97,11 +97,13 @@ public record Configuration
97
97
/// Runs ClangSharp to obtain the raw bindings for the given response file.
98
98
/// </summary>
99
99
/// <param name="config">The ClangSharp configuration.</param>
100
+ /// <param name="rspIndex">the index of the current rsp for logging</param>
101
+ /// <param name="rspCount">the total number of rsps</param>
100
102
private (
101
103
IEnumerable < KeyValuePair < string , Stream > > Sources ,
102
104
IEnumerable < KeyValuePair < string , Stream > > Tests ,
103
105
bool HasErrors
104
- ) ScrapeRawBindings ( ResponseFile config )
106
+ ) ScrapeRawBindings ( ResponseFile config , int rspIndex , int rspCount )
105
107
{
106
108
var files = new Dictionary < string , Stream > ( ) ;
107
109
@@ -121,8 +123,11 @@ Stream OutputStreamFactory(string fileName)
121
123
OutputStreamFactory
122
124
) ;
123
125
var hasErrors = false ;
126
+ int index = 0 ;
127
+ int count = config . Files . Count ;
124
128
foreach ( var file in config . Files )
125
129
{
130
+ index ++ ;
126
131
var filePath = Path . Combine ( config . FileDirectory , file ) ;
127
132
var fileName = Path . GetFileName ( file ) ;
128
133
logger . LogTrace (
@@ -190,19 +195,28 @@ out var handle
190
195
using var translationUnit = TranslationUnit . GetOrCreate ( handle ) ;
191
196
Debug . Assert ( translationUnit is not null ) ;
192
197
193
- logger . LogInformation ( "Generating raw bindings for '{0}'" , fileName ) ;
198
+ logger . LogInformation ( "Generating raw bindings for '{0}' ({1}/{2}) ({3}/{4}) " , fileName , index , count , rspIndex , rspCount ) ;
194
199
pinvokeGenerator . GenerateBindings (
195
200
translationUnit ,
196
201
filePath ,
197
202
config . ClangCommandLineArgs ,
198
203
config . TranslationFlags
199
204
) ;
200
205
pinvokeGenerator . Close ( ) ;
201
- logger . LogDebug (
206
+
207
+ if ( files . Count == 0 )
208
+ {
209
+ logger . LogWarning ( "No files generated for {0}" ,
210
+ filePath ) ;
211
+ }
212
+ else
213
+ {
214
+ logger . LogDebug (
202
215
"Completed generation for {0}, file count: {1}" ,
203
216
filePath ,
204
217
files . Count
205
- ) ;
218
+ ) ;
219
+ }
206
220
}
207
221
catch ( Exception e )
208
222
{
@@ -266,6 +280,8 @@ private async Task ScrapeBindingsAsync(
266
280
// Generate all the sources and tests.
267
281
var aggregatedSources = new ConcurrentDictionary < string , SyntaxTree > ( ) ;
268
282
var aggregatedTests = new ConcurrentDictionary < string , SyntaxTree > ( ) ;
283
+ int rspIndex = 0 ;
284
+ int rspCount = rsps . Count ;
269
285
try
270
286
{
271
287
await Parallel . ForEachAsync (
@@ -279,8 +295,9 @@ await Parallel.ForEachAsync(
279
295
await Task . Run (
280
296
async ( ) =>
281
297
{
298
+ int index = Interlocked . Increment ( ref rspIndex ) ;
282
299
// Generate the raw bindings.
283
- var ( sources , tests , hasErrors ) = ScrapeRawBindings ( rsp ) ;
300
+ var ( sources , tests , hasErrors ) = ScrapeRawBindings ( rsp , index , rspCount ) ;
284
301
285
302
static MemoryStream Reopen ( MemoryStream ms ) =>
286
303
ms . TryGetBuffer ( out var buff ) && buff . Array is not null
@@ -450,6 +467,17 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
450
467
. ReadResponseFiles ( ctx . ConfigurationDirectory , cfg . ClangSharpResponseFiles )
451
468
. ToList ( ) ;
452
469
470
+ if ( rsps . Count == 0 )
471
+ {
472
+ logger . LogWarning ( "No Response files found for {}" , ctx . JobKey ) ;
473
+ }
474
+
475
+ var missingIncludes = rsps . SelectMany < ResponseFile , string > ( rsp => rsp . ClangCommandLineArgs . Where ( arg => arg . StartsWith ( "--include-directory=" ) && ! Directory . Exists ( arg . Substring ( 20 ) ) ) ) . Select ( arg => arg . Substring ( 20 ) ) . Distinct ( ) ;
476
+ if ( missingIncludes . Count ( ) > 0 )
477
+ {
478
+ logger . LogWarning ( "The following includes are missing and may cause erroneous generation: \n " + string . Join ( "\n " , missingIncludes ) ) ;
479
+ }
480
+
453
481
// Apply modifications. This is done before the cache key as modifications to the rsps result in different
454
482
// outputs.
455
483
foreach ( var mod in responseFileMods ? . SelectMany ( x => x . Get ( ctx . JobKey ) ) ?? [ ] )
0 commit comments