(headers, cflags)
| 232 | |
| 233 | |
| 234 | def 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 | |
| 271 | def merge_info(target, src): |
no test coverage detected