@@ -49,12 +49,24 @@ protected override void WriteSymbols (StreamWriter output)
49
49
output . WriteLine ( ) ;
50
50
WriteHeaderField ( output , "java_name_width" , mappingData . JavaNameWidth ) ;
51
51
52
+ bool haveAssemblyNames = mappingData . AssemblyNames . Count > 0 ;
53
+ bool haveModules = mappingData . Modules . Count > 0 ;
54
+
52
55
output . WriteLine ( ) ;
53
- output . WriteLine ( $ "{ Indent } .include{ Indent } \" { Path . GetFileName ( SharedIncludeFile ) } \" ") ;
54
- output . WriteLine ( $ "{ Indent } .include{ Indent } \" { Path . GetFileName ( TypemapsIncludeFile ) } \" ") ;
56
+ if ( haveAssemblyNames ) {
57
+ output . WriteLine ( $ "{ Indent } .include{ Indent } \" { Path . GetFileName ( SharedIncludeFile ) } \" ") ;
58
+ } else {
59
+ WriteCommentLine ( output , $ "No shared data present, { Path . GetFileName ( SharedIncludeFile ) } not generated") ;
60
+ }
61
+
62
+ if ( haveModules ) {
63
+ output . WriteLine ( $ "{ Indent } .include{ Indent } \" { Path . GetFileName ( TypemapsIncludeFile ) } \" ") ;
64
+ } else {
65
+ WriteCommentLine ( output , $ "No modules defined, { Path . GetFileName ( TypemapsIncludeFile ) } not generated") ;
66
+ }
55
67
output . WriteLine ( ) ;
56
68
57
- if ( ! sharedBitsWritten ) {
69
+ if ( ! sharedBitsWritten && haveAssemblyNames ) {
58
70
using ( var fs = File . Open ( SharedIncludeFile , FileMode . Create ) ) {
59
71
using ( var sharedOutput = new StreamWriter ( fs , output . Encoding ) ) {
60
72
WriteAssemblyNames ( sharedOutput ) ;
@@ -63,10 +75,14 @@ protected override void WriteSymbols (StreamWriter output)
63
75
}
64
76
}
65
77
66
- using ( var fs = File . Open ( TypemapsIncludeFile , FileMode . Create ) ) {
67
- using ( var mapOutput = new StreamWriter ( fs , output . Encoding ) ) {
68
- WriteMapModules ( output , mapOutput , "map_modules" ) ;
78
+ if ( haveModules ) {
79
+ using ( var fs = File . Open ( TypemapsIncludeFile , FileMode . Create ) ) {
80
+ using ( var mapOutput = new StreamWriter ( fs , output . Encoding ) ) {
81
+ WriteMapModules ( output , mapOutput , "map_modules" ) ;
82
+ }
69
83
}
84
+ } else {
85
+ WriteMapModules ( output , null , "map_modules" ) ;
70
86
}
71
87
72
88
WriteJavaMap ( output , "map_java" ) ;
@@ -128,7 +144,8 @@ void WriteMapModules (StreamWriter output, StreamWriter mapOutput, string symbol
128
144
129
145
string mapName = $ "module{ moduleCounter ++ } _managed_to_java";
130
146
size += WriteStructure ( output , fieldAlignBytes , ( ) => WriteMapModule ( output , mapName , mvid , data ) ) ;
131
- WriteManagedMaps ( mapOutput , mapName , data ) ;
147
+ if ( mapOutput != null )
148
+ WriteManagedMaps ( mapOutput , mapName , data ) ;
132
149
}
133
150
134
151
WriteStructureSize ( output , symbolName , size ) ;
0 commit comments