@@ -67,6 +67,23 @@ def generate_stub(wit_path, stub_name):
6767 except Exception as e :
6868 return False , str (e )
6969
70+ def check_if_empty_stub (stub_name ):
71+ """Check if generated stub only contains empty namespaces"""
72+ stub_file = GENERATED_DIR / f"{ stub_name } .hpp"
73+
74+ try :
75+ with open (stub_file , 'r' ) as f :
76+ content = f .read ()
77+ # Check for the marker comment that indicates empty interfaces
78+ if "This WIT file contains no concrete interface definitions" in content :
79+ # Also verify it only has empty namespaces
80+ if "namespace host {}" in content and "namespace guest {}" in content :
81+ return True
82+ except Exception :
83+ pass
84+
85+ return False
86+
7087def compile_stub (stub_name ):
7188 """Compile a generated stub"""
7289 stub_file = GENERATED_DIR / f"{ stub_name } .hpp"
@@ -107,6 +124,10 @@ def process_wit_file(wit_path):
107124 gen_ok , gen_error = generate_stub (wit_path , stub_name )
108125
109126 if gen_ok :
127+ # Check if this generated an empty stub (references external packages only)
128+ if check_if_empty_stub (stub_name ):
129+ return rel_path , 'empty_stub' , 'Generated empty stub (references external packages only)'
130+
110131 # Compile stub
111132 compile_ok , compile_error = compile_stub (stub_name )
112133
@@ -142,11 +163,13 @@ def main():
142163 'gen_success' : 0 ,
143164 'gen_failed' : 0 ,
144165 'compile_success' : 0 ,
145- 'compile_failed' : 0
166+ 'compile_failed' : 0 ,
167+ 'empty_stubs' : 0
146168 }
147169
148170 failed_generation = []
149171 failed_compilation = []
172+ empty_stub_files = []
150173
151174 # Process files in parallel
152175 with ThreadPoolExecutor (max_workers = num_workers ) as executor :
@@ -163,6 +186,11 @@ def main():
163186 stats ['gen_success' ] += 1
164187 stats ['compile_success' ] += 1
165188 status = f"{ GREEN } ✓{ RESET } "
189+ elif result == 'empty_stub' :
190+ stats ['gen_success' ] += 1
191+ stats ['empty_stubs' ] += 1
192+ status = f"{ YELLOW } ⊘{ RESET } "
193+ empty_stub_files .append ((rel_path , error ))
166194 elif result == 'compile_failed' :
167195 stats ['gen_success' ] += 1
168196 stats ['compile_failed' ] += 1
@@ -191,9 +219,18 @@ def main():
191219 print (f" Total WIT files: { stats ['total' ]} " )
192220 print (f" Generation successful: { stats ['gen_success' ]} ({ stats ['gen_success' ]/ stats ['total' ]* 100 :.1f} %)" )
193221 print (f" Generation failed: { stats ['gen_failed' ]} " )
222+ print (f" Empty stubs (no types): { stats ['empty_stubs' ]} " )
194223 print (f" Compilation successful: { stats ['compile_success' ]} ({ stats ['compile_success' ]/ stats ['total' ]* 100 :.1f} %)" )
195224 print (f" Compilation failed: { stats ['compile_failed' ]} " )
196225
226+ if empty_stub_files :
227+ print (f"\n { YELLOW } Empty stubs ({ len (empty_stub_files )} files):{ RESET } " )
228+ print (f"These files only reference external packages and contain no concrete definitions:" )
229+ for rel_path , reason in empty_stub_files [:10 ]:
230+ print (f" - { rel_path } " )
231+ if len (empty_stub_files ) > 10 :
232+ print (f" ... and { len (empty_stub_files ) - 10 } more" )
233+
197234 if failed_generation :
198235 print (f"\n { YELLOW } Failed generation ({ len (failed_generation )} files):{ RESET } " )
199236 for rel_path , error in failed_generation [:10 ]: # Show first 10
0 commit comments