@@ -196,7 +196,7 @@ def gen_inspect_code(path, struct, code):
196196 c_ascent (code )
197197
198198
199- def inspect_headers (headers , cflags ):
199+ def inspect_headers (headers , cflags , cxx = False ):
200200 code = ['#include <stdio.h>' , '#include <stddef.h>' ]
201201 for header in headers :
202202 code .append ('#include "' + header ['name' ] + '"' )
@@ -254,18 +254,18 @@ def inspect_headers(headers, cflags):
254254 show ('Compiling generated code...' )
255255
256256 # -Oz optimizes enough to avoid warnings on code size/num locals
257- cmd = [shared .EMXX ] + cflags + ['-o' , js_file [1 ], src_file [1 ],
258- '-O0' ,
259- '-Werror' ,
260- '-Wno-format' ,
261- '-nostdlib' ,
262- compiler_rt ,
263- '-s' , 'BOOTSTRAPPING_STRUCT_INFO=1' ,
264- '-s' , 'LLD_REPORT_UNDEFINED=1' ,
265- '-s' , 'STRICT' ,
266- # Use SINGLE_FILE=1 so there is only a single
267- # file to cleanup.
268- '-s' , 'SINGLE_FILE' ]
257+ cmd = [shared .EMXX if cxx else shared . EMCC ] + cflags + ['-o' , js_file [1 ], src_file [1 ],
258+ '-O0' ,
259+ '-Werror' ,
260+ '-Wno-format' ,
261+ '-nostdlib' ,
262+ compiler_rt ,
263+ '-s' , 'BOOTSTRAPPING_STRUCT_INFO=1' ,
264+ '-s' , 'LLD_REPORT_UNDEFINED=1' ,
265+ '-s' , 'STRICT' ,
266+ # Use SINGLE_FILE=1 so there is only a single
267+ # file to cleanup.
268+ '-s' , 'SINGLE_FILE' ]
269269
270270 # Default behavior for emcc is to warn for binaryen version check mismatches
271271 # so we should try to match that behavior.
@@ -311,13 +311,13 @@ def merge_info(target, src):
311311 target ['structs' ][key ] = value
312312
313313
314- def inspect_code (headers , cflags ):
314+ def inspect_code (headers , cflags , cxx = False ):
315315 if not DEBUG :
316- info = inspect_headers (headers , cflags )
316+ info = inspect_headers (headers , cflags , cxx )
317317 else :
318318 info = {'defines' : {}, 'structs' : {}}
319319 for header in headers :
320- merge_info (info , inspect_headers ([header ], cflags ))
320+ merge_info (info , inspect_headers ([header ], cflags , cxx ))
321321 return info
322322
323323
@@ -375,7 +375,8 @@ def main(args):
375375
376376 default_json_files = [
377377 shared .path_from_root ('src' , 'struct_info.json' ),
378- shared .path_from_root ('src' , 'struct_info_internal.json' )
378+ shared .path_from_root ('src' , 'struct_info_libc.json' ),
379+ shared .path_from_root ('src' , 'struct_info_libcxx.json' )
379380 ]
380381 parser = argparse .ArgumentParser (description = 'Generate JSON infos for structs.' )
381382 parser .add_argument ('json' , nargs = '*' ,
@@ -411,6 +412,9 @@ def main(args):
411412 internal_cflags = [
412413 '-I' + shared .path_from_root ('system' , 'lib' , 'libc' , 'musl' , 'src' , 'internal' ),
413414 '-I' + shared .path_from_root ('system' , 'lib' , 'libc' , 'musl' , 'src' , 'include' ),
415+ ]
416+
417+ internal_cxxflags = [
414418 '-I' + shared .path_from_root ('system' , 'lib' , 'libcxxabi' , 'src' ),
415419 '-D__USING_EMSCRIPTEN_EXCEPTIONS__' ,
416420 ]
@@ -421,12 +425,16 @@ def main(args):
421425 for f in args .json :
422426 # This is a JSON file, parse it.
423427 header_files = parse_json (f )
428+ cxx = False
424429 # Inspect all collected structs.
425- if 'internal' in f :
430+ if 'libcxx' in f :
431+ use_cflags = cflags + internal_cxxflags
432+ cxx = True
433+ elif 'libc' in f :
426434 use_cflags = cflags + internal_cflags
427435 else :
428436 use_cflags = cflags
429- info_fragment = inspect_code (header_files , use_cflags )
437+ info_fragment = inspect_code (header_files , use_cflags , cxx )
430438 merge_info (info , info_fragment )
431439
432440 output_json (info , args .output )
0 commit comments