fix(CLI-02): make Rust crate buildable outside the repository
build.rs resolved the .proto files via a monorepo-relative path and packaging relied on `cargo publish --no-verify` to hide the resulting failure. Vendor the three canonical protos into clients/rust/protos/, resolve them via CARGO_MANIFEST_DIR (in-repo path preferred, vendored fallback for the packaged crate), ship them via Cargo.toml `include`, and drop `--no-verify` from pack-clients.ps1. archreview: CLI-02 (P1). Verified: cargo fmt/check/test (28) + clippy -D warnings, and `cargo package` (no --no-verify) compiles standalone in the isolated staging dir — the out-of-repo proof. Vendored-proto drift is guarded by check-codegen.ps1.
This commit is contained in:
+17
-3
@@ -6,11 +6,25 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
configure_protoc();
|
||||
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
|
||||
let repo_root = manifest_dir
|
||||
|
||||
// Resolve the proto source directory. In-repo builds prefer the canonical
|
||||
// Contracts protos (two levels above clients/rust) so local `.proto` edits
|
||||
// are picked up live. When that path is absent — e.g. a consumer building
|
||||
// the crate unpacked from a published tarball — fall back to the vendored
|
||||
// copies shipped in `clients/rust/protos/` (see build.rs staleness note and
|
||||
// CLI-02 in archreview/remediation/50-clients.md). Vendored copies are
|
||||
// build inputs only; the canonical source remains in Contracts and must be
|
||||
// refreshed here whenever the `.proto` files change.
|
||||
let repo_proto_root = manifest_dir
|
||||
.parent()
|
||||
.and_then(Path::parent)
|
||||
.ok_or("clients/rust must live two levels below the repository root")?;
|
||||
let proto_root = repo_root.join("src/ZB.MOM.WW.MxGateway.Contracts/Protos");
|
||||
.map(|repo_root| repo_root.join("src/ZB.MOM.WW.MxGateway.Contracts/Protos"));
|
||||
let vendored_proto_root = manifest_dir.join("protos");
|
||||
let proto_root = match repo_proto_root {
|
||||
Some(path) if path.is_dir() => path,
|
||||
_ => vendored_proto_root,
|
||||
};
|
||||
|
||||
let gateway_proto = proto_root.join("mxaccess_gateway.proto");
|
||||
let worker_proto = proto_root.join("mxaccess_worker.proto");
|
||||
let galaxy_proto = proto_root.join("galaxy_repository.proto");
|
||||
|
||||
Reference in New Issue
Block a user