MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / CargoBuild

Class CargoBuild

misc/python/materialize/mzbuild.py:624–865  ·  view source on GitHub ↗

A `PreImage` action that builds a single binary with Cargo. See doc/developer/mzbuild.md for an explanation of the user-facing parameters.

Source from the content-addressed store, hash-verified

622
623
624class CargoBuild(CargoPreImage):
625 """A `PreImage` action that builds a single binary with Cargo.
626
627 See doc/developer/mzbuild.md for an explanation of the user-facing
628 parameters.
629 """
630
631 def __init__(self, rd: RepositoryDetails, path: Path, config: dict[str, Any]):
632 super().__init__(rd, path)
633 bin = config.pop("bin", [])
634 self.bins = bin if isinstance(bin, list) else [bin]
635 example = config.pop("example", [])
636 self.examples = example if isinstance(example, list) else [example]
637 self.strip = config.pop("strip", True)
638 self.extract = config.pop("extract", {})
639 features = config.pop("features", [])
640 self.features = features if isinstance(features, list) else [features]
641
642 if len(self.bins) == 0 and len(self.examples) == 0:
643 raise ValueError("mzbuild config is missing pre-build target")
644
645 @staticmethod
646 def generate_cargo_build_command(
647 rd: RepositoryDetails,
648 bins: list[str],
649 examples: list[str],
650 features: list[str] | None = None,
651 ) -> list[str]:
652 rustflags = (
653 rustc_flags.coverage
654 if rd.coverage
655 else (
656 rustc_flags.sanitizer[rd.sanitizer]
657 if rd.sanitizer != Sanitizer.none
658 else ["--cfg=tokio_unstable"]
659 )
660 )
661 cflags = (
662 [
663 f"--target={target(rd.arch)}",
664 f"--gcc-toolchain=/opt/x-tools/{target(rd.arch)}/",
665 "-fuse-ld=lld",
666 f"--sysroot=/opt/x-tools/{target(rd.arch)}/{target(rd.arch)}/sysroot",
667 f"-L/opt/x-tools/{target(rd.arch)}/{target(rd.arch)}/lib64",
668 ]
669 + rustc_flags.sanitizer_cflags[rd.sanitizer]
670 if rd.sanitizer != Sanitizer.none
671 else []
672 )
673 extra_env = (
674 {
675 "CFLAGS": " ".join(cflags),
676 "CXXFLAGS": " ".join(cflags),
677 "LDFLAGS": " ".join(cflags),
678 "CXXSTDLIB": "stdc++",
679 "CC": "cc",
680 "CXX": "c++",
681 "CPP": "clang-cpp-18",

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected