MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / inspect_headers

Function inspect_headers

tools/gen_struct_info.py:234–268  ·  view source on GitHub ↗
(headers, cflags)

Source from the content-addressed store, hash-verified

232
233
234def inspect_headers(headers, cflags):
235 # Write the source code to a temporary file.
236 src_file_fd, src_file_path = tempfile.mkstemp('.c', text=True)
237 show('Generating C code... ' + src_file_path)
238 code = generate_c_code(headers)
239 os.write(src_file_fd, '\n'.join(code).encode())
240 os.close(src_file_fd)
241
242 js_file_fd, js_file_path = tempfile.mkstemp('.js')
243 # Close the unneeded FD.
244 os.close(js_file_fd)
245
246 cmd = generate_cmd(js_file_path, src_file_path, cflags)
247
248 try:
249 subprocess.check_call(cmd, env=system_libs.clean_env())
250 except subprocess.CalledProcessError as e:
251 sys.stderr.write('FAIL: Compilation failed!: %s\n' % e.cmd)
252 sys.exit(1)
253
254 # Run the compiled program.
255 show('Running generated program... ' + js_file_path, config.NODE_JS)
256 info = shared.run_js_tool(js_file_path, stdout=shared.PIPE)
257
258 if not DEBUG:
259 # Remove all temporary files.
260 os.unlink(src_file_path)
261
262 if os.path.exists(js_file_path):
263 os.unlink(js_file_path)
264 wasm_file_path = utils.replace_suffix(js_file_path, '.wasm')
265 os.unlink(wasm_file_path)
266
267 # Parse the output of the program into a dict.
268 return json.loads(info)
269
270
271def merge_info(target, src):

Callers 1

inspect_codeFunction · 0.85

Calls 8

generate_c_codeFunction · 0.85
generate_cmdFunction · 0.85
encodeMethod · 0.80
existsMethod · 0.80
showFunction · 0.70
writeMethod · 0.45
joinMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected