(cls, instances: list["PreImage"])
| 719 | |
| 720 | @classmethod |
| 721 | def prepare_batch(cls, instances: list["PreImage"]) -> dict[str, Any]: |
| 722 | super().prepare_batch(instances) |
| 723 | |
| 724 | if not instances: |
| 725 | return {} |
| 726 | |
| 727 | # Building all binaries and examples in the same `cargo build` command |
| 728 | # allows Cargo to link in parallel with other work, which can |
| 729 | # meaningfully speed up builds. |
| 730 | |
| 731 | rd: RepositoryDetails | None = None |
| 732 | builds = cast(list[CargoBuild], instances) |
| 733 | bins = set() |
| 734 | examples = set() |
| 735 | features = set() |
| 736 | for build in builds: |
| 737 | if not rd: |
| 738 | rd = build.rd |
| 739 | bins.update(build.bins) |
| 740 | examples.update(build.examples) |
| 741 | features.update(build.features) |
| 742 | assert rd |
| 743 | |
| 744 | ui.section(f"Common build for: {', '.join(bins | examples)}") |
| 745 | |
| 746 | cargo_build = cls.generate_cargo_build_command( |
| 747 | rd, list(bins), list(examples), list(features) if features else None |
| 748 | ) |
| 749 | |
| 750 | run_and_detect_rust_incremental_build_failure(cargo_build, cwd=rd.root) |
| 751 | |
| 752 | # Re-run with JSON-formatted messages and capture the output so we can |
| 753 | # later analyze the build artifacts in `run`. This should be nearly |
| 754 | # instantaneous since we just compiled above with the same crates and |
| 755 | # features. (We don't want to do the compile above with JSON-formatted |
| 756 | # messages because it wouldn't be human readable.) |
| 757 | json_output = spawn.capture( |
| 758 | cargo_build + ["--message-format=json"], |
| 759 | cwd=rd.root, |
| 760 | ) |
| 761 | prep = {"cargo": json_output} |
| 762 | |
| 763 | return prep |
| 764 | |
| 765 | def build(self, build_output: dict[str, Any]) -> None: |
| 766 | cargo_profile = ( |
nothing calls this directly
no test coverage detected