Drive the actual core compilation step. The groups argument describes how modules are assigned to C extension modules. See the comments on the Groups type in mypyc.emitmodule for details. Returns the C source code, (for debugging) the pretty printed IR, and list of SourceDeps.
(
sources: list[BuildSource],
options: Options,
groups: emitmodule.Groups,
fscache: FileSystemCache,
compiler_options: CompilerOptions,
)
| 299 | |
| 300 | |
| 301 | def generate_c( |
| 302 | sources: list[BuildSource], |
| 303 | options: Options, |
| 304 | groups: emitmodule.Groups, |
| 305 | fscache: FileSystemCache, |
| 306 | compiler_options: CompilerOptions, |
| 307 | ) -> tuple[list[list[tuple[str, str]]], str, list[SourceDep]]: |
| 308 | """Drive the actual core compilation step. |
| 309 | |
| 310 | The groups argument describes how modules are assigned to C |
| 311 | extension modules. See the comments on the Groups type in |
| 312 | mypyc.emitmodule for details. |
| 313 | |
| 314 | Returns the C source code, (for debugging) the pretty printed IR, and list of SourceDeps. |
| 315 | """ |
| 316 | t0 = time.time() |
| 317 | |
| 318 | try: |
| 319 | result = emitmodule.parse_and_typecheck( |
| 320 | sources, options, compiler_options, groups, fscache |
| 321 | ) |
| 322 | except CompileError as e: |
| 323 | emit_messages(options, e.messages, time.time() - t0, serious=(not e.use_stdout)) |
| 324 | sys.exit(1) |
| 325 | |
| 326 | t1 = time.time() |
| 327 | if result.errors: |
| 328 | emit_messages(options, result.errors, t1 - t0) |
| 329 | sys.exit(1) |
| 330 | |
| 331 | if compiler_options.verbose: |
| 332 | print(f"Parsed and typechecked in {t1 - t0:.3f}s") |
| 333 | |
| 334 | errors = Errors(options) |
| 335 | modules, ctext, mapper = emitmodule.compile_modules_to_c( |
| 336 | result, compiler_options=compiler_options, errors=errors, groups=groups |
| 337 | ) |
| 338 | t2 = time.time() |
| 339 | emit_messages(options, errors.new_messages(), t2 - t1) |
| 340 | if errors.num_errors: |
| 341 | # No need to stop the build if only warnings were emitted. |
| 342 | sys.exit(1) |
| 343 | |
| 344 | if compiler_options.verbose: |
| 345 | print(f"Compiled to C in {t2 - t1:.3f}s") |
| 346 | |
| 347 | if options.mypyc_annotation_file: |
| 348 | generate_annotated_html(options.mypyc_annotation_file, result, modules, mapper) |
| 349 | |
| 350 | # Collect SourceDep dependencies |
| 351 | source_deps = sorted(emitmodule.collect_source_dependencies(modules), key=lambda d: d.path) |
| 352 | |
| 353 | return ctext, "\n".join(format_modules(modules)), source_deps |
| 354 | |
| 355 | |
| 356 | def build_using_shared_lib( |
no test coverage detected
searching dependent graphs…